Data sampling method and device, equipment and storage medium

By sampling data in the training data of the object detection model according to the number of instances of the label to be sampled in the data unit, and using data units with a large number of instances is preferred, the problem of insufficient effective data is solved and the training convergence speed of the model is improved.

CN119832364APending Publication Date: 2025-04-15ZHEJIANG GEELY HLDG GRP CO LTD +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510023340.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-01-07
Publication Date
2025-04-15

AI Technical Summary

Technical Problem

The amount of effective data in the training data of the object detection model is small, resulting in slow convergence speed of model training.

Method used

By obtaining the number of instances corresponding to each tag to be sampled in each data unit, the target data unit is sampled from each data unit based on this information, and data units with a large number of instances are preferred as the training data of the model.

Benefits of technology

The effective amount of data in the training data of the object detection model is improved, and the training convergence speed of the model is improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119832364A_ABST
    Figure CN119832364A_ABST
Patent Text Reader

Abstract

The invention provides a data sampling method and device, equipment and a storage medium, and the method comprises the steps: obtaining the number of instances corresponding to each to-be-sampled label in each data unit, and enabling each data unit to be obtained through dividing original data according to a preset sampling unit; and based on the instance number corresponding to each to-be-sampled label in each data unit, sampling each target data unit from each data unit, each target data unit being used for training a target detection model. The method is used for solving the problem that the model training convergence speed is low due to the fact that the effective data amount in the training data of the target detection model is small.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of data processing technology, and in particular to a data sampling method, device, equipment and storage medium. Background Art

[0002] In the training of target detection models, the amount of training data is huge, which not only increases the burden of storage and processing, but also puts higher requirements on the efficiency of training. Moreover, the number of instances contained in different scenes varies significantly, which leads to a large difference in the amount of effective training data in different scenes. In some scenes, the amount of effective data is small, which wastes training resources, making it impossible to quickly verify and iterate the model, and the model training convergence speed is slow. Summary of the invention

[0003] The present application provides a data sampling method, apparatus, device and storage medium to solve the problem that the amount of effective data in the training data of the target detection model is small, resulting in slow model training convergence speed.

[0004] According to a first aspect of an embodiment of the present application, a data sampling method is provided, including:

[0005] Obtaining the number of instances corresponding to each to-be-sampled label in each data unit, wherein each of the data units is obtained by dividing the original data according to a preset sampling unit;

[0006] Based on the number of instances corresponding to each to-be-sampled label in each data unit, each target data unit is sampled from each of the data units, wherein each of the target data units is used to train a target detection model.

[0007] Optionally, sampling each target data unit from each of the data units based on the number of instances corresponding to each of the to-be-sampled labels in each of the data units includes:

[0008] Based on the number of instances corresponding to each to-be-sampled label in each data unit, the data units are sorted in descending order to obtain an ordered sequence of data units corresponding to each to-be-sampled label;

[0009] Based on the ordered sequence of data units corresponding to each of the to-be-sampled tags, each target data unit is sampled from each of the data units.

[0010] Optionally, sampling each target data unit from each data unit based on the ordered sequence of data units corresponding to each of the to-be-sampled tags includes:

[0011] Based on the instance density threshold corresponding to the first label to be sampled, select each data unit in the ordered sequence of data units corresponding to the first label to be sampled in order of sorting to obtain a sampling data set corresponding to the first label to be sampled;

[0012] Based on the instance density threshold corresponding to the i-th label to be sampled, select each data unit in the ordered sequence of data units corresponding to the i-th label to be sampled in order of sorting, add the sampled data set corresponding to the (i-1)-th label to be sampled, and remove duplicates to obtain the sampled data set corresponding to the i-th label to be sampled;

[0013] Based on the instance density threshold corresponding to the Nth label to be sampled, select each data unit in the ordered sequence of data units corresponding to the Nth label to be sampled in order of sorting, add the sampled data set corresponding to the (N-1)th label to be sampled, and remove duplicates to obtain the sampled data set corresponding to the Nth label to be sampled;

[0014] Based on the sampling data set corresponding to the Nth label to be sampled, sampling each target data unit from each data unit;

[0015] Wherein, i is greater than 1 and i is less than N, i is an integer, and N is the total number of the labels to be sampled.

[0016] Optionally, based on the instance density threshold corresponding to the first label to be sampled, selecting each data unit in sequence according to the sorting order from the ordered sequence of data units corresponding to the first label to be sampled to obtain a sampled data set corresponding to the first label to be sampled, includes:

[0017] From the ordered sequence of data units corresponding to the first label to be sampled, select each data unit in order according to the sorting order, add the data set corresponding to the first label to be sampled, and determine the instance density corresponding to the first label to be sampled in the data set corresponding to the first label to be sampled;

[0018] When the instance density corresponding to the first label to be sampled is greater than or equal to the instance density threshold corresponding to the first label to be sampled, continue to select each data unit in the ordered sequence of data units corresponding to the first label to be sampled in order of sorting, add the data set corresponding to the first label to be sampled, and determine the instance density corresponding to the first label to be sampled;

[0019] When the instance density corresponding to the first label to be sampled is less than the instance density threshold corresponding to the first label to be sampled, stop adding the data unit to the sampling data set corresponding to the first label to be sampled, and obtain the final sampling data set corresponding to the first label to be sampled;

[0020] The instance density corresponding to the first label to be sampled in the sampling data set corresponding to the first label to be sampled refers to the quotient obtained by dividing the total number of instances corresponding to the first label to be sampled in the sampling data set corresponding to the first label to be sampled by the total number of data units in the sampling data set corresponding to the first label to be sampled.

[0021] Optionally, based on the instance density threshold corresponding to the i-th label to be sampled, each data unit is selected in sequence according to the sorting order from the ordered sequence of data units corresponding to the i-th label to be sampled, and the sampled data set corresponding to the (i-1)-th label to be sampled is added and deduplication is performed to obtain the sampled data set corresponding to the i-th label to be sampled, including:

[0022] Determine the instance density corresponding to the i-th label to be sampled in the sampling data set corresponding to the (i-1)-th label to be sampled;

[0023] When the instance density corresponding to the i-th label to be sampled is greater than or equal to the instance density threshold corresponding to the i-th label to be sampled, select each data unit in the ordered sequence of data units corresponding to the i-th label to be sampled in order of sorting, add the data set corresponding to the (i-1)-th label to be sampled and remove duplicates, and determine the instance density corresponding to the i-th label to be sampled in the data set corresponding to the (i-1)-th label to be sampled;

