Data set splitting method and data set splitting apparatus
By splitting the image dataset using a greedy strategy, the problem of imbalanced sample distribution caused by random splitting is solved, thereby improving the training and validation accuracy of machine learning models.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- THE FOURTH PARADIGM BEIJING TECH CO LTD
- Filing Date
- 2021-12-31
- Publication Date
- 2026-05-29
AI Technical Summary
In cases of imbalanced sample distribution, existing random dataset splitting methods can easily lead to inaccurate training or validation results for machine learning models, especially in image segmentation and object detection tasks, where the validation set data differs significantly from the overall distribution.
A greedy strategy is used to split the image dataset. First, image samples without objects are randomly assigned. Then, image samples with objects are evenly assigned according to the distribution of each object category, so that the object category distribution in each subset is close to the overall distribution.
This method ensures that the sample distribution in each subset is close to the overall distribution, thereby improving the accuracy of training or validating machine learning models.
Smart Images

Figure CN116434094B_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of computer technology, and more specifically, to a method and apparatus for splitting a dataset. Background Technology
[0002] In the field of Automated Machine Learning (AutoML), training or validating machine learning models requires splitting the dataset, and then using the split subsets to train or validate the model. A common dataset splitting method is random splitting, which is effective in most cases. However, when the sample distribution is imbalanced, such as in image segmentation and object detection tasks where some categories have a smaller proportion, randomly splitting the dataset at the sample granularity (image granularity) can easily lead to a large discrepancy between the validation set and the overall distribution, resulting in inaccurate training or validation of the machine learning model. Summary of the Invention
[0003] This disclosure proposes a dataset splitting method and a dataset splitting apparatus that can at least partially solve the above-mentioned problems.
[0004] According to one aspect of this disclosure, a dataset splitting method is provided, comprising: acquiring an image dataset; determining at least one object category in the image dataset; and splitting the image dataset into N sub-datasets based on the distribution of each object category in the at least one object category in the image dataset, wherein N is an integer greater than 1.
[0005] Optionally, splitting the image dataset into N sub-datasets based on the distribution of each object category among the at least one object category in the image dataset may include: randomly and evenly distributing image samples in the image dataset that do not include objects to the N sub-datasets; and distributing image samples in the image dataset that include objects to the N sub-datasets based on a first distribution ratio and a second distribution ratio for each object category of the image samples in the image dataset, wherein the first distribution ratio is the distribution ratio of each object category in the image dataset in the image dataset, and the second distribution ratio is the distribution ratio of each object category in each sub-dataset in that sub-dataset.
[0006] Optionally, the step of allocating image samples containing objects in the image dataset to the N sub-datasets based on the first and second distribution ratios of each object category in the image samples containing objects in the image dataset may include: allocating image samples containing objects in the image dataset to the N sub-datasets based on the difference between the second distribution ratio of each object category in each sub-dataset and the first distribution ratio of the corresponding object category, such that the difference between the second distribution ratio of each object category in each sub-dataset and the first distribution ratio of the corresponding object category is minimized.
[0007] Optionally, the step of allocating image samples containing objects in the image dataset to the N subsets based on the difference between the second distribution ratio of each object category in each subset and the first distribution ratio of the corresponding object category may include: calculating the first distribution ratio R of the image dataset. j , j is the object category number; randomly select N image samples containing objects from the image samples containing objects in the image dataset, and randomly and evenly distribute them into the N subsets; repeatedly perform the following first operation until all image samples containing objects in the image dataset have been distributed: calculate the second distribution ratio R of each subset. i,j And calculate the second distribution proportion R for each subset. i,j The first distribution ratio R of the corresponding object category j The difference r i,j Where i is the subset number, r i,j =R j -R i,j From the remaining image samples containing objects in the image dataset, randomly select N image samples; repeatedly perform the following second operation until the N image samples are assigned to the N sub-data: count the category set of all object categories in the image samples that have not yet been assigned in the N image samples; from the category set of each sub-data set in the sub-data set that has not yet been assigned to image samples in the current second operation, find the gap r. i,j The largest first category number and the largest first subset number; the image sample with the largest distribution of the object category corresponding to the first category number among the unassigned image samples is assigned to the subset corresponding to the first subset number.
[0008] Optionally, when the image dataset is a dataset for image semantic segmentation, the object is a foreground object, the first distribution ratio is the ratio of the total number of pixels of the foreground object of each foreground object category in the image dataset to the total number of pixels of all image samples in the image dataset, and the second distribution ratio is the ratio of the total number of pixels of the foreground object of each foreground object category in each sub-dataset to the total number of pixels of all image samples in that sub-dataset.
[0009] Optionally, when the image dataset is a dataset for image object detection, the object is a target object, the first distribution ratio is the proportion of the number of target objects of each target object category in the image dataset to the total number of target objects in the image dataset, and the second distribution ratio is the proportion of the number of target objects of each target category in each sub-dataset to the total number of target objects in that sub-dataset.
[0010] Optionally, the first distribution ratio is the proportion of the number of target objects of each target object category at each scale range in the image dataset to the total number of target objects in the image dataset, and the second distribution ratio is the proportion of the number of target objects of each target object category at each scale range in each sub-dataset to the total number of target objects in that sub-dataset.
[0011] According to another aspect of this disclosure, a dataset splitting apparatus is provided, characterized in that it includes: a dataset acquisition unit configured to acquire an image dataset; a determination unit configured to determine at least one object category in the image dataset; and a splitting unit configured to split the image dataset into N sub-datasets based on the distribution of each object category among the at least one object category in the image dataset, wherein N is an integer greater than 1.
[0012] Optionally, the splitting unit can be configured to: randomly and evenly distribute image samples in the image dataset that do not include objects to the N sub-datasets; and distribute image samples in the image dataset that include objects to the N sub-datasets based on a first distribution ratio and a second distribution ratio for each object category in the image samples in the image dataset, wherein the first distribution ratio is the distribution ratio of each object category in the image dataset in the image dataset, and the second distribution ratio is the distribution ratio of each object category in each sub-dataset in that sub-dataset.
[0013] Optionally, the splitting unit can be configured to: based on the difference between the second distribution ratio of each object category in each subset and the first distribution ratio of the corresponding object category, distribute image samples including objects in the image dataset to the N subsets, such that the difference between the second distribution ratio of each object category in each subset and the first distribution ratio of the corresponding object category is minimized.
[0014] Optionally, the splitting unit can be configured to: statistically analyze a first distribution ratio R of the image dataset. j , j is the object category number; randomly select N image samples containing objects from the image samples containing objects in the image dataset, and randomly and evenly distribute them into the N subsets; repeatedly perform the following first operation until all image samples containing objects in the image dataset have been distributed: calculate the second distribution ratio R of each subset. i,j And calculate the second distribution proportion R for each subset. i,j The first distribution ratio R of the corresponding object category j The difference r i,j Where i is the subset number, r i,j =R j -R i,j From the remaining image samples containing objects in the image dataset, randomly select N image samples; repeatedly perform the following second operation until the N image samples are assigned to the N sub-data: count the category set of all object categories in the image samples that have not yet been assigned in the N image samples; from the category set of each sub-data set in the sub-data set that has not yet been assigned to image samples in the current second operation, find the gap r. i,j The largest first category number and the largest first subset number; the image sample with the largest distribution of the object category corresponding to the first category number among the unassigned image samples is assigned to the subset corresponding to the first subset number.
[0015] Optionally, when the image dataset is a dataset for image semantic segmentation, the object is a foreground object, the first distribution ratio is the ratio of the total number of pixels of the foreground object of each foreground object category in the image dataset to the total number of pixels of all image samples in the image dataset, and the second distribution ratio is the ratio of the total number of pixels of the foreground object of each foreground object category in each sub-dataset to the total number of pixels of all image samples in that sub-dataset.
[0016] Optionally, when the image dataset is a dataset for image object detection, the object is a target object, the first distribution ratio is the proportion of the number of target objects of each target object category in the image dataset to the total number of target objects in the image dataset, and the second distribution ratio is the proportion of the number of target objects of each target category in each sub-dataset to the total number of target objects in that sub-dataset.
[0017] Optionally, the first distribution ratio is the proportion of the number of target objects of each target object category at each scale range in the image dataset to the total number of target objects in the image dataset, and the second distribution ratio is the proportion of the number of target objects of each target object category at each scale range in each sub-dataset to the total number of target objects in that sub-dataset.
[0018] According to another aspect of this disclosure, a computer-readable storage medium for storing instructions is provided, wherein when the instructions are executed by at least one computing device, the at least one computing device causes the at least one computing device to perform a dataset splitting method according to this disclosure.
[0019] According to another aspect of this disclosure, a system is provided that includes at least one computing device and at least one storage device for storing instructions, wherein the instructions, when executed by the at least one computing device, cause the at least one computing device to perform a dataset splitting method according to this disclosure.
[0020] According to the dataset splitting method and apparatus disclosed herein, image datasets, for example, used for image semantic segmentation or image object detection tasks, can be effectively split based on the distribution of object categories in the image dataset. This ensures that the sample distribution of each category in each split dataset is basically close to the overall sample distribution, thereby improving the accuracy of training or validation of machine learning models. Attached Figure Description
[0021] These and / or other aspects and advantages of this disclosure will become clearer and more readily understood from the following description of the embodiments, taken in conjunction with the accompanying drawings, wherein:
[0022] Figure 1 This is a flowchart illustrating a dataset splitting method according to an exemplary embodiment of the present disclosure.
[0023] Figure 2 This is a flowchart illustrating the allocation of image samples including objects according to an exemplary embodiment of the present disclosure.
[0024] Figure 3 This is a flowchart illustrating an algorithm for splitting an image dataset for image semantic segmentation according to an exemplary embodiment of the present disclosure.
[0025] Figure 4 This is a block diagram illustrating a dataset splitting apparatus according to an exemplary embodiment of the present disclosure. Detailed Implementation
[0026] The following description, provided with reference to the accompanying drawings, is intended to aid in a full understanding of embodiments of the present disclosure as defined by the claims and their equivalents. Various specific details are included to aid understanding, but these details are to be considered exemplary only. Therefore, those skilled in the art will recognize that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present disclosure. Furthermore, for clarity and brevity, descriptions of well-known functions and structures are omitted.
[0027] It should be noted that the phrase "at least one of several items" in this disclosure refers to three parallel cases: "any one of the several items", "a combination of any number of the several items", and "all of the several items". For example, "including at least one of A and B" includes the following three parallel cases: (1) including A; (2) including B; (3) including A and B. As another example, "performing at least one of step one and step two" indicates the following three parallel cases: (1) performing step one; (2) performing step two; (3) performing both step one and step two.
[0028] Dataset splitting can be applied to hyperparameter search scenarios. Specifically, during hyperparameter search, the dataset needs to be split into multi-fold training and validation sets. Each hyperparameter search attempt trains the model (i.e., a machine learning model, such as an AutoML product, hereinafter referred to as the model) on the training set of each fold, and tests the model's performance on the validation set. The average performance on the multi-fold validation set is used as the performance metric for this hyperparameter search. A common method for multi-fold dataset splitting is random splitting, for example, randomly dividing the dataset into 10 equal parts, each containing the same number of samples, denoted as d1, d2, ..., d... 10 ,(d2∪d3∪…∪d 10 d1) is the first fold's split between the validation and training sets (the first part represents the training set, and the second part represents the validation set), (d1∪d3∪d4∪…∪d 10 d2) constitutes the second split, and so on. Random splitting is effective in most cases, but when the sample distribution is unbalanced, such as in image segmentation and image object detection tasks, where some categories have a smaller proportion, if the split is randomly averaged at the sample granularity (image granularity), it is easy to cause a large difference between the data distribution of the validation set and the overall distribution, resulting in inaccurate search results for hyperparameter search due to the large difference in the distribution of the validation set.
[0029] To address the aforementioned technical problems, this disclosure proposes a dataset splitting method using a greedy strategy. For image datasets used in tasks such as image semantic segmentation or image object detection (typically containing a large number of objects of different types), this method performs effective data splitting, ensuring that the sample distribution of each category in each split dataset is approximately close to the overall sample distribution. This prevents the hyperparameter search results from being affected by the dataset splitting. The general idea is to first randomly distribute image samples without objects into multiple subsets. Then, image samples containing objects are evenly distributed into multiple subsets based on the distribution of each object category. More specifically, the distribution can be based on the difference between the distribution of each object category in each subset and its distribution in the entire dataset, ensuring that the sample distribution of each object category in each split subset is approximately close to the overall sample distribution. Of course, this dataset splitting method is not only applicable to hyperparameter search scenarios but also to any scenario requiring the splitting of the full dataset into multiple subsets, ensuring that the data distribution of the subsets approximates the distribution of the full dataset. The following will refer to... Figures 1 to 4 The present disclosure provides a detailed description of the dataset splitting method and apparatus thereof.
[0030] Figure 1 This is a flowchart illustrating a dataset splitting method according to an exemplary embodiment of the present disclosure.
[0031] Reference Figure 1 In step 101, an image dataset can be obtained, wherein the image dataset includes multiple image samples. Here, the image dataset can be a training dataset used for model training. For example, but not limited to, the image dataset can be a dataset used to train a model for image semantic segmentation, or the image dataset can be a dataset used to train a model for image object detection.
[0032] In step 102, at least one object category in the image dataset can be determined. For example, in an image semantic segmentation algorithm, the object can be a foreground object; therefore, the foreground object categories included in the image samples in the image dataset can be determined. For example, the foreground object categories can be set to include people, vehicles, animals, buildings, etc. As another example, in an image object detection algorithm, the object can be a target object to be detected; therefore, the target object categories included in the image samples in the image dataset can be determined. For example, the target object categories can be set to include cats, dogs, people, etc.
[0033] In step 103, the image dataset can be split into N subsets based on the distribution of each object category in at least one object category in the image dataset, where N is an integer greater than 1.
[0034] According to an exemplary embodiment of the present disclosure, image samples in an image dataset that do not include objects can be randomly and evenly distributed into N sub-datasets. Based on a first distribution ratio and a second distribution ratio of each object category in the image samples in the image dataset that include objects, the image samples in the image dataset that include objects are distributed into N sub-datasets. The first distribution ratio is the distribution ratio of each object category in the image dataset in the image dataset, and the second distribution ratio is the distribution ratio of each object category in each sub-dataset in that sub-dataset.
[0035] According to an exemplary embodiment of this disclosure, image samples including objects in an image dataset can be allocated to N subsets based on the difference between the second distribution ratio of each object category in each subset and the first distribution ratio of the corresponding object category, thereby minimizing the difference between the second distribution ratio of each object category in each subset and the first distribution ratio of the corresponding object category. In other words, through the above allocation method, the sample distribution of each object category in each split subset is substantially close to the overall sample distribution. The following will refer to... Figure 2 The algorithm for allocating image samples containing objects is described in detail.
[0036] Figure 2 This is a flowchart illustrating the allocation of image samples including objects according to an exemplary embodiment of the present disclosure.
[0037] Reference Figure 2 In step 201, the first distribution ratio R of the image dataset can be statistically analyzed. j j is the object category number. For example, if the number of object categories is m, then j = 1, 2, ..., m.
[0038] In step 202, N image samples containing objects can be randomly selected from the image samples containing objects in the image dataset, and then randomly and evenly distributed among N subsets. That is, each subset can be randomly assigned to one image sample from the N randomly selected image samples.
[0039] In step 203, the second distribution proportion R of each subset can be calculated. i,j And calculate the second distribution proportion R for each subset. i,j The first distribution ratio R of the corresponding object category j The difference r i,j r i,j =R j -R i,j , where i is the subset number, therefore i = 1, 2, ..., N.
[0040] In step 204, N image samples are randomly selected from the remaining image samples containing objects in the image dataset.
[0041] In step 205, the set of categories C of all object categories is counted among the N randomly selected image samples that have not yet been assigned.
[0042] In step 206, find the gap r from the category set C of each of the N subsets that have not yet been assigned to image samples. i,j The largest first category number c and the largest subset number s. For example, if the category set C includes categories 1, 2, 4, 6, m, and there are currently 1, 2, ..., n subsets of data that have not yet been assigned to image samples, then we can look up {r}. i,j The first category number c and the first subset number s corresponding to the maximum value of}(i∈{1,2,…,n},j∈C=1,2,4,6,m) are, i.e.,
[0043] In step 207, the image sample with the largest distribution of the object category corresponding to the first category code c among the unassigned image samples can be assigned to the subset corresponding to the first subset number s. For example, the unassigned image samples include a first image sample and a second image sample. Both the first and second image samples include the object category corresponding to category code c, and the distribution of the object category corresponding to category code c in the first image sample is larger than that in the second image sample. In this case, the first image sample can be assigned to the subset corresponding to the first subset number s. For example, in the case of image samples used for image semantic segmentation, the largest distribution may refer to the largest total number of pixels of that object category. As another example, in the case of image samples used for image object detection, the largest distribution may refer to the largest number of objects of that object category.
[0044] For the N image samples randomly selected in step 204, steps 205 to 206 can be repeated until the N image samples randomly selected in step 204 have been allocated. That is, each of the N subsets can be allocated to one of the N image samples according to steps 205 to 207. Of course, if only one image sample remains unallocated, corresponding to only one subset of the dataset, steps 205 to 207 can be skipped, and the image sample can be directly allocated to that subset.
[0045] For the remaining image samples containing objects in the image dataset, steps 203 to 207 can be repeated until all image samples containing objects in the image dataset have been allocated.
[0046] According to an exemplary embodiment of this disclosure, when the image dataset is a dataset for image semantic segmentation, and the object is a foreground object, the first distribution ratio may be the ratio of the total number of pixels of the foreground object of each foreground object category in the image dataset to the total number of pixels of all image samples in the image dataset, and the second distribution ratio may be the ratio of the total number of pixels of the foreground object of each foreground object category in each subset of the dataset to the total number of pixels of all image samples in that subset of the dataset. In this case, an image sample excluding the object may represent an image sample containing only the background and excluding the foreground object.
[0047] According to an exemplary embodiment of this disclosure, when the image dataset is a dataset for image object detection, the object is a target object. A first distribution ratio can be the proportion of the number of target objects of each target object category in the image dataset to the total number of target objects in the image dataset. A second distribution ratio can be the proportion of the number of target objects of each target object category in each sub-dataset to the total number of target objects in that sub-dataset. In this case, image samples excluding objects can represent image samples excluding target objects. Furthermore, in this case, the granular statistical proportion and segmentation operation can be performed more finely, using different scale ranges for each target object category. For example, the first distribution ratio can be the proportion of the number of target objects of each target object category at each scale range in the image dataset to the total number of target objects in the image dataset, and the second distribution ratio can be the proportion of the number of target objects of each target object category at each scale range in each sub-dataset to the total number of target objects in that sub-dataset.
[0048] The following section will use an image semantic segmentation algorithm as an example to describe the algorithmic process of splitting an image dataset. Figure 3 This is a flowchart illustrating an algorithm for splitting an image dataset for image semantic segmentation according to an exemplary embodiment of the present disclosure. The algorithm input is an image semantic segmentation dataset D containing *a* image samples. The algorithm output is N subsets {d1, d2, d3, ..., dn}. N}, each subset d i It contains D / N image samples, and the intersection of any two distinct subsets is empty, i.e. The union of all subsets is the entire dataset D, i.e., d1∪d2∪…∪d N =D.
[0049] Reference Figure 3 In step 301, N subsets of the dataset can be initialized. That is, the N subsets can be set to an empty set.
[0050] In step 302, the proportion of the total number of pixels for each foreground object category in the image dataset to the total number of pixels in the entire dataset can be calculated, i.e., the first distribution proportion, denoted as R1, R2, ..., R m , where m represents the number of categories of foreground objects.
[0051] In step 303, the subset S of the pure background image sample set is... b The data is randomly and evenly divided into N subsets.
[0052] In step 304, from the remaining subset of image samples containing foreground objects In this process, N image samples are randomly selected, and then these N image samples are randomly and evenly distributed into N subsets, that is, each subset is randomly assigned to one of the N image samples.
[0053] In step 305, the proportion R of the total number of pixels for each foreground object category in each subset of the dataset to the total number of pixels in all images of that subset is calculated. i,j (i is the subset number, j is the foreground object category number), and calculate R for each subset. i,j The proportion R of the corresponding category j in the image dataset j The difference r i,j That is, r i,j =R j -R i,j .
[0054] In step 306, from subset S r N image samples are randomly selected from the sample.
[0055] In step 307, the set of categories C of all foreground object categories of the image samples that have not yet been assigned among the N image samples is counted.
[0056] In step 308, find the gap r from the category set of each of the N subsets that have not yet been assigned to image samples. i,j The category number c and the subset number s corresponding to the maximum value.
[0057] In step 309, the image sample ε with the largest total number of pixels belonging to category c can be found from the N unassigned image samples, and image sample ε is assigned to the subset s. That is, d s =d s ∪{ε}.
[0058] For subset S r For N randomly selected image samples, repeat steps 307 to 309 until a subset S is obtained. rN image samples randomly selected from the dataset are assigned to N subsets.
[0059] Additionally, it is possible to target subset S r For the remaining image samples, repeat steps 305 to 309 until subset S is reached. r The image samples in the dataset have been allocated, that is,
[0060] According to an exemplary embodiment of this disclosure, the dataset splitting method of this disclosure is applied to a 4-class semantic segmentation dataset, splitting the dataset into 10 subsets. The proportion of pixels in each class in each subset is approximately the same as the proportion of pixels in each class in the overall dataset. Tables 1 and 2 below show the distribution obtained by randomly performing the dataset splitting method of this disclosure twice, where class_1, class_2, class_3, and class_4 represent the four foreground classes, total represents the pixel distribution of each class in the overall dataset, and split_0,…,split_9 represents the pixel distribution of each class in the 10 subsets.
[0061] Table 1
[0062]
[0063] Table 2
[0064]
[0065] Figure 3 The algorithmic flow for splitting an image dataset for image semantic segmentation is shown, but the same algorithmic flow can also be applied to an image dataset for image object detection. The difference is that, when applied to an image dataset for image object detection, the proportion R counted in step 302 will be... j Replace the image samples with the proportion of the number of target objects in each target object category in the image dataset to the total number of target objects in the image dataset. Replace the pure background image samples in step 303 with image samples that do not contain target objects, and change the proportion R calculated in step 305. i,j Replace the proportion of target objects of each target category in each subset of the dataset with the proportion of all target objects in that subset, and replace the image sample ε with the largest total number of pixels including category c found in step 309 with the image sample ε with the largest number of target objects including category c. Furthermore, more finely, the proportion and segmentation operation can be performed at a granular level based on different scale ranges for each target category. Therefore, the proportion R calculated in step 302 can be... jReplace the image samples with the proportion of the number of target objects in each scale range of each target object category in the image dataset to the total number of target objects in the image dataset. Replace the pure background image samples in step 303 with image samples that do not contain target objects, and change the proportion R counted in step 305. i,j Replace the proportion of the number of target objects in each scale range of each target category in each subset of the dataset to the total number of target objects in that subset, and replace the image sample ε with the largest total number of pixels including category c found in step 309 with the image sample ε with the largest number of target objects including category c.
[0066] Figure 4 This is a block diagram illustrating a dataset splitting apparatus according to an exemplary embodiment of the present disclosure. Figure 4 The dataset splitting device shown can be applied to any scenario that requires splitting the full dataset into multiple sub-datasets, so that the data distribution of the sub-datasets can be close to the distribution of the full dataset.
[0067] Reference Figure 4 The dataset splitting apparatus 600 according to an exemplary embodiment of the present disclosure may include a dataset acquisition unit 401, a determination unit 402, and a splitting unit 403.
[0068] The dataset acquisition unit 401 can acquire an image dataset, which includes multiple image samples. Here, the image dataset can be a training dataset used for model training. For example, but not limited to, the image dataset can be a dataset used to train a model for image semantic segmentation, or it can be a dataset used to train a model for image object detection.
[0069] The determining unit 402 can determine at least one object category in the image dataset. For example, in an image semantic segmentation algorithm, the object can be a foreground object; therefore, the determining unit 402 can determine the foreground object categories included in the image samples in the image dataset. For example, the foreground object categories can be set to include people, vehicles, animals, buildings, etc. As another example, in an image object detection algorithm, the object can be a target object to be detected; therefore, the determining unit 402 can determine the target object categories included in the image samples in the image dataset. For example, the target object categories can be set to include cats, dogs, people, etc.
[0070] The splitting unit 403 can split the image dataset into N subsets based on the distribution of each object category in at least one object category in the image dataset, where N is an integer greater than 1.
[0071] According to an exemplary embodiment of the present disclosure, the splitting unit 403 can randomly and evenly distribute image samples in the image dataset that do not include objects into N sub-datasets, and distribute image samples in the image dataset that include objects into N sub-datasets based on a first distribution ratio and a second distribution ratio of each object category in the image samples in the image dataset, wherein the first distribution ratio is the distribution ratio of each object category in the image dataset in the image dataset, and the second distribution ratio is the distribution ratio of each object category in each sub-dataset in the sub-dataset.
[0072] According to an exemplary embodiment of this disclosure, the splitting unit 403 can allocate image samples including objects in the image dataset to the N subsets based on the difference between the second distribution ratio of each object category in each subset and the first distribution ratio of the corresponding object category, thereby minimizing the difference between the second distribution ratio of each object category in each subset and the first distribution ratio of the corresponding object category. In other words, through the above allocation method, the sample distribution of each object category in each split subset is substantially close to the overall sample distribution.
[0073] According to an exemplary embodiment of this disclosure, the splitting unit 403 can be configured as follows: Figure 2 The process shown is used to allocate image samples, including objects.
[0074] In step 201, the splitting unit 403 can statistically analyze the first distribution ratio R of the image dataset. j j is the object category number. For example, if the number of object categories is m, then j = 1, 2, ..., m.
[0075] In step 202, the splitting unit 403 may randomly select N image samples containing objects from the image samples containing objects in the image dataset, and randomly and evenly distribute them into N subsets. That is, each subset may be randomly assigned to one image sample from the N randomly selected image samples.
[0076] In step 203, the splitting unit 403 can calculate the second distribution ratio R of each subset of data. i,j And calculate the second distribution proportion R for each subset. i,j The first distribution ratio R of the corresponding object category j The difference r i,j r i,j =R j -R i,j , where i is the subset number, therefore i = 1, 2, ..., N.
[0077] In step 204, the splitting unit 403 randomly selects N image samples from the remaining image samples containing objects in the image dataset.
[0078] In step 205, the splitting unit 403 counts the number of image samples that have not yet been assigned among the N randomly selected image samples, including the category set C of all object categories;
[0079] In step 206, splitting unit 403 searches for gaps r from the category set C of each of the N subsets that have not yet been assigned to image samples. i,j The largest first category number c and the largest subset number s. For example, if the category set C includes categories 1, 2, 4, 6, m, and there are currently 1, 2, ..., n subsets of data that have not yet been assigned to image samples, then we can look up {r}. i,j The first category number c and the first subset number s corresponding to the maximum value of}(i∈{1,2,…,n},j∈C={1,2,4,6,m}) are, i.e.,
[0080] In step 207, the splitting unit 403 can allocate the image sample with the largest distribution of the object category corresponding to the first category number c among the unallocated image samples to the subset corresponding to the first subset number s. For example, the unallocated image samples include a first image sample and a second image sample. Both the first and second image samples include the object category corresponding to category code c, and the distribution of the object category corresponding to category code c in the first image sample is larger than the distribution of the object category corresponding to category code c in the second image sample. In this case, the splitting unit 403 can allocate the first image sample to the subset corresponding to the first subset number s. For example, in the case of image samples used for image semantic segmentation, the largest distribution may refer to the largest total number of pixels of that object category. As another example, in the case of image samples used for image object detection, the largest distribution may refer to the largest number of objects of that object category.
[0081] For the N image samples randomly selected in step 204, the splitting unit 403 may repeat steps 205 to 206 until the N image samples randomly selected in step 204 have been allocated. That is, the splitting unit 403 may allocate each of the N subsets to one of the N image samples according to steps 205 to 207. Of course, if only one image sample remains unallocated, corresponding to only one subset of the dataset not yet allocated to an image sample, the splitting unit 603 may skip steps 205 to 207 and directly allocate the image sample to that subset.
[0082] For the remaining image samples containing objects in the image dataset, the splitting unit 403 may repeat steps 203 to 207 until all image samples containing objects in the image dataset have been allocated.
[0083] According to an exemplary embodiment of this disclosure, when the image dataset is a dataset for image semantic segmentation, and the object is a foreground object, the first distribution ratio may be the ratio of the total number of pixels of the foreground object of each foreground object category in the image dataset to the total number of pixels of all image samples in the image dataset, and the second distribution ratio may be the ratio of the total number of pixels of the foreground object of each foreground object category in each subset of the dataset to the total number of pixels of all image samples in that subset of the dataset. In this case, an image sample excluding the object may represent an image sample containing only the background and excluding the foreground object.
[0084] According to an exemplary embodiment of this disclosure, when the image dataset is a dataset for image object detection, the object is a target object. A first distribution ratio can be the proportion of the number of target objects of each target object category in the image dataset to the total number of target objects in the image dataset. A second distribution ratio can be the proportion of the number of target objects of each target object category in each sub-dataset to the total number of target objects in that sub-dataset. In this case, image samples excluding objects can represent image samples excluding target objects. Furthermore, in this case, the granular statistical proportion and segmentation operation can be performed more finely, using different scale ranges for each target object category. For example, the first distribution ratio can be the proportion of the number of target objects of each target object category at each scale range in the image dataset to the total number of target objects in the image dataset, and the second distribution ratio can be the proportion of the number of target objects of each target object category at each scale range in each sub-dataset to the total number of target objects in that sub-dataset.
[0085] The above has been referred to Figures 1 to 4 A dataset splitting method and apparatus according to exemplary embodiments of the present disclosure are described.
[0086] Figure 4 The individual units in the illustrated data splitting device can be configured as software, hardware, firmware, or any combination thereof to perform specific functions. For example, each device may correspond to a dedicated integrated circuit, pure software code, or a module combining software and hardware. Furthermore, one or more functions implemented by each device may also be uniformly executed by components in a physical entity device (e.g., a processor, client, or server).
[0087] In addition, refer to Figures 1 to 3The described dataset splitting method can be implemented by a program (or instructions) recorded on a computer-readable storage medium. For example, according to an exemplary embodiment of the present disclosure, a computer-readable storage medium storing instructions may be provided, wherein when the instructions are executed by at least one computing device, the at least one computing device causes the at least one computing device to perform the dataset splitting method according to the present disclosure.
[0088] The computer program in the aforementioned computer-readable storage medium can run in an environment deployed in computer devices such as clients, hosts, agent devices, and servers. It should be noted that the computer program can also be used to perform additional steps beyond those described above, or to perform more specific processing while performing the above steps. The details of these additional steps and further processing are already described in the reference... Figures 1 to 3 The relevant methods were mentioned in the description of the process, so they will not be repeated here to avoid repetition.
[0089] It should be noted that each unit in the dataset splitting apparatus according to the exemplary embodiments of this disclosure can rely entirely on the operation of a computer program to realize its corresponding function. That is, the functional architecture of the computer program in each unit corresponds to each step, so that the entire system is called through a special software package (e.g., a lib library) to realize the corresponding function.
[0090] on the other hand, Figure 4 The various units within can also be implemented using hardware, software, firmware, middleware, microcode, or any combination thereof. When implemented in software, firmware, middleware, or microcode, the program code or code segment used to perform the corresponding operation can be stored in a computer-readable medium such as a storage medium, enabling the processor to perform the corresponding operation by reading and running the corresponding program code or code segment.
[0091] For example, an exemplary embodiment of the present disclosure can also be implemented as a computing device including a storage component and a processor, wherein the storage component stores a set of computer-executable instructions, and when the set of computer-executable instructions is executed by the processor, a dataset splitting method according to an exemplary embodiment of the present disclosure is executed.
[0092] Specifically, the computing device can be deployed on a server or client, or on node devices in a distributed network environment. Furthermore, the computing device can be a PC, tablet, personal digital assistant, smartphone, web application, or other device capable of executing the aforementioned set of instructions.
[0093] Here, the computing device is not necessarily a single computing device, but can be any collection of devices or circuits capable of executing the aforementioned instructions (or instruction sets) individually or in combination. The computing device can also be part of an integrated control system or system manager, or can be configured to interconnect with a portable electronic device locally or remotely (e.g., via wireless transmission) through an interface.
[0094] In a computing device, a processor may include a central processing unit (CPU), a graphics processing unit (GPU), a programmable logic device, a dedicated processor system, a microcontroller, or a microprocessor. By way of example and not limitation, a processor may also include an analog processor, a digital processor, a microprocessor, a multi-core processor, a processor array, a network processor, etc.
[0095] Some operations described in the dataset splitting method according to exemplary embodiments of this disclosure can be implemented in software, some operations can be implemented in hardware, and some operations can be implemented in a combination of software and hardware.
[0096] The processor can execute instructions or code stored in one of the storage components, which can also store data. Instructions and data can also be sent and received over a network via a network interface device, which can employ any known transport protocol.
[0097] Storage components can be integrated with the processor, for example, by placing RAM or flash memory within an integrated circuit microprocessor. Alternatively, storage components can include separate devices, such as external disk drives, storage arrays, or other storage devices that can be used by any database system. Storage components and the processor can be operatively coupled, or can communicate with each other, for example, via I / O ports, network connections, etc., enabling the processor to read files stored in the storage component.
[0098] In addition, the computing device may include a video display (such as a liquid crystal display) and a user interaction interface (such as a keyboard, mouse, touch input device, etc.). All components of the computing device may be interconnected via a bus and / or network.
[0099] The dataset splitting method according to exemplary embodiments of this disclosure can be described as various interconnected or coupled functional blocks or functional diagrams. However, these functional blocks or functional diagrams can be equally integrated into a single logical device or operated according to non-precise boundaries.
[0100] Therefore, refer to Figures 1 to 3 The described dataset splitting method can be implemented by a system comprising at least one computing device and at least one storage device containing storage instructions.
[0101] According to an exemplary embodiment of the present disclosure, at least one computing device is a computing device for executing a dataset splitting method according to an exemplary embodiment of the present disclosure, and a storage device stores a set of computer-executable instructions. When the set of computer-executable instructions is executed by at least one computing device, the dataset splitting method according to the present disclosure is executed.
[0102] The foregoing has described various exemplary embodiments of this disclosure. It should be understood that the foregoing description is exemplary only and not exhaustive, and this disclosure is not limited to the disclosed exemplary embodiments. Many modifications and variations will be apparent to those skilled in the art without departing from the scope and spirit of this disclosure. Therefore, the scope of protection of this disclosure should be determined by the scope of the claims.
Claims
1. A dataset splitting method, characterized in that, include: Obtain the image dataset; Determine at least one object category in the image dataset; Based on the distribution of each object category in at least one object category in the image dataset, the image dataset is split into N sub-datasets, where N is an integer greater than 1; Specifically, the step of splitting the image dataset into N sub-datasets based on the distribution of each object category in at least one object category in the image dataset includes: The image samples in the image dataset that do not include objects are randomly and evenly distributed among the N sub-datasets; Based on the first and second distribution ratios of each object category in the image samples containing objects in the image dataset, the image samples containing objects in the image dataset are distributed into the N sub-datasets, wherein the first distribution ratio is the distribution ratio of each object category in the image dataset in the image dataset, and the second distribution ratio is the distribution ratio of each object category in each sub-dataset in the sub-dataset.
2. The dataset splitting method as described in claim 1, characterized in that, The process of allocating image samples containing objects in the image dataset to the N sub-datasets based on the first and second distribution ratios of each object category in the image samples containing objects in the image dataset includes: Based on the difference between the second distribution ratio of each object category in each subset and the first distribution ratio of the corresponding object category, the image samples including objects in the image dataset are distributed to the N subsets, so that the difference between the second distribution ratio of each object category in each subset and the first distribution ratio of the corresponding object category is minimized.
3. The dataset splitting method as described in claim 2, characterized in that, The method of allocating image samples containing objects in the image dataset to the N subsets based on the difference between the second distribution ratio of each object category in each subset and the first distribution ratio of the corresponding object category includes: Statistical analysis of the first distribution ratio of the image dataset , It is the object category number; From the image dataset containing objects, N image samples containing objects are randomly selected and randomly and evenly distributed among the N subsets. The following first operation is performed repeatedly until all image samples containing objects in the image dataset have been allocated: Calculate the proportion of the second distribution for each subset of data. And calculate the second distribution proportion for each subset. The first distribution ratio of the corresponding object category The gap ,in, It is the subset number. ; From the remaining image samples containing objects in the image dataset, N image samples are randomly selected; The second operation is performed repeatedly until the N image samples are assigned to the N sub-data: The set of all object categories is included in the N image samples that have not yet been assigned. The gap is found from the category set of each of the N sub-data sets that have not yet been assigned to image samples in the current second operation. The largest first category number and the largest subset number; The image sample with the largest distribution of the object category corresponding to the first category number among the unassigned image samples is assigned to the subset corresponding to the first subset number.
4. The dataset splitting method according to any one of claims 1 to 3, characterized in that, In the case where the image dataset is a dataset for image semantic segmentation, the object is a foreground object. The first distribution ratio is the ratio of the total number of pixels of the foreground object of each foreground object category in the image dataset to the total number of pixels of all image samples in the image dataset. The second distribution ratio is the ratio of the total number of pixels of the foreground object of each foreground object category in each sub-dataset to the total number of pixels of all image samples in that sub-dataset.
5. The dataset splitting method according to any one of claims 1 to 3, characterized in that, In the case where the image dataset is a dataset for image object detection, the object is a target object, the first distribution ratio is the proportion of the number of target objects of each target object category in the image dataset to the total number of target objects in the image dataset, and the second distribution ratio is the proportion of the number of target objects of each target category in each sub-dataset to the total number of target objects in that sub-dataset.
6. The dataset splitting method as described in claim 5, characterized in that, The first distribution ratio is the proportion of the number of target objects of each target object category at each scale range in the image dataset to the total number of target objects in the image dataset. The second distribution ratio is the proportion of the number of target objects of each target object category at each scale range in each sub-dataset to the total number of target objects in that sub-dataset.
7. A dataset splitting device, characterized in that, include: The dataset acquisition unit is configured to acquire an image dataset; The determining unit is configured to determine at least one object category in the image dataset; The splitting unit is configured to split the image dataset into N subsets based on the distribution of each object category among the at least one object category in the image dataset, where N is an integer greater than 1; The splitting unit is configured as follows: The image samples in the image dataset that do not include objects are randomly and evenly distributed among the N sub-datasets; Based on the first and second distribution ratios of each object category in the image samples containing objects in the image dataset, the image samples containing objects in the image dataset are distributed into the N sub-datasets, wherein the first distribution ratio is the distribution ratio of each object category in the image dataset in the image dataset, and the second distribution ratio is the distribution ratio of each object category in each sub-dataset in the sub-dataset.
8. The dataset splitting apparatus as described in claim 7, characterized in that, The split unit is configured as follows: Based on the difference between the second distribution ratio of each object category in each subset and the first distribution ratio of the corresponding object category, the image samples including objects in the image dataset are distributed to the N subsets, so that the difference between the second distribution ratio of each object category in each subset and the first distribution ratio of the corresponding object category is minimized.
9. The dataset splitting apparatus as described in claim 8, characterized in that, The split unit is configured as follows: Statistical analysis of the first distribution ratio of the image dataset , It is the object category number; From the image dataset containing objects, N image samples containing objects are randomly selected and randomly and evenly distributed among the N subsets. The following first operation is performed repeatedly until all image samples containing objects in the image dataset have been allocated: Calculate the proportion of the second distribution for each subset of data. And calculate the second distribution proportion for each subset. The first distribution ratio of the corresponding object category The gap ,in, It is the subset number. ; From the remaining image samples containing objects in the image dataset, N image samples are randomly selected; The second operation is performed repeatedly until the N image samples are assigned to the N sub-data: The set of all object categories is included in the N image samples that have not yet been assigned. The gap is found from the category set of each of the N sub-data sets that have not yet been assigned to image samples in the current second operation. The largest first category number and the largest subset number; The image sample with the largest distribution of the object category corresponding to the first category number among the unassigned image samples is assigned to the subset corresponding to the first subset number.
10. The dataset splitting apparatus according to any one of claims 7 to 9, characterized in that, In the case where the image dataset is a dataset for image semantic segmentation, the object is a foreground object. The first distribution ratio is the ratio of the total number of pixels of the foreground object of each foreground object category in the image dataset to the total number of pixels of all image samples in the image dataset. The second distribution ratio is the ratio of the total number of pixels of the foreground object of each foreground object category in each sub-dataset to the total number of pixels of all image samples in that sub-dataset.
11. The dataset splitting apparatus according to any one of claims 7 to 9, characterized in that, In the case where the image dataset is a dataset for image object detection, the object is a target object, the first distribution ratio is the proportion of the number of target objects of each target object category in the image dataset to the total number of target objects in the image dataset, and the second distribution ratio is the proportion of the number of target objects of each target category in each sub-dataset to the total number of target objects in that sub-dataset.
12. The dataset splitting apparatus as described in claim 11, characterized in that, The first distribution ratio is the proportion of the number of target objects of each target object category at each scale range in the image dataset to the total number of target objects in the image dataset. The second distribution ratio is the proportion of the number of target objects of each target object category at each scale range in each sub-dataset to the total number of target objects in that sub-dataset.
13. A computer-readable storage medium for storing instructions, wherein, When the instruction is executed by at least one computing device, it causes the at least one computing device to perform the dataset splitting method as described in any one of claims 1 to 6.
14. A system comprising at least one computing device and at least one storage device for storing instructions, wherein, When the instruction is executed by the at least one computing device, it causes the at least one computing device to perform the dataset splitting method as described in any one of claims 1 to 6.