[0024] When the instance density corresponding to the i-th label to be sampled is less than the instance density threshold corresponding to the i-th label to be sampled, stop adding the data unit to the sampling data set corresponding to the (i-1)-th label to be sampled, and obtain the final sampling data set corresponding to the i-th label to be sampled;

[0025] The instance density corresponding to the i-th label to be sampled in the sampling data set corresponding to the (i-1)-th label to be sampled refers to the quotient obtained by dividing the total number of instances corresponding to the i-th label to be sampled in the sampling data set corresponding to the (i-1)-th label to be sampled by the total number of data units in the sampling data set corresponding to the (i-1)-th label to be sampled.

[0026] Optionally, sampling each target data unit from each data unit based on the sampling data set corresponding to the Nth label to be sampled includes:

[0027] Determine the actual value corresponding to each of the to-be-sampled labels based on the total number of instances corresponding to each of the to-be-sampled labels in the sampling data set corresponding to the Nth to-be-sampled label;

[0028] Obtaining target values ​​corresponding to the labels to be sampled;

[0029] Based on the actual value and the target value corresponding to each of the labels to be sampled, the instance density threshold corresponding to each of the labels to be sampled is updated, the sampling data set corresponding to the Nth label to be sampled is deleted, and the step of returning to execute the step of selecting each data unit in the ordered sequence of data units corresponding to the first label to be sampled in the sorted order based on the instance density threshold corresponding to the first label to be sampled;

[0030] Until the preset condition is met, each data unit in the final sampling data set corresponding to the Nth label to be sampled is determined as each target data unit.

[0031] Optionally, updating the instance density threshold corresponding to each of the to-be-sampled labels based on the actual value and the target value corresponding to each of the to-be-sampled labels includes:

[0032] Subtract the target value from the actual value corresponding to each of the to-be-sampled labels to obtain a difference value corresponding to each of the to-be-sampled labels;

[0033] Multiplying the difference corresponding to each of the to-be-sampled labels by a preset learning rate to obtain a product corresponding to each of the to-be-sampled labels;

[0034] The instance density thresholds corresponding to the labels to be sampled before updating are added to the products corresponding to the labels to be sampled, so as to obtain the instance density thresholds corresponding to the labels to be sampled after updating.

[0035] According to a second aspect of an embodiment of the present application, a data sampling device is provided, including:

[0036] An acquisition unit, used to acquire the number of instances corresponding to each to-be-sampled label in each data unit, wherein each of the data units is obtained by dividing the original data according to a preset sampling unit;

[0037] The sampling unit is used to sample each target data unit from each data unit based on the number of instances corresponding to each to-be-sampled label in each data unit, wherein each target data unit is used to train a target detection model.

[0038] According to a third aspect of an embodiment of the present application, there is provided an electronic device, including a memory and a processor;

[0039] The memory is connected to the processor and is used to store programs;

[0040] The processor is used to implement the data sampling method as described in the first aspect by running the program in the memory.

[0041] According to a fourth aspect of an embodiment of the present application, a storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the data sampling method as described in the first aspect is implemented.

[0042] In the present application, the number of instances corresponding to each label to be sampled in each data unit is obtained, wherein each data unit is obtained by dividing the original data according to a preset sampling unit, and based on the number of instances corresponding to each label to be sampled in each data unit, each target data unit is sampled from each data unit, wherein each target data unit is used to train a target detection model. In the present application, based on the number of instances corresponding to each label to be sampled in each data unit, each target data unit is sampled from each data unit, and target data units with a large number of instances corresponding to each label to be sampled are preferentially used as training data for the target detection model, that is, target data units with a large amount of effective data are preferentially used as training data for the target detection model, thereby increasing the amount of effective data in the training data of the target detection model, and thereby increasing the training convergence speed of the target detection model. BRIEF DESCRIPTION OF THE DRAWINGS

[0043] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying any creative work.

[0044] Figure 1 A schematic diagram of a data sampling method provided in an embodiment of the present application;

[0045] Figure 2 A schematic diagram of a process of step 102 provided in an embodiment of the present application;

[0046] Figure 3 A schematic diagram of a process of step 202 provided in an embodiment of the present application;

[0047] Figure 4 A schematic diagram of a process of step 301 provided in an embodiment of the present application;

[0048] Figure 5A schematic diagram of a process of step 302 provided in an embodiment of the present application;

[0049] Figure 6 A schematic diagram of a process of step 202 provided in an embodiment of the present application;

[0050] Figure 7 A schematic diagram of a data sampling method provided in an embodiment of the present application;

[0051] Figure 8 A schematic diagram of the structure of a data sampling device provided in an embodiment of the present application;

[0052] Fig. 9 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0053] In the training of object detection models, for example, in deep learning training in the field of autonomous driving, model training based on image and radar point cloud data faces several key challenges. First, the amount of training data for object detection models is huge, which not only increases the burden of storage and processing, but also puts higher requirements on the efficiency of algorithm training. Second, the number of instances contained in different scenes varies significantly, which leads to a large difference in the amount of effective training data for different scenes. Furthermore, the number of instances of different labels is extremely unevenly distributed, which may affect the model's recognition ability for minority categories. In addition, existing data sampling and data augmentation algorithms have poor robustness in dealing with these challenges, resulting in slow convergence of model training, small amount of effective data in some scenes, waste of training resources, inability to quickly verify and then iterate the model, and poor detection effect of categories with small number of samples.

[0054] The current data sampling and data enhancement algorithms are usually the following:

[0055] The first

[0056] In the process of training 2D detection models using image data, methods such as mixing augmentation and mosaic augmentation are usually used to increase the effective information density in the image and speed up the model convergence. At the same time, the proportion of different classifications in the training data is balanced to optimize the long-tail problem.

[0057] In the process of training 3D (three-dimensional) detection models through images, since the image is actually the projection of the object in the 3D coordinate system on the 2D plane of the image, which includes the conversion between the world coordinate system, the camera coordinate system, and the image coordinate system, there are complex projection transformations and various camera distortions in the process of projecting the object in the 3D world onto the image plane. This makes it impossible to simulate the projection process of 3D objects onto 2D images by simply splicing and mixing image instances similar to 2D detection, and it is also impossible to solve the problems of low data information density and long tail by augmenting 2D data.

[0058] The second

[0059] In the process of training a 2D detection model using image data, training data can also be generated by training a generative model.

[0060] Generative models for 3D scenes are not yet available, and in most training processes using generated data, there will almost always be some degree of accuracy loss.

[0061] The third

[0062] In the process of training 3D detection models based on radar point cloud data, the point clouds of all instances in the data set are usually saved separately from the global point cloud in units of instances. During the training process, the data is augmented by adding instance point clouds from other scenes to the training data to increase the effective information density in the training data, accelerate the model convergence speed, and balance the proportion of different classifications in the training data to optimize the long-tail problem.

[0063] However, in actual operation, instances in different scenarios cannot be spliced ​​and migrated due to occlusion, weather and other reasons. In addition, during the migration process, instances cannot be placed in the area where instances of the same type should appear or in the state where they should be, such as pedestrians on the motorway, motor vehicles driving in the opposite direction, etc. These reasons lead to that in the actual training process, this method cannot solve the above-mentioned slow model training and long-tail data distribution problems, and sometimes even negative optimization occurs.

[0064] In summary, the following problems exist in the current training of 3D detection models based on images and radar point clouds: the amount of effective data in the training data of the target detection model is small, resulting in slow convergence of model training.

[0065] In order to solve the problem that the amount of effective data in the training data of the target detection model is small, resulting in slow model training convergence speed, the present application provides a data sampling method, device, equipment and storage medium.

[0066] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0067] Exemplary Implementation Environment

[0068] The data sampling method according to the embodiment of the present application can be performed by an electronic device such as a terminal device or a server, and the terminal device can be a user equipment (User Equipment, UE), a mobile device, a user terminal, a terminal, a cellular phone, a cordless phone, a personal digital assistant (Personal Digital Assistant, PDA), a handheld device, a computing device, a vehicle-mounted device, a wearable device, etc. The server can be an independent physical server, a server cluster composed of multiple physical servers, or a cloud server capable of cloud computing. The method can be implemented by a processor calling a computer-readable program instruction stored in a memory.

[0069] Exemplary Methods

[0070] See also Figure 1 In an exemplary embodiment, a data sampling method is provided. Figure 1 As shown in Figure 1, the process of the data sampling method mainly includes:

[0071] Step 101, obtaining the number of instances corresponding to each to-be-sampled label in each data unit.

[0072] Among them, each data unit is obtained by dividing the original data according to the preset sampling unit.

[0073] In an exemplary embodiment, the data sampling process and the training process of the target detection model are independent of each other, and the raw data may include data of various modalities. The raw data may include image data, radar point cloud data, or other types of data, as long as it is labeled data, and this application does not limit this. For example, the raw data may be a nuScenes dataset (autonomous driving dataset).

[0074] In an exemplary embodiment, the preset sampling unit may be a data frame (Frame), where a data frame refers to data corresponding to a moment, for example, a data frame may refer to a frame of image, or may refer to a frame of radar point cloud data. The preset sampling unit may also be a scene (Scene), where a scene refers to a continuous frame sequence within a preset duration, including multiple data frames.

[0075] When each target data unit is used for training and does not require timing information, the data set can be sampled with the data frame as the preset sampling unit; when each target data unit is used for training and requires timing information, that is, the timing relationship between each frame and its previous and subsequent frames is required, it is necessary to sample the data set with the scene as the preset sampling unit. The following embodiments are explained by taking the preset sampling unit as the scene as an example, but this is not limited to this.

[0076] In the exemplary embodiments, an instance may refer to a car, a bicycle, an electric car, a person, etc.

[0077] Step 102: based on the number of instances corresponding to each to-be-sampled label in each data unit, sample each target data unit from each data unit.

[0078] Among them, each target data unit is used to train the target detection model.

[0079] In an exemplary embodiment, the object detection model may be a three-dimensional object detection model.

[0080] In this application, based on the number of instances corresponding to each to-be-sampled label in each data unit, each target data unit is sampled from each data unit, and the target data units with a large number of instances corresponding to each to-be-sampled label are preferentially used as the training data of the target detection model, that is, the target data units with a large amount of effective data are preferentially used as the training data of the target detection model. Under the same training resource usage, the effect of training with the full data set can be approached to the maximum extent, the amount of effective data in the training data of the target detection model can be increased, and the training convergence speed of the target detection model can be improved. Since the data augmentation of a single data unit is not involved in the middle, negative optimization caused by mixed augmentation or generated data will not be introduced.

[0081] In some embodiments, Figure 2 As shown, step 102 includes:

[0082] Step 201 : sort each data unit in descending order based on the number of instances corresponding to each to-be-sampled label in each data unit, to obtain an ordered sequence of data units corresponding to each to-be-sampled label.

[0083] In an exemplary embodiment, N is the total number of tags to be sampled, and N ordered sequences of data units Q1, Q2, ..., QN are generated, wherein the length of each ordered sequence of data units is equal to the number of data units.

[0084] In an exemplary embodiment, the data units are sorted in descending order based on the number of instances corresponding to each label to be sampled in each data unit, which means that for each label to be sampled, the data units are sorted from large to small according to the number of instances corresponding to each label to be sampled in each data unit.

[0085] For example, there are 4 scenes and 3 labels to be sampled (the labels to be sampled are cars, bicycles, and people, that is, N=3). The number of cars in scene 1 is 10, the number of bicycles is 3, and the number of people is 5; the number of cars in scene 2 is 6, the number of bicycles is 5, and the number of people is 6; the number of cars in scene 3 is 8, the number of bicycles is 8, and the number of people is 4; the number of cars in scene 4 is 3, the number of bicycles is 7, and the number of people is 2; then Q1={scene 1, scene 3, scene 2, scene 4} is obtained by sorting the 4 scenes from large to small according to the number of cars, Q2={scene 3, scene 4, scene 2, scene 1} is obtained by sorting the 4 scenes from large to small according to the number of bicycles, and Q3={scene 2, scene 1, scene 3, scene 4} is obtained by sorting the 4 scenes from large to small according to the number of people.

[0086] Step 202: based on the ordered sequence of data units corresponding to the respective tags to be sampled, sample the respective target data units from the respective data units.

[0087] Based on the number of instances corresponding to each label to be sampled in each data unit, each data unit is sorted in descending order to obtain an ordered sequence of data units corresponding to each label to be sampled. Based on the ordered sequence of data units corresponding to each label to be sampled, each target data unit is sampled from each data unit. Data units with a large amount of effective data can be used preferentially, and target data units with a large number of instances corresponding to each label to be sampled can be used preferentially as training data for the target detection model. That is, target data units with a large amount of effective data can be used preferentially as training data for the target detection model. Under the same training resource usage, the effect of training with the full data set can be approached to the maximum extent, the amount of effective data in the training data of the target detection model can be increased, and the training convergence speed of the target detection model can be improved.

[0088] In some embodiments, Figure 3 As shown, step 202 includes:

[0089] Step 301 , based on the instance density threshold corresponding to the first label to be sampled, select each data unit in the ordered sequence of data units corresponding to the first label to be sampled in order of sorting to obtain a sampling data set corresponding to the first label to be sampled.

[0090] In an exemplary embodiment, the instance density corresponding to a single label to be sampled in a data set refers to the quotient obtained by dividing the total number of instances corresponding to the label to be sampled in all data units in the data set by the total number of data units in the data set.

[0091] In an exemplary embodiment, the instance density threshold corresponding to a single to-be-sampled label refers to a threshold set for the instance density corresponding to a single to-be-sampled label in a data set.

[0092] In an exemplary embodiment, the instance density thresholds corresponding to the labels to be sampled are initialized to k1, k2, ..., kN respectively.

[0093] In some embodiments, Figure 4 As shown, step 301 includes:

[0094] Step 401, from the ordered sequence of data units corresponding to the first label to be sampled, select each data unit in sequence according to the sorting order, add it to the sampling data set corresponding to the first label to be sampled, and determine the instance density corresponding to the first label to be sampled in the sampling data set corresponding to the first label to be sampled.

[0095] The instance density corresponding to the first label to be sampled in the sampling data set corresponding to the first label to be sampled refers to the quotient obtained by dividing the total number of instances corresponding to the first label to be sampled in the sampling data set corresponding to the first label to be sampled by the total number of data units in the sampling data set corresponding to the first label to be sampled.

[0096] Step 402, when the instance density corresponding to the first label to be sampled is greater than or equal to the instance density threshold corresponding to the first label to be sampled, continue to select each data unit in the ordered sequence of data units corresponding to the first label to be sampled in the sorted order, add the sampling data set corresponding to the first label to be sampled, and determine the instance density corresponding to the first label to be sampled.

[0097] Step 403, when the instance density corresponding to the first label to be sampled is less than the instance density threshold corresponding to the first label to be sampled, stop adding the data unit to the sampling data set corresponding to the first label to be sampled, and obtain the final sampling data set corresponding to the first label to be sampled.

[0098] For example, in the ordered sequence of data units corresponding to the first label to be sampled, the instance density corresponding to the first label to be sampled of the first m data units is greater than the instance density threshold k1 corresponding to the first label to be sampled, and the instance density corresponding to the first label to be sampled of the first (m+1) data units is less than the instance density threshold k1 corresponding to the first label to be sampled, then the final sampling data set corresponding to the first label to be sampled includes the first m data units in the ordered sequence of data units corresponding to the first label to be sampled.

[0099] From the ordered sequence of data units corresponding to the first label to be sampled, select each data unit in sequence according to the sorting order, and add it to the sampling data set corresponding to the first label to be sampled. When the instance density corresponding to the first label to be sampled is less than the instance density threshold corresponding to the first label to be sampled, stop adding the data unit to the sampling data set corresponding to the first label to be sampled, and obtain the final sampling data set corresponding to the first label to be sampled. It can ensure that the instance density corresponding to the first label to be sampled in the final sampling data set corresponding to the first label to be sampled is greater than or equal to the instance density threshold corresponding to the first label to be sampled, and the final sampling data set corresponding to the first label to be sampled contains data units with a relatively large number of instances of the first label to be sampled, that is, the effective data volume of the first label to be sampled in the final sampling data set corresponding to the first label to be sampled is large.

[0100] Step 302, based on the instance density threshold corresponding to the i-th label to be sampled, select each data unit in the ordered sequence of data units corresponding to the i-th label to be sampled in order of sorting, add the sampling data set corresponding to the (i-1)-th label to be sampled and remove duplicates, so as to obtain the sampling data set corresponding to the i-th label to be sampled.

[0101] In some embodiments, Figure 5 As shown, step 302 includes:

[0102] Step 501 : Determine the instance density corresponding to the i-th label to be sampled in the sampling data set corresponding to the (i-1)-th label to be sampled.

[0103] The instance density corresponding to the i-th label to be sampled in the sampling data set corresponding to the (i-1)-th label to be sampled refers to the quotient obtained by dividing the total number of instances corresponding to the i-th label to be sampled in the sampling data set corresponding to the (i-1)-th label to be sampled by the total number of data units in the sampling data set corresponding to the (i-1)-th label to be sampled.

[0104] Step 502: When the instance density corresponding to the i-th label to be sampled is greater than or equal to the instance density threshold corresponding to the i-th label to be sampled, select each data unit in the ordered sequence of data units corresponding to the i-th label to be sampled in order of sorting, add the sampled data set corresponding to the (i-1)-th label to be sampled and remove duplicates, and then determine the instance density corresponding to the i-th label to be sampled in the sampled data set corresponding to the (i-1)-th label to be sampled.

[0105] Step 503, when the instance density corresponding to the i-th label to be sampled is less than the instance density threshold corresponding to the i-th label to be sampled, stop adding the data unit to the sampling data set corresponding to the (i-1)-th label to be sampled, and obtain the final sampling data set corresponding to the i-th label to be sampled.

[0106] Determine the instance density corresponding to the i-th label to be sampled in the sampling data set corresponding to the (i-1)-th label to be sampled, and count the instance density corresponding to the i-th label to be sampled based on the sampling data set after the (i-1)-th label to be sampled has been sampled. When the instance density corresponding to the i-th label to be sampled is greater than or equal to the instance density threshold corresponding to the i-th label to be sampled, select each data unit in the ordered sequence of data units corresponding to the i-th label to be sampled in order of sorting, add the data set corresponding to the (i-1)-th label to be sampled, and remove duplicates. The sampling data set corresponding to the (i-1)-th label to be sampled is a data unit with a relatively large number of instances of the (i-1)-th label to be sampled and a relatively large number of instances of the i-th label to be sampled.

[0107] When the instance density corresponding to the i-th label to be sampled is less than the instance density threshold corresponding to the i-th label to be sampled, stop adding the data unit to the sampling data set corresponding to the (i-1)-th label to be sampled to obtain the final sampling data set corresponding to the i-th label to be sampled, which can ensure that the instance density corresponding to the i-th label to be sampled in the final sampling data set corresponding to the i-th label to be sampled is greater than or equal to the instance density threshold corresponding to the i-th label to be sampled, and the final sampling data set corresponding to the i-th label to be sampled contains data units with a relatively large number of instances of the i-th label to be sampled. Moreover, the final sampling data set corresponding to the i-th label to be sampled is obtained by adding data units to the sampling data set after the (i-1)-th label to be sampled has been sampled. The number of instances of the (i-1)-th label to be sampled in the final sampling data set corresponding to the i-th label to be sampled is relatively large, that is, the effective data volume of the (i-1)-th label to be sampled and the i-th label to be sampled in the final sampling data set corresponding to the i-th label to be sampled is relatively large.

[0108] For example, the sampling data set after the (i-1)th label to be sampled has been sampled includes m data units. The instance density of the i-th label to be sampled in these m data units is calculated. If it is greater than ki, the scenes that are not in these m scenes in the ordered sequence of data units in descending order of Qi are added to the sampling data set in sequence until it is less than ki.

[0109] Step 303, based on the instance density threshold corresponding to the Nth label to be sampled, select each data unit in the ordered sequence of data units corresponding to the Nth label to be sampled in order of sorting, add the sampling data set corresponding to the (N-1)th label to be sampled and remove duplicates, so as to obtain the sampling data set corresponding to the Nth label to be sampled.

[0110] Step 304 : based on the sampling data set corresponding to the Nth label to be sampled, sample each target data unit from each data unit.

[0111] Wherein, i is greater than 1 and less than N, i is an integer, and N is the total number of labels to be sampled.

[0112] The final obtained sampling data set corresponding to the Nth label to be sampled has a large amount of effective data for each label to be sampled. Based on the sampling data set corresponding to the Nth label to be sampled, each target data unit is sampled from each data unit, and the target data units with a large number of instances corresponding to each label to be sampled are preferentially used as training data for the target detection model. That is, the target data units with a large amount of effective data are preferentially used as training data for the target detection model, thereby increasing the amount of effective data in the training data of the target detection model, thereby improving the training convergence speed of the target detection model.

[0113] In some embodiments, Figure 6 As shown, step 202 includes:

[0114] Step 601 , based on the instance density threshold corresponding to the first label to be sampled, select each data unit in the ordered sequence of data units corresponding to the first label to be sampled in order of sorting to obtain a sampling data set corresponding to the first label to be sampled.

[0115] Step 602, based on the instance density threshold corresponding to the i-th label to be sampled, select each data unit in the ordered sequence of data units corresponding to the i-th label to be sampled in order of sorting, add the sampling data set corresponding to the (i-1)-th label to be sampled and remove duplicates, so as to obtain the sampling data set corresponding to the i-th label to be sampled.

[0116] Step 603, based on the instance density threshold corresponding to the Nth label to be sampled, select each data unit in the ordered sequence of data units corresponding to the Nth label to be sampled in order of sorting, add the sampling data set corresponding to the (N-1)th label to be sampled and remove duplicates, so as to obtain the sampling data set corresponding to the Nth label to be sampled.

[0117] Step 604 : determining the actual value corresponding to each to-be-sampled label based on the total number of instances corresponding to each to-be-sampled label in the sampling data set corresponding to the Nth to-be-sampled label.

[0118] In an exemplary embodiment, the actual value corresponding to each label to be sampled may be the instance density corresponding to each label to be sampled, or may be the value obtained by dividing the number of instances of each label to be sampled by the total number of instances of each label to be sampled in all data units in the sampling data set. This application is not limited to this.

[0119] Step 605: Obtain the target value corresponding to each label to be sampled.

[0120] In an exemplary embodiment, the target value and the actual value correspond to each other. If the actual value corresponding to each label to be sampled is the instance density corresponding to each label to be sampled, then the target value corresponding to each label to be sampled is the target value of the instance density corresponding to each label to be sampled; if the actual value corresponding to each label to be sampled is the value obtained by dividing the number of instances of each label to be sampled by the total number of instances of each label to be sampled in all data units in the sampling data set, then the target value corresponding to each label to be sampled is also a quantity ratio value.

[0121] Step 606, determine whether the preset conditions are met, if so, execute step 607, otherwise, execute step 608.

[0122] In an exemplary embodiment, the preset condition may include reaching the maximum number of iterations, or may include that the difference between the actual distribution and the target distribution is less than a threshold value, and this application does not limit this. The actual distribution and the target distribution actually refer to the actual data ratio and the target data ratio corresponding to each label to be sampled. Multiple data are called distributions. Some mathematical algorithms, such as cross entropy, are used to calculate the difference between the actual distribution and the target distribution.

[0123] Step 607 : determine each data unit in the final sampling data set corresponding to the Nth label to be sampled as each target data unit.

[0124] Step 608 , based on the actual value and target value corresponding to each to-be-sampled label, update the instance density threshold corresponding to each to-be-sampled label, delete the sample data set corresponding to the Nth to-be-sampled label, and return to execute step 601 .

[0125] Wherein, i is greater than 1 and less than N, i is an integer, and N is the total number of labels to be sampled.

[0126] The temporary data set sampled previously needs to be cleared during each loop because the instance density threshold corresponding to each label to be sampled changes in each loop, and the temporary data set sampled also changes.

[0127] In some embodiments, in step 608, based on the actual value and target value corresponding to each label to be sampled, the instance density threshold corresponding to each label to be sampled is updated, including: subtracting the target value from the actual value corresponding to each label to be sampled to obtain the difference corresponding to each label to be sampled; multiplying the difference corresponding to each label to be sampled by the preset learning rate to obtain the product corresponding to each label to be sampled; adding the instance density threshold corresponding to each label to be sampled before the update to the product corresponding to each label to be sampled to obtain the instance density threshold corresponding to each label to be sampled after the update.

[0128] For example, taking the i-th label to be sampled as an example, the actual value corresponding to the i-th label to be sampled is percent(i), the target value corresponding to the i-th label to be sampled is target(i), and the instance density threshold corresponding to the i-th label to be sampled after update = ki+lr*(percent(i)-target(i)). Among them, ki is the instance density threshold corresponding to the i-th label to be sampled before the update, and lr is the preset learning rate.

[0129] In an exemplary embodiment, Figure 7 As shown, the data sampling methods include:

[0130] Step 701, initializing the target value and instance density threshold corresponding to each label.

[0131] Step 702: Count the density of each scene instance under each tag and sort them in descending order.

[0132] Step 703, processing scenes in descending order of scene instance density under the current tag.

[0133] Step 704 , determining whether the instance density of the data set after sampling is greater than a threshold, if so, executing step 705 , otherwise, executing step 707 .

[0134] Step 705: The scene is added to the sampled data set.

[0135] Step 706, determine whether it is the last scene of the current tag, if so, execute step 707, otherwise, execute step 708.

[0136] Step 707 , determine whether all tags have been processed, if so, execute step 709 , otherwise, execute step 713 .

[0137] Step 708, process the next scene of the current tag and return to step 704.

[0138] Step 709, calculating the difference between the actual distribution and the target distribution.

[0139] Step 710, determine whether the difference is less than a threshold or reaches a maximum number of iterations. If so, execute step 711; otherwise, execute step 712.

[0140] Step 711, end, output the sampled data set.

[0141] Step 712 , updating the instance density threshold, clearing the sampled data set, and returning to step 703 .

[0142] Step 713, process the next tag and return to step 703.

[0143] According to the set data label ratio, the scene or data frame is sampled so that the data label distribution is close to the customized label distribution ratio, which can simply and effectively adjust the data distribution and solve the long-tail problem of data distribution. It only needs a labeled data set, several labels to be screened, and the target ratio of each label classification, and the data set can be automatically sampled through an adaptive algorithm. The method is simple.

[0144] In summary, in the present application, the number of instances corresponding to each label to be sampled in each data unit is obtained, wherein each data unit is obtained by dividing the original data according to a preset sampling unit, and based on the number of instances corresponding to each label to be sampled in each data unit, each target data unit is sampled from each data unit, wherein each target data unit is used to train a target detection model. In the present application, based on the number of instances corresponding to each label to be sampled in each data unit, each target data unit is sampled from each data unit, and target data units with a large number of instances corresponding to each label to be sampled are preferentially used as training data for the target detection model, that is, target data units with a large amount of effective data are preferentially used as training data for the target detection model, thereby increasing the amount of effective data in the training data of the target detection model, and thereby increasing the training convergence speed of the target detection model.

[0145] Exemplary Devices

[0146] Accordingly, the present application also provides a data sampling device, such as Figure 8 As shown, the data sampling device includes:

[0147] An acquisition unit 801 is used to acquire the number of instances corresponding to each to-be-sampled label in each data unit, wherein each data unit is obtained by dividing the original data according to a preset sampling unit;

[0148] The sampling unit 802 is used to sample each target data unit from each data unit based on the number of instances corresponding to each to-be-sampled label in each data unit, wherein each target data unit is used to train the target detection model.

[0149] The data sampling device provided in this embodiment belongs to the same application concept as the data sampling method provided in the above embodiments of this application, can execute the data sampling method provided in any of the above embodiments of this application, and has the corresponding functional modules and beneficial effects of executing the data sampling method. For technical details not fully described in this embodiment, please refer to the specific processing content of the data sampling method provided in the above embodiments of this application, and will not be repeated here.

[0150] The functions implemented by the above acquisition unit 801 and sampling unit 802 may be implemented by the same or different processors, respectively, and are not limited in the embodiment of the present application.

[0151] It should be understood that the units in the above devices can be implemented in the form of a processor calling software. For example, the device includes a processor, the processor is connected to a memory, and instructions are stored in the memory. The processor calls the instructions stored in the memory to implement any of the above methods or realize the functions of each unit of the device, wherein the processor can be a general-purpose processor, such as a CPU or a microprocessor, etc., and the memory can be a memory in the device or a memory outside the device. Alternatively, the units in the device can be implemented in the form of hardware circuits, and the functions of some or all units can be realized by designing the hardware circuits. The hardware circuit can be understood as one or more processors; for example, in one implementation, the hardware circuit is an ASIC, and the functions of some or all of the above units are realized by designing the logical relationship of the components in the circuit; for another example, in another implementation, the hardware circuit can be implemented by PLD, taking FPGA as an example, which can include a large number of logic gate circuits, and the connection relationship between the logic gate circuits is configured by the configuration file, so as to realize the functions of some or all of the above units. All units of the above devices can be implemented in the form of a processor calling software, or in the form of hardware circuits, or in part by a processor calling software, and the remaining part is implemented in the form of hardware circuits.

[0152] In an embodiment of the present application, a processor is a circuit with the ability to process signals. In one implementation, the processor may be a circuit with the ability to read and run instructions, such as a CPU, a microprocessor, a GPU, or a DSP; in another implementation, the processor may implement certain functions through the logical relationship of a hardware circuit, and the logical relationship of the hardware circuit is fixed or reconfigurable, such as a hardware circuit implemented by an ASIC or PLD, such as an FPGA. In a reconfigurable hardware circuit, the process of the processor loading a configuration document to implement the hardware circuit configuration can be understood as the process of the processor loading instructions to implement the functions of some or all of the above units. In addition, it can also be a hardware circuit designed for artificial intelligence, which can be understood as an ASIC, such as an NPU, TPU, DPU, etc.

[0153] It can be seen that each unit in the above device can be one or more processors (or processing circuits) configured to implement the above method, such as: CPU, GPU, NPU, TPU, DPU, microprocessor, DSP, ASIC, FPGA, or a combination of at least two of these processor forms.

[0154] In addition, all or part of the units in the above device can be integrated together, or can be implemented independently. In one implementation, these units are integrated together and implemented in the form of a SOC. The SOC may include at least one processor for implementing any of the above methods or implementing the functions of each unit of the device. The type of the at least one processor may be different, for example, including a CPU and an FPGA, a CPU and an artificial intelligence processor, a CPU and a GPU, etc.

[0155] Exemplary Electronic Devices

[0156] An embodiment of the present application provides an electronic device, see Fig. 9 As shown, the device includes:

[0157] Memory 200 and processor 210;

[0158] The memory 200 is connected to the processor 210 and is used to store programs;

[0159] The processor 210 is used to implement the data sampling method disclosed in any of the above embodiments by running the program stored in the memory 200.

[0160] Specifically, the electronic device may further include: a bus, a communication interface 220 , an input device 230 and an output device 240 .

[0161] The processor 210, the memory 200, the communication interface 220, the input device 230 and the output device 240 are connected to each other via a bus.

[0162] A bus may include a pathway that transfers information between components of a computer system.

[0163] The processor 210 may be a general-purpose processor, such as a general-purpose central processing unit (CPU), a microprocessor, etc., or an application-specific integrated circuit (ASIC), or one or more integrated circuits for controlling the execution of the program of the scheme of the present invention. It may also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.

[0164] The processor 210 may include a main processor, and may also include a baseband chip, a modem, and the like.

[0165] The memory 200 stores a program for executing the technical solution of the present invention, and may also store an operating system and other key services. Specifically, the program may include a program code, and the program code includes a computer operation instruction. More specifically, the memory 200 may include a read-only memory (ROM), other types of static storage devices that can store static information and instructions, a random access memory (RAM), other types of dynamic storage devices that can store information and instructions, a disk storage, a flash, and the like.

[0166] The input device 230 may include a device for receiving data and information input by a user, such as a keyboard, a mouse, a camera, a scanner, a light pen, a voice input device, a touch screen, a pedometer, or a gravity sensor.

[0167] Output device 240 may include devices that allow information to be output to a user, such as a display screen, printer, speaker, etc.

[0168] The communication interface 220 may include any transceiver or the like to communicate with other devices or communication networks, such as Ethernet, Radio Access Network (RAN), Wireless Local Area Network (WLAN), etc.

[0169] The processor 210 executes the program stored in the memory 200 and calls other devices, which can be used to implement each step of any data sampling method provided in the above embodiments of the present application.

[0170] Exemplary computer program products and storage media

[0171] In addition to the above-mentioned methods and devices, an embodiment of the present application may also be a computer program product, which includes computer program instructions, which, when executed by a processor, enable the processor to execute the steps of the data sampling method according to various embodiments of the present application described in any of the above-mentioned embodiments of this specification.

[0172] The computer program product may be written in any combination of one or more programming languages ​​to write program codes for performing the operations of the embodiments of the present application, including object-oriented programming languages, such as Java, C++, etc., and conventional procedural programming languages, such as "C" language or similar programming languages. The program code may be executed entirely on the user computing device, partially on the user device, as an independent software package, partially on the user computing device and partially on a remote computing device, or entirely on a remote computing device or server.

[0173] In addition, the embodiment of the present application may also be a storage medium on which a computer program is stored. The computer program is executed by a processor to execute the steps of the data sampling method according to various embodiments of the present application described in any of the above embodiments of this specification, and specifically the following steps may be implemented:

[0174] Step 101, obtaining the number of instances corresponding to each to-be-sampled label in each data unit.

[0175] Among them, each data unit is obtained by dividing the original data according to the preset sampling unit.

[0176] Step 102: based on the number of instances corresponding to each to-be-sampled label in each data unit, sample each target data unit from each data unit.

[0177] Among them, each target data unit is used to train the target detection model.

[0178] For the aforementioned method embodiments, for the sake of simplicity, they are all described as a series of action combinations, but those skilled in the art should be aware that the present application is not limited by the order of the actions described, because according to the present application, some steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the present application.

[0179] It should be noted that each embodiment in this specification is described in a progressive manner, and each embodiment focuses on the differences from other embodiments, and the same or similar parts between the embodiments can be referred to each other. For the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.

[0180] The steps in the methods of each embodiment of the present application can be adjusted in sequence, combined and deleted according to actual needs, and the technical features recorded in each embodiment can be replaced or combined.

[0181] The modules and sub-modules in the devices and terminals in the various embodiments of the present application can be combined, divided and deleted according to actual needs.

[0182] In the several embodiments provided in the present application, it should be understood that the disclosed terminals, devices and methods can be implemented in other ways. For example, the terminal embodiments described above are only schematic, for example, the division of modules or submodules is only a logical function division, and there may be other division methods in actual implementation, for example, multiple submodules or modules can be combined or integrated into another module, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or modules, which can be electrical, mechanical or other forms.

[0183] The modules or submodules described as separate components may or may not be physically separated, and the components of the modules or submodules may or may not be physical modules or submodules, that is, they may be located in one place, or they may be distributed on multiple network modules or submodules. Some or all of the modules or submodules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0184] In addition, each functional module or submodule in each embodiment of the present application may be integrated into one processing module, or each module or submodule may exist physically separately, or two or more modules or submodules may be integrated into one module. The above-mentioned integrated modules or submodules may be implemented in the form of hardware or in the form of software functional modules or submodules.

[0185] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in the above description according to function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.

[0186] The steps of the method or algorithm described in conjunction with the embodiments disclosed herein may be implemented directly by hardware, software units executed by a processor, or a combination of the two. The software units may be placed in a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.

[0187] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.

[0188] The above description of the disclosed embodiments enables those skilled in the art to implement or use the present application. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to the embodiments shown herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A data sampling method, characterized in that: include: Obtaining the number of instances corresponding to each to-be-sampled label in each data unit, wherein each of the data units is obtained by dividing the original data according to a preset sampling unit; Based on the number of instances corresponding to each to-be-sampled label in each data unit, each target data unit is sampled from each of the data units, wherein each of the target data units is used to train a target detection model.

2. The data sampling method according to claim 1, characterized in that: The step of sampling each target data unit from each data unit based on the number of instances corresponding to each to-be-sampled label in each data unit includes: Based on the number of instances corresponding to each to-be-sampled label in each data unit, the data units are sorted in descending order to obtain an ordered sequence of data units corresponding to each to-be-sampled label; Based on the ordered sequence of data units corresponding to each of the to-be-sampled tags, each target data unit is sampled from each of the data units.

3. The data sampling method according to claim 2, characterized in that: The step of sampling each target data unit from each data unit based on the ordered sequence of data units corresponding to each of the to-be-sampled tags includes: Based on the instance density threshold corresponding to the first label to be sampled, select each data unit in the ordered sequence of data units corresponding to the first label to be sampled in order of sorting to obtain a sampling data set corresponding to the first label to be sampled; Based on the instance density threshold corresponding to the i-th label to be sampled, select each data unit in the ordered sequence of data units corresponding to the i-th label to be sampled in order of sorting, add the sampled data set corresponding to the (i-1)-th label to be sampled, and remove duplicates to obtain the sampled data set corresponding to the i-th label to be sampled; Based on the instance density threshold corresponding to the Nth label to be sampled, select each data unit in the ordered sequence of data units corresponding to the Nth label to be sampled in order of sorting, add the sampled data set corresponding to the (N-1)th label to be sampled, and remove duplicates to obtain the sampled data set corresponding to the Nth label to be sampled; Based on the sampling data set corresponding to the Nth label to be sampled, sampling each target data unit from each data unit; Wherein, i is greater than 1 and i is less than N, i is an integer, and N is the total number of the labels to be sampled.

4. The data sampling method according to claim 3, characterized in that: The method of selecting each data unit in sequence according to the sorting order from the ordered sequence of data units corresponding to the first label to be sampled based on the instance density threshold corresponding to the first label to be sampled, to obtain a sampling data set corresponding to the first label to be sampled, includes: From the ordered sequence of data units corresponding to the first label to be sampled, select each data unit in order according to the sorting order, add the data set corresponding to the first label to be sampled, and determine the instance density corresponding to the first label to be sampled in the data set corresponding to the first label to be sampled; When the instance density corresponding to the first label to be sampled is greater than or equal to the instance density threshold corresponding to the first label to be sampled, continue to select each data unit in the ordered sequence of data units corresponding to the first label to be sampled in order of sorting, add the data set corresponding to the first label to be sampled, and determine the instance density corresponding to the first label to be sampled; When the instance density corresponding to the first label to be sampled is less than the instance density threshold corresponding to the first label to be sampled, stop adding the data unit to the sampling data set corresponding to the first label to be sampled, and obtain the final sampling data set corresponding to the first label to be sampled; The instance density corresponding to the first label to be sampled in the sampling data set corresponding to the first label to be sampled refers to the quotient obtained by dividing the total number of instances corresponding to the first label to be sampled in the sampling data set corresponding to the first label to be sampled by the total number of data units in the sampling data set corresponding to the first label to be sampled.

5. The data sampling method according to claim 3, characterized in that: The method of selecting each data unit in the ordered sequence of data units corresponding to the i-th label to be sampled based on the instance density threshold corresponding to the i-th label to be sampled in order of sorting, adding the sampled data set corresponding to the (i-1)-th label to be sampled and removing duplicates to obtain the sampled data set corresponding to the i-th label to be sampled includes: Determine the instance density corresponding to the i-th label to be sampled in the sampling data set corresponding to the (i-1)-th label to be sampled; When the instance density corresponding to the i-th label to be sampled is greater than or equal to the instance density threshold corresponding to the i-th label to be sampled, select each data unit in the ordered sequence of data units corresponding to the i-th label to be sampled in order of sorting, add the data set corresponding to the (i-1)-th label to be sampled and remove duplicates, and determine the instance density corresponding to the i-th label to be sampled in the data set corresponding to the (i-1)-th label to be sampled; When the instance density corresponding to the i-th label to be sampled is less than the instance density threshold corresponding to the i-th label to be sampled, stop adding the data unit to the sampling data set corresponding to the (i-1)-th label to be sampled, and obtain the final sampling data set corresponding to the i-th label to be sampled; The instance density corresponding to the i-th label to be sampled in the sampling data set corresponding to the (i-1)-th label to be sampled refers to the quotient obtained by dividing the total number of instances corresponding to the i-th label to be sampled in the sampling data set corresponding to the (i-1)-th label to be sampled by the total number of data units in the sampling data set corresponding to the (i-1)-th label to be sampled.

6. The data sampling method according to claim 3, characterized in that: The step of sampling each target data unit from each data unit based on the sampling data set corresponding to the Nth label to be sampled includes: Determine the actual value corresponding to each of the to-be-sampled labels based on the total number of instances corresponding to each of the to-be-sampled labels in the sampling data set corresponding to the Nth to-be-sampled label; Obtaining target values ​​corresponding to the labels to be sampled; Based on the actual value and the target value corresponding to each of the labels to be sampled, the instance density threshold corresponding to each of the labels to be sampled is updated, the sampling data set corresponding to the Nth label to be sampled is deleted, and the step of returning to execute the step of selecting each data unit in the ordered sequence of data units corresponding to the first label to be sampled in the sorted order based on the instance density threshold corresponding to the first label to be sampled; Until the preset condition is met, each data unit in the final sampling data set corresponding to the Nth label to be sampled is determined as each target data unit.

7. The data sampling method according to claim 6, characterized in that: The updating of the instance density threshold corresponding to each of the to-be-sampled labels based on the actual value and the target value corresponding to each of the to-be-sampled labels includes: Subtract the target value from the actual value corresponding to each of the to-be-sampled labels to obtain a difference value corresponding to each of the to-be-sampled labels; Multiplying the difference corresponding to each of the to-be-sampled labels by a preset learning rate to obtain a product corresponding to each of the to-be-sampled labels; The instance density thresholds corresponding to the labels to be sampled before updating are added to the products corresponding to the labels to be sampled, so as to obtain the instance density thresholds corresponding to the labels to be sampled after updating.

8. A data sampling device, characterized in that: include: An acquisition unit, used to acquire the number of instances corresponding to each to-be-sampled label in each data unit, wherein each of the data units is obtained by dividing the original data according to a preset sampling unit; The sampling unit is used to sample each target data unit from each data unit based on the number of instances corresponding to each to-be-sampled label in each data unit, wherein each target data unit is used to train a target detection model.

9. An electronic device, characterized in that: including memory and processor; The memory is connected to the processor and is used to store programs; The processor is used to implement the data sampling method according to any one of claims 1 to 7 by running the program in the memory.

10. A storage medium, characterized in that: The storage medium stores a computer program, and when the computer program is executed by the processor, the data sampling method according to any one of claims 1 to 7 is implemented.