Optimization method and device of training data set, electronic equipment and storage medium

By optimizing the training dataset through quality inspection, forward inference, and cluster analysis, the problem of poor training dataset quality was solved, achieving efficient data processing and model training, and improving the performance of the object detection model.

CN122135138APending Publication Date: 2026-06-02GUANGDONG ESHORE TECH

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
GUANGDONG ESHORE TECH
Filing Date
2026-02-13
Publication Date
2026-06-02

AI Technical Summary

Technical Problem

Existing technologies suffer from poor training dataset quality, including imbalanced class and scale distribution, annotation noise, lack of targeted optimization strategies, and independence between data processing and model training, which limits the performance of object detection models.

Method used

By optimizing the training dataset through quality inspection, forward inference, cluster analysis, and scene hierarchical optimization, a high-quality and balanced training dataset is generated.

Benefits of technology

It improves the reliability and relevance of the training dataset, enhances the detection accuracy and efficiency of the object detection model, and shortens the cycle from data preparation to model delivery.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122135138A_ABST
    Figure CN122135138A_ABST
Patent Text Reader

Abstract

This application relates to a method, apparatus, electronic device, and storage medium for optimizing a training dataset. The method includes: performing at least one quality detection operation on an original image dataset to generate an initial training dataset; performing forward inference on the initial training dataset to obtain bounding box information containing target objects; calculating a target area percentage set for the target objects based on the bounding box information; dividing the initial training dataset into at least one training data subset by cluster analysis of the target area percentage set, and determining the scene layering result corresponding to the training data subset; and optimizing the training data subset according to the scene layering result to generate a target training dataset. The solution provided in this application can improve the quality of the training dataset used for object detection models.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of training data processing technology, and in particular to methods, apparatus, electronic devices and storage media for optimizing training datasets. Background Technology

[0002] Object detection is one of the core tasks in computer vision, aiming to locate and classify objects from images or videos. It has wide applications in many important fields such as security monitoring, smart cities, autonomous driving, and remote sensing image analysis. With the development of deep learning technology, object detection algorithms based on convolutional neural networks have gradually become the mainstream technology, improving detection accuracy and real-time performance to a certain extent.

[0003] Among related technologies, object detection models represented by the YOLO series are widely used due to their balance between detection speed and accuracy. These object detection models usually rely on large-scale labeled data for supervised training, and their detection performance largely depends on the distribution quality of the training dataset, the accuracy of the labeling, and the data preprocessing strategy.

[0004] However, these technologies often have the following limitations in practical applications: First, raw datasets collected in real-world scenarios often suffer from severe imbalances in category and scale distribution. Second, manual annotation inevitably introduces issues such as bounding box localization errors, incorrect category labels, and missed annotations, resulting in annotation noise. Third, traditional dataset optimization methods often use fixed proportional thresholds to hard-divide image scenes, leading to a lack of targeted optimization strategies and difficulty in achieving optimal results. Finally, most current data optimization processes are independent of subsequent model training and hardware platforms, failing to form efficient collaboration. Especially on high-performance AI (Artificial Intelligence) computing platforms, their powerful heterogeneous computing and high-speed data processing capabilities are not fully utilized to accelerate preprocessing stages such as data cleaning and augmentation. This disconnect leads to efficiency bottlenecks in overall R&D, prolonging the cycle from data preparation to model delivery.

[0005] It is evident that the relevant technologies suffer from performance limitations due to poor training dataset quality. Summary of the Invention

[0006] To address or partially address the problems existing in related technologies, this application provides a method, apparatus, electronic device, and storage medium for optimizing training datasets, which can improve the quality of training datasets used for object detection models.

[0007] The first aspect of this application provides a method for optimizing a training dataset, comprising: For the original image dataset, perform at least one quality detection operation to generate the initial training dataset; Forward inference is performed on the initial training dataset to obtain bounding box information containing the target object; Based on the bounding box information, calculate the target area percentage set for the target object; By clustering analysis of the target area proportion set, the initial training dataset is divided into at least one training data subset, and the scene stratification result corresponding to the training data subset is determined. Based on the scenario stratification results, the training data subset is optimized to generate the target training dataset.

[0008] In one instance, the quality detection operation includes a blurred image filtering operation and a duplicate image removal operation. The step of performing at least one quality detection operation on the original image dataset to generate an initial training dataset includes: performing the blurred image filtering operation on the original image dataset after format conversion to generate a first valid image dataset; and performing the duplicate image removal operation on the original image dataset to generate a second valid image dataset; and generating the initial training dataset based on the first valid image dataset and the second valid image dataset.

[0009] In one example, performing the blurring image filtering operation on the original image dataset to generate a first valid image dataset includes: converting multiple images to be processed in the original image dataset into grayscale images one by one; calculating the pixel gradient values ​​of the grayscale images using the Laplacian operator; calculating the gradient variance of the grayscale images based on the pixel gradient values; if the gradient variance is less than a preset sharpness threshold, then marking the grayscale images as blurry images and removing the corresponding images to be processed from the original image dataset to obtain the first valid image dataset.

[0010] In one example, the process of performing the duplicate image removal operation on the original image dataset to generate a second valid image dataset includes: converting the image sizes of multiple images to be processed in the original image dataset to a preset image size; converting the images to be processed to the preset image size to grayscale images and calculating the grayscale mean of the grayscale images; calculating the image fingerprint corresponding to the grayscale image based on the grayscale mean; calculating the Hamming distance between any two images to be processed based on the image fingerprint; when the Hamming distance is less than or equal to a preset distance threshold, marking the two images to be processed as duplicate images, and removing one of the images to be processed from the original image dataset to obtain the second valid image dataset.

[0011] In one instance, calculating the target area percentage set for the target object based on the bounding box information includes: for each image to be processed containing the target object, obtaining the image width and image height; extracting the bounding box width and bounding box height for the target object from the bounding box information; calculating the target area percentage for each image to be processed based on the image width, the image height, the bounding box width, and the bounding box height, and summing them to obtain the target area percentage set.

[0012] In one example, the step of dividing the initial training dataset into at least one training data subset by cluster analysis of the target area percentage set and determining the scene stratification result corresponding to the training data subset includes: determining a target number of clusters from multiple candidate cluster numbers; randomly selecting a target area percentage from the target area percentage set as the initial cluster centroid according to the target number of clusters; assigning the target area percentage to the corresponding cluster based on the distance between each target area percentage in the target area percentage set and the initial cluster centroid; iteratively calculating the centroid change of each cluster until the centroid change meets a preset convergence condition to determine the target cluster centroid of the cluster; determining a scene stratification threshold based on the target cluster centroid; dividing the initial training dataset into multiple training data subsets according to the scene stratification threshold and determining the scene stratification result corresponding to the training data subset.

[0013] In one instance, optimizing the training data subset based on the scene layering result to generate the target training dataset includes: selecting a data optimization strategy corresponding to the scene layering result; performing image optimization operations using the corresponding data optimization strategy for each training data subset until each training data subset passes verification, thereby generating the target training dataset.

[0014] A second aspect of this application provides an optimization apparatus for a training dataset, comprising: The quality detection module is used to perform at least one quality detection operation on the original image dataset to generate the initial training dataset; The bounding box information determination module is used to perform forward reasoning on the initial training dataset to obtain bounding box information containing the target object; The target area percentage calculation module is used to calculate the target area percentage set for the target object based on the bounding box information. The scene layering module is used to divide the initial training dataset into at least one training data subset by cluster analysis of the target area proportion set, and determine the scene layering result corresponding to the training data subset. The dataset optimization module is used to optimize the training data subset based on the scenario stratification results and generate the target training dataset.

[0015] A third aspect of this application provides an electronic device, comprising: Processor; and A memory that stores executable code, which, when executed by the processor, causes the processor to perform the method described above.

[0016] A fourth aspect of this application provides a computer-readable storage medium having executable code stored thereon, which, when executed by a processor of an electronic device, causes the processor to perform the method described above.

[0017] The fifth aspect of this application provides a computer program product comprising computer instructions that, when executed by a processor, implement the method described above.

[0018] The technical solution provided in this application may include the following beneficial results: In this application, for the original image dataset, at least one quality detection operation is performed to generate an initial training dataset; forward inference is performed on the initial training dataset to obtain bounding box information containing the target object; based on the bounding box information, a target area percentage set for the target object is calculated; by cluster analysis of the target area percentage set, the initial training dataset is divided into at least one training data subset, and the scene layering result corresponding to the training data subset is determined; according to the scene layering result, the training data subset is optimized to generate a target training dataset.

[0019] The technical solution of this application not only improves the reliability of the training dataset from the source by performing at least one quality detection operation on the original image dataset to pre-remove low-quality samples, but also performs forward inference on the initial training dataset after quality detection to accurately extract the bounding box information of the target object. Furthermore, it calculates the target area ratio set through the bounding box information, performs targeted cluster analysis, automatically divides the initial training dataset into multiple training data subsets, realizes scene layering, and then uses adaptive optimization methods to optimize training data subsets of different scales, thereby improving the quality of the training dataset used for the object detection model.

[0020] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and do not limit this application. Attached Figure Description

[0021] The above and other objects, features and advantages of this application will become more apparent from the more detailed description of exemplary embodiments thereof in conjunction with the accompanying drawings, wherein the same reference numerals generally represent the same components in the exemplary embodiments thereof.

[0022] Figure 1 This is a flowchart illustrating a method for optimizing a training dataset according to an embodiment of this application; Figure 2 This is another flowchart illustrating a method for optimizing a training dataset, as shown in an embodiment of this application. Figure 3 This is a schematic diagram of the Mindyolo dataset optimization system architecture based on scene layering and dynamic threshold adjustment, as shown in the embodiments of this application. Figure 4 This is a schematic diagram illustrating the data set optimization method based on the Mindyolo dataset optimization system in an embodiment of this application; Figure 5 This is a schematic diagram of the structure of an optimization device for a training dataset shown in an embodiment of this application; Figure 6 This is a schematic diagram of the structure of an electronic device shown in an embodiment of this application. Detailed Implementation

[0023] Embodiments of this application will now be described in more detail with reference to the accompanying drawings. While embodiments of this application are shown in the drawings, it should be understood that this application may be implemented in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided to make this application more thorough and complete, and to fully convey the scope of this application to those skilled in the art.

[0024] The terminology used in this application is for the purpose of describing particular embodiments only and is not intended to be limiting of the application. The singular forms “a,” “the,” and “the” used in this application and the appended claims are also intended to include the plural forms unless the context clearly indicates otherwise. It should also be understood that the term “and / or” as used herein refers to and includes any or all possible combinations of one or more of the associated listed items.

[0025] It should be understood that although the terms "first," "second," "third," etc., may be used in this application to describe various information, this information should not be limited to these terms. These terms are only used to distinguish information of the same type from one another. For example, without departing from the scope of this application, first information may also be referred to as second information, and similarly, second information may also be referred to as first information. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature. In the description of this application, "multiple" means two or more, unless otherwise explicitly specified.

[0026] Object detection is one of the core tasks in computer vision, aiming to locate and classify objects from images or videos. It has wide applications in many important fields such as security monitoring, smart cities, autonomous driving, and remote sensing image analysis. With the development of deep learning technology, object detection algorithms based on convolutional neural networks have gradually become the mainstream technology, improving detection accuracy and real-time performance to a certain extent.

[0027] Among related technologies, object detection models, represented by the YOLO series, are widely used due to their balance between detection speed and accuracy. These object detection models typically rely on large-scale labeled data for supervised training, and their detection performance largely depends on the distribution quality of the training dataset, the accuracy of the annotations, and the data preprocessing strategies. Correspondingly, these technologies often have the following limitations in practical applications: First, raw datasets collected in real-world scenarios often suffer from severe imbalances in class and scale distribution. For example, in surveillance scenarios, small-scale targets at a distance (such as pedestrians and vehicles) account for a very small proportion of images, and their sample size is far less than that of medium- and large-scale targets. This imbalance causes the model training process to favor the dominant class, resulting in a significantly low recall rate for small target detection, which is difficult to meet the needs of fine-grained detection in practical applications.

[0028] Secondly, the quality of data annotation is inconsistent. Manual annotation inevitably introduces issues such as bounding box positioning errors, incorrect category labels, and missing annotations, creating annotation noise. This is especially true for small targets with indistinct features, where annotation consistency is even worse. This noisy data directly interferes with the model's learning process, reducing its convergence efficiency and the upper limit of its final performance.

[0029] Furthermore, traditional dataset optimization methods often use a fixed proportional threshold to hard-divide image scenes. This "one-size-fits-all" strategy ignores the differences in the inherent scale distribution of different application scenarios (such as remote sensing images and medical images) and different target characteristics (such as rigid bodies and non-rigid bodies), resulting in a lack of specificity in the optimization strategy and difficulty in achieving the best optimization results.

[0030] Finally, most current data optimization processes operate independently from subsequent model training and hardware platforms, failing to achieve efficient collaboration. Particularly on high-performance AI computing platforms, their powerful heterogeneous computing and high-speed data processing capabilities are not fully utilized to accelerate preprocessing stages such as data cleaning and augmentation. This disconnect leads to overall R&D efficiency bottlenecks and prolongs the cycle from data preparation to model delivery.

[0031] It is evident that the relevant technologies suffer from performance limitations due to poor training dataset quality.

[0032] To address the aforementioned issues, this application provides a method for optimizing training datasets, which can improve the quality of training datasets used for object detection models.

[0033] The technical solutions of the embodiments of this application are described in detail below with reference to the accompanying drawings.

[0034] See Figure 1 , Figure 1 This is a flowchart illustrating a method for optimizing a training dataset, as shown in an embodiment of this application.

[0035] Step 101: Perform at least one quality detection operation on the original image dataset to generate the initial training dataset.

[0036] In this embodiment of the application, image data to be processed is first obtained from different business systems to form an original image dataset. Then, at least one quality detection operation is performed on the original image dataset to generate a filtered initial training dataset.

[0037] Optionally, the original image dataset refers to the set of images to be processed for training the object detection model. The original image set may come from actual acquisition equipment, public datasets, or historical business data, and may contain samples of different quality levels such as clear images, blurry images, duplicate images, and abnormal images.

[0038] Quality detection refers to the automatic filtering of images to be processed, identifying and removing images of poor quality, thereby reducing the interference of low-quality samples on subsequent model training. In this application, quality detection may include one or more data processing methods, such as format normalization, blurred image filtering, duplicate image removal, and abnormal image detection.

[0039] As an example, the process of performing quality inspection can be to evaluate the quality of each image to be processed separately. When the sharpness of the image to be processed is lower than a preset sharpness threshold, the image to be processed is determined to be a low-quality image and deleted. When the similarity between two images to be processed is higher than a preset similarity threshold, the two images to be processed are determined to be duplicate images, and only one of them is kept.

[0040] The initial training dataset refers to the set of valid images obtained after quality detection of the original image dataset, such as a dataset from which blurry and duplicate images have been removed.

[0041] Step 102: Perform forward inference on the initial training dataset to obtain bounding box information containing the target object.

[0042] In the embodiments of this application, a pre-trained object detection model can be used to perform forward inference on the initial training dataset to obtain bounding box information containing the target object.

[0043] Optionally, the target object refers to the object to be detected in the image to be processed, such as a safety helmet in an urban security scenario, equipment parts in an industrial manufacturing scenario, and vehicles in a traffic detection scenario, among other entity objects from various scenarios. In this application, the category of the target object can be pre-defined according to the business scenario.

[0044] Bounding box information refers to information describing the location of a target object in the image to be processed, and it includes at least the bounding box width and bounding box height.

[0045] Step 103: Based on the bounding box information, calculate the target area percentage set for the target object.

[0046] In this embodiment of the application, after obtaining the bounding box information corresponding to the target object in each image to be processed, the scale of the target object in the image can be calculated based on the bounding box information, thereby constructing a target area ratio set.

[0047] Optionally, the target area ratio refers to the ratio between the bounding box area of ​​the target object and the area of ​​the image in which it is located, which is used to characterize the relative size of the target object in the image. The target area ratio set refers to the set of target area ratios calculated for all target objects in the initial training dataset.

[0048] As an example, for any image to be processed, the image width and image height of the image can be obtained, and the bounding box width and bounding box height of the corresponding target object can be extracted from the bounding box information. The target area ratio can be calculated based on the image width, image height, bounding box width, and bounding box height.

[0049] Step 104: By clustering analysis of the target area proportion set, the initial training dataset is divided into at least one training data subset, and the scene stratification result corresponding to the training data subset is determined.

[0050] In this embodiment of the application, after obtaining the target area proportion set, the target area proportion can be processed by cluster analysis to divide samples with similar scale characteristics into the same training data subset, thereby obtaining multiple training data subsets with different scale characteristics, and determining the corresponding scene layering results.

[0051] Alternatively, cluster analysis refers to grouping based on the distance between target area proportions, so that the difference in target area proportions within the same cluster is small, while the difference in target area proportions between different clusters is large, which is beneficial for targeted optimization of training samples under different clusters.

[0052] The training data subset refers to the subset obtained from the initial training dataset based on the clustering analysis results of the target area proportion set, divided according to the scale distribution characteristics of the target object. Each training data subset corresponds to a scale feature and is used for subsequent targeted data optimization processing.

[0053] Scene stratification results refer to scene stratification labels obtained based on cluster analysis. For example, scene stratification results include small target scene layer, medium target scene layer and large target scene layer.

[0054] Step 105: Optimize the training data subset based on the scenario stratification results to generate the target training dataset.

[0055] In this embodiment of the application, after obtaining the training data subset and its corresponding scene stratification results, targeted data optimization processing can be performed on each training data subset according to the scale features of different scene levels, thereby improving the sample effectiveness and sample distribution balance, and generating a target training dataset for model training.

[0056] Optionally, the target training dataset refers to the sample set formed after performing targeted data optimization processing on a subset of training data based on scene stratification results. This dataset has been optimized in terms of sample quality, scale distribution, and annotation reliability, and can be used to train the target detection model, thereby improving the accuracy of the target detection model.

[0057] In this embodiment, for the original image dataset, at least one quality detection operation is performed to generate an initial training dataset; forward inference is performed on the initial training dataset to obtain bounding box information containing the target object; based on the bounding box information, the target area percentage set for the target object is calculated; by cluster analysis of the target area percentage set, the initial training dataset is divided into at least one training data subset, and the scene layering result corresponding to the training data subset is determined; based on the scene layering result, the training data subset is optimized to generate the target training dataset.

[0058] The technical solution of this application not only improves the reliability of the training dataset from the source by performing at least one quality detection operation on the original image dataset to pre-remove low-quality samples, but also performs forward inference on the initial training dataset after quality detection to accurately extract the bounding box information of the target object. Furthermore, it calculates the target area ratio set through the bounding box information, performs targeted cluster analysis, automatically divides the initial training dataset into multiple training data subsets, realizes scene layering, and then uses adaptive optimization methods to optimize training data subsets of different scales, thereby improving the quality of the training dataset used for the object detection model.

[0059] Figure 2 This is another flowchart illustrating a method for optimizing a training dataset as shown in an embodiment of this application. Figure 2 relatively Figure 1 The technical solutions of the embodiments of this application are described in more detail.

[0060] To facilitate understanding of the optimization method for the training dataset in the embodiments of this application, the object detection model in the embodiments of this application will be described in detail below.

[0061] In this embodiment, the object detection model can be a deep learning-based model capable of accurately identifying target objects in an image. Specifically, the object detection model can be a MindYolo object detection model implemented using the MindSpore framework. MindYolo is a model framework for object detection tasks, supporting the YOLO series of algorithm structures. It can perform object detection training and inference tasks on AI processor platforms, covering image data cleaning, scene adaptive layering, dynamic threshold calculation, differential data augmentation, and joint training strategies in collaboration with hardware platforms.

[0062] Furthermore, this application can also deeply optimize the AI ​​processor, enabling it to have the characteristics of high training efficiency and lightweight deployment.

[0063] The technical solution of this application is applicable to providing high-quality and balanced training datasets for deep learning-based detection models in complex and realistic business scenarios. It can be widely used in smart cities, industrial vision, autonomous driving and other scenarios that require accurate identification and localization of multi-scale targets.

[0064] Next, the entire processing procedure will be explained in detail using the target detection model of this application.

[0065] Step 201: Convert the format of the original image dataset.

[0066] This application first performs format conversion processing on the original image datasets from different data sources to generate data samples with a unified data format.

[0067] The original image data is converted into a data format compatible with the MindYolo framework of the object detection model through format conversion, including image data format conversion and annotation data format conversion.

[0068] Image data format conversion may include: uniformly converting the images to be processed in the original image dataset into a preset image encoding format, such as JPG (Joint Photographic Experts Group) format or PNG (Portable Network Graphics) format, and adjusting the image size to a preset input resolution size.

[0069] As an example, the resolution of the image to be processed can be adjusted to 640×640 pixels. When the resolution of the image to be processed is less than the preset input resolution, the original size is maintained to avoid image distortion due to excessive stretching.

[0070] Annotated data format conversion can include converting raw annotation information into a structured text format required for training object detection models, such as TXT (Plain Text File) format, where each line records information about a single target object.

[0071] As an example, the annotation information can include the category identifier of the target object and the bounding box information, in the format of "class_idx_centery_centerwidthheight", where x_center, y_center (target center coordinates), width, and height (target width and height) are all normalized values ​​obtained by dividing the original pixel coordinates by the image width and height.

[0072] Step 202: Perform a blurring image filtering operation on the original image dataset after format conversion to generate the first valid image dataset.

[0073] To improve the quality of the training dataset, it is necessary to remove blurry images with low clarity from the original image dataset.

[0074] As an optional example of the embodiments of this application, a blur image filtering operation is performed on the original image dataset to generate a first effective image dataset, including: converting multiple images to be processed in the original image dataset into grayscale images one by one, calculating the pixel gradient values ​​of the grayscale images using the Laplacian operator, calculating the gradient variance of the grayscale images based on the pixel gradient values, and if the gradient variance is less than a preset sharpness threshold, then marking the grayscale images as blurry images and removing the corresponding images to be processed from the original image dataset to obtain the first effective image dataset.

[0075] The blurred image filtering operation refers to the quality assessment of the images to be processed in the original image dataset. By analyzing the edge features and detail information of the images to be processed, it identifies whether the images are blurred, thereby automatically removing low-quality images. In this application, the blurred image filtering operation includes converting color images to grayscale images, calculating pixel gradient values, calculating gradient variance, and determining whether an image is blurred based on a threshold. The blurred image filtering operation can avoid interference from low-quality images to the target detection model, which is beneficial to improving the convergence speed and detection accuracy of the model.

[0076] The first valid image dataset refers to the dataset obtained after removing blurry images from the original image dataset.

[0077] A grayscale image refers to a color image converted into a single-channel grayscale image, retaining only luminance information and eliminating color channel interference. In this application, the grayscale value calculation formula is as follows: Where G(x,y) is the grayscale value of pixel (x,y), and R(x,y), G(x,y), and B(x,y) are the red channel value, green channel value, and blue channel value of the pixel, respectively.

[0078] The Laplacian operator is used to detect edge information in an image and to measure the strength of gray-level changes between a pixel and its neighborhood.

[0079] Pixel gradient values ​​are used to represent the degree of change of the gray value of each pixel relative to its neighborhood. Images with clear edges have large changes in pixel gradient values, while blurry images have small changes in pixel gradient values.

[0080] In this application, a 3×3 Laplacian operator can be used to detect edges in the image to be processed. The Laplacian operator matrix is ​​as follows:

[0081] The formula for calculating the gradient value of pixel (x,y) is:

[0082] in, This is the Laplacian gradient value, reflecting the grayscale difference between a pixel and its neighbors.

[0083] Gradient variance refers to the value obtained by calculating the variance of the pixel gradient values ​​of the entire grayscale image. It is a core sharpness indicator, and the larger the value, the sharper the image.

[0084] In this application, the variance of the gradient values ​​across the entire image is calculated to quantify image sharpness, using the following formula:

[0085] in, Gradient variance; N: Image pixel width and height; The mean of the Laplacian gradient values ​​across the entire graph. .

[0086] The preset sharpness threshold refers to the threshold used to determine whether an image to be processed is blurry. (For example, setting a sharpness threshold...) =50, if the image to be processed is Images deemed blurry are removed from the dataset. Generally, the preset sharpness threshold is the optimal value verified through multiple experiments, suitable for most industrial scenarios.

[0087] Step 203: Perform duplicate image removal on the original image dataset after format conversion to generate a second valid image dataset.

[0088] To improve the quality of the training dataset, duplicate images in the original image dataset need to be removed to reduce the interference of redundant samples on the training of the object detection model.

[0089] As an optional example of the embodiments of this application, a duplicate image removal operation is performed on the original image dataset to generate a second effective image dataset, including: converting the image size of multiple images to be processed in the original image dataset to a preset image size; converting the images to be processed to the preset image size to grayscale images and calculating the grayscale mean of the grayscale images; calculating the image fingerprint corresponding to the grayscale image based on the grayscale mean; calculating the Hamming distance between any two images to be processed based on the image fingerprint; when the Hamming distance is less than or equal to a preset distance threshold, marking any two images to be processed as duplicate images, and removing one of the images to be processed from the original image dataset to obtain the second effective image dataset.

[0090] The duplicate image removal operation refers to automatically identifying images in the original image dataset that are highly similar or identical in content by comparing the geometric similarity of the original images, and then removing duplicate images.

[0091] The second effective image dataset refers to the dataset obtained by removing duplicate images from the original image dataset.

[0092] The preset image size is used to ensure that different images have a consistent scale when comparing features.

[0093] Gray mean refers to the average gray value of all pixels in a grayscale image, and is used to generate image fingerprints.

[0094] Image fingerprints refer to the hash values ​​of images to be processed. In this application, perceptual hashing algorithms are mainly used to calculate image fingerprints, such as generating binary hash values ​​of images through steps like scaling, grayscale conversion, and binarization.

[0095] Hamming distance refers to the number of binary differences between two image fingerprints and is used to measure image similarity.

[0096] The preset distance threshold is a threshold used to determine whether the images to be processed are duplicates. When the Hamming distance is less than or equal to the preset distance threshold, any two images to be processed are determined to be duplicate images.

[0097] As an example, the duplicate image removal operation primarily measures similarity by generating image fingerprints (hash values) to eliminate duplicate / highly similar images, and includes at least the following steps: Step 1: Size normalization, such as scaling the image to 8×8 pixels (64 pixels) to eliminate the impact of image size differences on similarity calculation.

[0098] Step 2: Grayscale conversion and mean value calculation. For example, perform grayscale conversion on the scaled image and calculate the mean grayscale value of 64 pixels. .

[0099] Step 3: Iterate through each pixel; if the pixel grayscale value... If the result is 1, it is recorded as binary "1"; otherwise, it is recorded as "0". This generates a 64-bit binary hash value H, such as "10100110...1101".

[0100] Step 4: Calculate the Hamming distance d between the hash values ​​of the two images (i.e., the number of different bits in the two hash values), and set a distance threshold. (Experimental verification:) When the image similarity is ≥95%, if If an image is identified as a duplicate, the image with the earliest acquisition time will be retained, and the rest will be discarded.

[0101] Step 204: Generate an initial training dataset based on the first valid image dataset and the second valid image dataset.

[0102] In this application, the method of generating an initial training dataset based on a first valid image dataset and a second valid image dataset may include: merging the first valid image dataset and the second valid image dataset to obtain an initial training dataset that is both clear and non-repetitive.

[0103] As an example, the first and second valid image datasets are independent datasets. During the merging process, the union of the two datasets is taken to obtain the initial training dataset containing all valid images from both datasets, while duplicate images are deduplicated.

[0104] As another example, this application can also perform a blurring image filtering operation on the original image dataset to generate a first effective image dataset. Then, a duplicate image removal operation is performed on the first effective image dataset to generate a second effective image dataset. The second effective image dataset is the result of duplicate image removal based on the first effective image dataset. During the merging process, the intersection of the first effective image dataset and the second effective image dataset can be taken to ensure that the initial training dataset retains only high-quality samples.

[0105] Step 205: Perform forward inference on the initial training dataset to obtain bounding box information containing the target object.

[0106] For each image to be processed in the initial training dataset, this application can use a MindYolo-S model pre-trained on the COCO dataset (Common Objects in Context) for forward inference. The MindYolo-S model is lightweight and has fast inference speed, making it suitable for large-scale training datasets and capable of accurately detecting target objects in the images to be processed.

[0107] Step 206: Based on the bounding box information, calculate the target area percentage set for the target object.

[0108] Based on the bounding box information obtained from forward inference, the area ratio of each target is calculated, thereby further analyzing the relative scale of the target object in the image, so as to perform scene layering and data optimization.

[0109] As an optional example of the embodiments of this application, the target area percentage set for the target object is calculated based on the bounding box information, including: for each image to be processed containing the target object, obtaining the image width and image height, extracting the bounding box width and bounding box height for the target object from the bounding box information, calculating the target area percentage of each image to be processed based on the image width, image height, bounding box width and bounding box height, and summarizing to obtain the target area percentage set.

[0110] Through forward inference, the bounding box information of all target objects in each image is extracted, and the area ratio S of each target object is calculated to describe the relative scale of the target in the image. The calculation formula is as follows: Where S is the target area ratio (normalized value, ranging from 0 to 1), the smaller the S value, the smaller the relative size of the target; bbox_width, bbox_height: the width and height of the target bounding box (normalized values ​​in YOLO format, provided by the model inference results); image_width, image_height: the pixel width and height of the image (unnormalized, such as 640, 480 pixels).

[0111] Calculate S for all target objects in the initial training dataset, and generate a target area percentage set S_set={S1,S2,…,S…} n}. Where n is the total number of all target objects in the dataset.

[0112] Step 207: By clustering analysis of the target area proportion set, the initial training dataset is divided into at least one training data subset, and the scene stratification result corresponding to the training data subset is determined.

[0113] As an optional example of the embodiments of this application, the initial training dataset is divided into at least one training data subset by cluster analysis of the target area proportion set, and the scene stratification result corresponding to the training data subset is determined. This includes: determining the target number of clusters from multiple candidate cluster numbers; randomly selecting the target area proportion from the target area proportion set as the initial cluster centroid according to the target number of clusters; allocating the target area proportion to the corresponding clusters according to the distance between each target area proportion in the target area proportion set and the initial cluster centroid; iteratively calculating the centroid change of each cluster until the centroid change meets the preset convergence condition; determining the target cluster centroid of the cluster; determining the scene stratification threshold based on the target cluster centroid; dividing the initial training dataset into multiple training data subsets according to the scene stratification threshold; and determining the scene stratification result corresponding to the training data subset.

[0114] In this application, the method for determining the target number of clusters from multiple candidate cluster numbers can be the elbow method: for each candidate cluster number, calculate the sum of squared errors of all samples to its cluster centroid, plot the relationship curve, and observe that the point where the curve inflection point is the target cluster number. This is because the error reduction caused by increasing the number of clusters after this point is significantly reduced. Selecting this cluster number can ensure clustering accuracy while avoiding over-division, thus improving the rationality and operability of training dataset stratification.

[0115] The scene layering threshold refers to the boundary value determined based on the clustering results of the target area proportion set, which is used to distinguish target objects of different scales.

[0116] Scene stratification results refer to the classification information after dividing the images to be processed in the initial training dataset into corresponding training data subsets based on scene stratification thresholds. Scene stratification results record the target scale categories contained in each training data subset, such as small targets, medium targets, and large targets, ensuring the balance of scale distribution in the training dataset.

[0117] For example, based on the scene stratification threshold, the initial training dataset is divided into training data subset ①, training data subset ②, and training data subset ③. The scene stratification result is that training data subset ① corresponds to small scene targets, training data subset ② corresponds to medium scene targets, and training data subset ③ corresponds to large scene targets.

[0118] This application uses a pre-trained model to infer the dataset, extracts the area proportion of each target, and uses a clustering algorithm to perform unsupervised learning on the distribution of target area proportions, automatically identifying the typical modalities of target scale in the dataset. Finally, based on the clustering results, a threshold for distinguishing small, medium and large scenes is dynamically set, overcoming the weakness of the fixed threshold strategy in terms of generalization.

[0119] As an example, this application can analyze using the K-means clustering algorithm. Based on the distribution characteristics, it automatically identifies the cluster centers of small, medium, and large targets.

[0120] First, the elbow method is used to determine the optimal number of clusters k. The clustering loss function value J is calculated when k=1, 2, 3, 4, 5. When k increases from 2 to 3, the decrease in J drops sharply (elbow point). Therefore, k=3 is determined (corresponding to small, medium and large scenarios).

[0121] Then, the K-means clustering objective function is adopted with "minimizing the sum of squares within each cluster" as the objective function, and the formula is: .

[0122] Where J: clustering loss function (the smaller the value, the more concentrated the data within the cluster, and the better the clustering effect); The i-th cluster (containing The proportion of all target areas in the cluster (S) is included. The centroid of the i-th cluster (the average value of all S values ​​within the cluster, i.e.) , For clusters (Includes the target number); : Single S and cluster centroid The square of the Euclidean distance.

[0123] Next, initialize 3 random centroids. Iteratively execute the "assign-update" operation. The assignment operation involves: assigning each... Assigned to the cluster corresponding to the nearest centroid (i.e. ,like Minimum. Update operation: Recalculate the centroid of each cluster. Repeat the above operation until the change in centroid is less than the minimum. (With preset convergence conditions), the final clusters are obtained. and corresponding centroid (Assuming) ).

[0124] Finally, the scene stratification threshold is determined based on the cluster centroid. (Small / Medium Scene Boundary) (Divider between medium and large scenes), the formula is: .in, Threshold offset (determined through experimental optimization) , (to avoid data overlap between clusters) Centroids of small and medium target clusters (from K-means clustering results). Based on the above K-means clustering, the scene stratification results are as follows: Small scene: (Targets are relatively small, such as pedestrians at a distance or small parts); Medium-sized scenes: (Targets are of medium relative size, such as nearby vehicles or equipment components); Large-scale scenarios: (The target is relatively large, such as a person in front of you or a large machine).

[0125] Through this step, this application integrates super-resolution reconstruction, targeted local cropping, and oversampling techniques for small-scene samples to enhance the saliency of small targets and balance sample distribution. For medium-scene samples, it combines IoU (Intersection over Union) calculation for annotation quality filtering with GAN (Generative Adversarial Network)-based background noise synthesis to improve annotation quality and model robustness. For large-scene samples, it employs a fusion technique of geometric transformation enhancement and repeated annotation to improve the model's robustness to changes in target morphology and clean up the annotation data.

[0126] Step 208: Optimize the training data subset based on the scenario stratification results to generate the target training dataset.

[0127] As an optional example of the embodiments of this application, a data optimization strategy corresponding to the scene layering result is selected, and image optimization operation is performed for each training data subset using the corresponding data optimization strategy until each training data subset passes the verification and the target training dataset is generated.

[0128] In this application, the data optimization strategy includes one image optimization operation or a combination of multiple image optimization operations, wherein the image optimization operation includes operations such as data augmentation, annotation filtering, and sample balancing on a subset of training data.

[0129] Data augmentation refers to the diverse processing of images in a subset of training data, including operations such as rotation, translation, scaling, horizontal mirroring, brightness adjustment, and contrast adjustment, in order to increase sample diversity and enhance the model's ability to recognize small targets or specific scenes.

[0130] Label filtering refers to correcting erroneous labels in a subset of training data to remove low-quality labels and correct incorrect labels, or using Cycle GAN (Cycle-Consistent Generative Adversarial Network) to synthesize images of different interference scenarios, thereby expanding the background diversity of scene samples and improving the generalization of the model.

[0131] Sample balancing refers to balancing the quantity or weight of samples from different categories or scenarios within a subset of training data to alleviate model training bias caused by uneven sample distribution and ensure the balance of the target training dataset across categories and scenarios.

[0132] As an example, this application designs a dedicated optimization scheme for the target characteristics of different scenarios to solve the problems of insufficient details of small targets, noise in the annotation of medium targets, and poor pose robustness of large targets.

[0133] 1) Optimization for small scenes

[0134] Core objective: To enhance the detailed features of small targets, increase the number of samples, and alleviate the imbalance problem caused by small samples.

[0135] Super-resolution reconstruction: ESRGAN (Enhanced Super-Resolution Generative Adversarial Network) is used to perform super-resolution of the image by 4 times, enlarging the pixel size of small targets by 4 times (e.g., a 10×10 pixel target becomes a 40×40 pixel target) while preserving the edge details of the target.

[0136] Local cropping: Centered on a small target, crop a local area of ​​256×256 or 512×512 pixels (select according to the original image size, ensuring that the cropped area includes the complete target) to increase the relative proportion of the target in the image.

[0137] Oversampling augmentation: Perform data enhancement operations such as horizontal mirroring, brightness ±10% adjustment, and contrast ±5% adjustment on the cropped image to double the number of small scene samples (e.g., 1800 images → 3600 images), balancing the proportion of small, medium, and large scene samples.

[0138] 2) Optimization for mid-scenes

[0139] Core objectives: Improve annotation quality and enhance the model's resistance to background interference.

[0140] Annotation quality filtering: Calculate the IoU (Intersection over Union) between the predicted bounding boxes generated by the model inference and the manually annotated bounding boxes, using the following formula: , (The low-quality annotation threshold verified by experiments) is judged as an annotation error (such as bounding box offset or category mislabeling), and the annotation is removed or marked as needing manual correction.

[0141] Background interference enhancement: CycleGAN (Recurrent Generative Adversarial Network) is used to synthesize images of different interference scenarios, including foggy weather (visibility 200-500 meters), nighttime (low light intensity), and complex backgrounds (such as tree obstruction and dense buildings), to expand the background diversity of the scene samples and improve the generalization of the model.

[0142] 3) Large-scale scene optimization

[0143] Core objectives: Enhance the model's adaptability to pose changes of large targets and merge duplicate annotations.

[0144] Geometric Transformation Enhancement: Performs random geometric transformations on the image, including: random rotation: ±10° (to prevent the target from going beyond the image boundary); scale jitter: 0.9-1.1 times (to simulate changes in target distance); horizontal flip: 50% probability (to enhance the target's left and right attitude robustness).

[0145] Duplicate annotation fusion: For multiple overlapping annotations of the same target (such as duplicate boxes in manual annotation), the non-maximum suppression (NMS) algorithm is used to merge them into a single high-quality annotation. The NMS threshold is set to 0.6 (that is, the boxes with IoU ≥ 0.6 are merged, and the box with the highest confidence is retained).

[0146] In addition, this application constructs a closed loop of "performance evaluation - threshold adjustment - strategy optimization" to ensure that the dataset quality meets the standards. The core of this loop includes performance metric calculation and threshold iteration.

[0147] (1) Calculation of core performance indicators The optimized dataset was input into the MindYolo model (mixed precision training mode), and three core metrics were evaluated. Average Precision (AP) for a single class: This reflects the model's detection accuracy for a single class, and the formula is: Where P(r) is the precision-recall function (precision-recall curve) corresponding to the recall rate r. (TP: true positive, FN: false negative), P (FP: False positive).

[0148] Mean Accuracy (mAP): Reflects the overall detection accuracy of the model across all categories. The formula is: Where N is the total number of target categories in the dataset. Let be the AP value for the i-th category.

[0149] Small target recall rate : Reflects the model's ability to detect small targets, the formula is: .in, To the number of small targets that are correctly detected, This represents the number of small targets that were not detected.

[0150] (2) Threshold Iterative Adjustment If performance indicators do not meet expectations Initiate threshold iteration. Update using Bayesian optimization algorithm. The optimization scope is .

[0151] Re-execute the "scenario layering - differentiated optimization - performance evaluation" process until mAP ≥ 85% and If the pass rate is ≥70% (the standard for industrial-grade testing tasks), the iteration will cease.

[0152] In addition, this application enables end-to-end model-data collaborative training, and by leveraging the hardware characteristics of the AI ​​platform, it achieves seamless integration of data optimization and model training, thereby improving the efficiency of the entire process.

[0153] Hardware-accelerated preprocessing: Utilizing the AI ​​processor's DVPP (Digital Vision Pre-Processing) module, image scaling, grayscale conversion, super-resolution, and other operations are performed in parallel, increasing preprocessing speed by 3 times (compared to CPU processing).

[0154] Mixed precision training: Enable the platform's AMP (Automatic Mixed Precision) mode, dynamically switch between FP16 (16-bit Floating Point, half precision) and FP32 (32-bit Floating Point, single precision), improve training speed by 1.5 times, and avoid gradient underflow through loss scaling to ensure training accuracy.

[0155] Data loading optimization: The optimized dataset is stored in the high-speed storage module of the AI ​​platform, such as SSD (SolidState Drive). The DataLoader of the MindSpore (deep learning framework) framework is used to load the data in parallel, reducing IO (Input / Output) waiting time and increasing the batch size to 64 (compared to 32 in traditional storage).

[0156] For a complete example, see [reference] Figure 3 and Figure 4 , Figure 3 This is a schematic diagram of the Mindyolo dataset optimization system architecture based on scene layering and dynamic threshold adjustment, as shown in the embodiments of this application. Figure 4 This is a schematic diagram illustrating the data set optimization method based on the Mindyolo data set optimization system in an embodiment of this application.

[0157] Taking helmet wearing detection in urban security as an example, this paper illustrates the implementation process of the solution.

[0158] 1) Basic experimental information Hardware environment: A certain brand of AI platform 910B graphics card with 64GB of RAM, a certain model of CPU, and 1TB SSD high-speed storage. Software environment: MindSpore 2.5.0 deep learning framework, MindYolo-S object detection model (pre-trained weights from the COCO dataset), and Python 3.9.

[0159] Original image dataset: 10,000 urban construction site surveillance images, including two categories: "wearing a safety helmet" and "not wearing a safety helmet". The image resolution is 1280×720, and the accuracy of manual annotation is about 82.5% (including blurry and duplicate images).

[0160] 2) Implementation steps and results Step 1: Raw data preprocessing: Perform the "format unification, fuzzy filtering, and duplicate removal" process.

[0161] Standardize the format: scale 10,000 images to 640×360 (maintaining aspect ratio), and convert annotations to YOLO format. Blur filtering: calculate the Laplacian gradient variance for all images. Remove 820 blurred images were generated. Deduplication: 64-bit perceptual hash values ​​were generated for all images, and Hamming distance was removed. 315 duplicate images.

[0162] Of these 315 duplicate images, some were removed as blurred images, meaning there was an overlap between duplicate and blurred images. A total of 180 duplicate images were actually removed, resulting in 9,000 valid images.

[0163] Implementation Process: In the raw data preprocessing stage, 10,000 urban construction site monitoring images were optimized: the format was standardized by adapting the resolution to 640×360 (maintaining aspect ratio), and the annotations were converted to the YOLO standard format. Blur filtering was performed using the Laplacian gradient variance method, removing 820 blurry images with σ² < 50, reducing the blur percentage from 8.2% to 0.3%, and increasing the average sharpness variance from 38.6 to 89.2 (an improvement of 131.1%). Duplicate removal was achieved by calculating the 64-bit hash Hamming distance using perceptual hashing, removing 315 duplicate images with d ≤ 3. Finally, 9,000 valid image data points were obtained, and the annotation effectiveness (IoU ≥ 0.75) increased from 82.5% to 98.7%, laying the foundation for subsequent scene layering. Refer to Table 1, which compares the data before and after preprocessing.

[0164] Table 1

[0165] Step 2: Scene layering and dynamic threshold calculation.

[0166] Target area proportion calculation: Using a pre-trained MindYolo-S model to infer from 9000 images, extract the S-values ​​of all "helmet" targets, and generate... (S contains a total of 28,600 targets).

[0167] K-means clustering: for Perform K-means clustering After convergence, the center of mass is obtained. .

[0168] Dynamic threshold generation: based on formula Calculate the initial threshold After Bayesian iterative optimization, the final threshold was adjusted to (At this point, mAP and small target recall are optimal).

[0169] Scene layering results: Small scene: 1800 images Such as safety helmets for long-distance workers.

[0170] Medium scenes: 5200 images Such as safety helmets for workers operating at medium distances.

[0171] Large scene: 2000 images For example, safety helmets for workers at close range.

[0172] Step 3: Layered scenario-specific optimization, performing dedicated optimizations for the three types of scenarios.

[0173] Small scene optimization: 1800 images → ESRGAN 4x super-resolution → cropping a 300×300 pixel area centered on the helmet → horizontal mirroring + brightness adjustment oversampling → finally obtaining 3600 optimized small scene images.

[0174] Mid-scene optimization: 5200 images → calculate the IoU between predicted bounding boxes and labeled bounding boxes, and remove low-quality labels with IoU < 0.75 (a total of 120 images were removed) → Cycle GAN generates 500 foggy / night scene images → finally obtain 5580 mid-scene optimized images.

[0175] Large-scene optimization: 2000 images → random ±10° rotation + 0.9-1.1 scale jitter + 50% horizontal flip → NMS (threshold 0.6) to merge duplicate annotations (a total of 85 duplicate boxes were merged) → finally obtained 2000 large-scene optimized images.

[0176] The optimized total dataset size is 3600+5580+2000=11180 images, with a more balanced sample distribution (small scenes account for 30.8%, medium scenes account for 47.8%, and large scenes account for 21.4%).

[0177] Step 4: Model training and performance validation.

[0178] The 11,180 optimized images were divided into a training set (8,944 images) and a validation set (2,236 images) in an 8:2 ratio. The MindYolo-S model was trained on the 910B platform, and the model performance of the "unoptimized dataset" and the "optimized dataset of this application" was compared.

[0179] During the model training and validation phase, the optimized 11,180 images were divided into training and validation sets in an 8:2 ratio. MindYolo-S was trained on 910B: Compared with the baseline, mAP increased from 82.5% to 89.7% (+7.2), small target recall increased from 62.0% to 76.3% (+14.3), convergence epochs increased from 220 to 185 (speed increase of 15.9%), false negative rate increased from 12.8% to 4.3%, and inference speed increased from 45 to 52 FPS (+15.6%).

[0180] Compared with traditional methods: the traditional fixed threshold method achieves mAP +2.1 and small target +3.5, with no acceleration; the general enhancement method achieves mAP +3.8 and small target +6.8 (+5%). The improvement of this application is 3.4 / 4.1 times and 1.9 / 2.1 times that of the former two, and it has high cross-scenario adaptability, with an acceleration of 32%, which is a significant advantage.

[0181] Refer to Table 2, which is a comparison table of model performance before and after optimization in this application.

[0182] Table 2

[0183] 3) Implementation Conclusion Significant performance improvement: This application improves the mAP of the MindYolo model by 7.2 percentage points and the recall rate of small targets by 14.3 percentage points in the helmet detection task, solving the core pain point of insufficient accuracy in small target detection.

[0184] Significant efficiency advantages: With the help of hardware acceleration from the AI ​​platform, data preprocessing speed is increased by 3 times, model training convergence speed is increased by 15.9%, and project delivery cycle is significantly shortened.

[0185] High generalization ability: Through CycleGAN background synthesis and multi-scale enhancement, the model reduces the false detection rate from 12.8% to 4.3% in complex scenarios such as fog and night, and can adapt to the detection needs of different urban security scenarios.

[0186] High portability: The dynamic threshold and differentiated optimization logic of this application do not depend on specific tasks and can be directly transferred to other target detection scenarios such as industrial part defect detection and autonomous driving pedestrian detection.

[0187] In this embodiment, after format conversion of the original image dataset, a blurring image filtering operation is performed on the original image dataset to generate a first valid image dataset; and a duplicate image removal operation is performed on the original image dataset to generate a second valid image dataset; an initial training dataset is generated based on the first and second valid image datasets; forward inference is performed on the initial training dataset to obtain bounding box information containing the target object; based on the bounding box information, a target area percentage set for the target object is calculated; the initial training dataset is divided into at least one training data subset by cluster analysis of the target area percentage set, and the scene layering result corresponding to the training data subset is determined; based on the scene layering result, the training data subset is optimized to generate a target training dataset.

[0188] The technical solution of this application not only improves the reliability of the training dataset from the source by performing at least one quality detection operation on the original image dataset to pre-remove low-quality samples, but also performs forward inference on the initial training dataset after quality detection to accurately extract the bounding box information of the target object. Furthermore, it calculates the target area ratio set through the bounding box information, performs targeted cluster analysis, automatically divides the initial training dataset into multiple training data subsets, realizes scene layering, and then uses adaptive optimization methods to optimize training data subsets of different scales, thereby improving the quality of the training dataset used for the object detection model.

[0189] Corresponding to the aforementioned application function implementation method embodiments, this application also provides a training dataset optimization device, electronic device, and corresponding embodiments.

[0190] Figure 5 This is a schematic diagram of the structure of a training dataset optimization device shown in an embodiment of this application.

[0191] See Figure 5 An optimization device for a training dataset, comprising: The quality detection module 501 is used to perform at least one quality detection operation on the original image dataset to generate the initial training dataset; The bounding box information determination module 502 is used to perform forward reasoning on the initial training dataset to obtain bounding box information containing the target object; The target area percentage calculation module 503 is used to calculate the target area percentage set for the target object based on the bounding box information. The scene layering module 504 is used to divide the initial training dataset into at least one training data subset by cluster analysis of the target area proportion set, and to determine the scene layering result corresponding to the training data subset. The dataset optimization module 505 is used to optimize the training data subset based on the scenario stratification results and generate the target training dataset.

[0192] As an optional example of an embodiment of this application, the quality detection operation includes a blurred image filtering operation and a duplicate image removal operation, and the quality detection module 501 includes: The blurred image filtering submodule is used to perform blurred image filtering on the original image dataset after format conversion, generating a first valid image dataset; and, The duplicate image removal submodule is used to perform duplicate image removal operations on the original image dataset to generate a second valid image dataset; The initial training dataset generation submodule is used to generate the initial training dataset based on the first valid image dataset and the second valid image dataset.

[0193] As an optional example of an embodiment of this application, the blurred image filtering submodule is used to: convert multiple images to be processed in the original image dataset into grayscale images one by one; calculate the pixel gradient value of the grayscale image using the Laplacian operator; calculate the gradient variance of the grayscale image based on the pixel gradient value; if the gradient variance is less than a preset sharpness threshold, mark the grayscale image as a blurred image and remove the corresponding image to be processed from the original image dataset to obtain the first effective image dataset.

[0194] As an optional example of an embodiment of this application, the duplicate image removal submodule is used to: convert the image size of multiple images to be processed in the original image dataset to a preset image size; convert the images to be processed that have been converted to the preset image size to grayscale images and calculate the grayscale mean of the grayscale images; calculate the image fingerprint corresponding to the grayscale image based on the grayscale mean; calculate the Hamming distance between any two images to be processed according to the image fingerprint; when the Hamming distance is less than or equal to a preset distance threshold, mark any two images to be processed as duplicate images and remove one of the images to be processed from the original image dataset to obtain a second effective image dataset.

[0195] As an optional example of an embodiment of this application, the target area ratio calculation module 503 is used to: obtain the image width and image height for each image to be processed containing the target object; extract the bounding box width and bounding box height for the target object from the bounding box information; calculate the target area ratio of each image to be processed based on the image width, image height, bounding box width and bounding box height, and summarize to obtain a target area ratio set.

[0196] As an optional example of an embodiment of this application, the scene layering module 504 is used to: determine the target number of clusters from multiple candidate cluster numbers; randomly select a target area percentage from the target area percentage set as the initial cluster centroid according to the target number of clusters; allocate the target area percentage to the corresponding cluster based on the distance between each target area percentage in the target area percentage set and the initial cluster centroid; iteratively calculate the centroid change of each cluster until the centroid change meets the preset convergence condition, and determine the target cluster centroid of the cluster; determine the scene layering threshold based on the target cluster centroid; divide the initial training dataset into multiple training data subsets according to the scene layering threshold, and determine the scene layering result corresponding to the training data subsets.

[0197] As an optional example of an embodiment of this application, the dataset optimization module 505 is used to: select a data optimization strategy corresponding to the scene layering result; perform image optimization operation by adopting the corresponding data optimization strategy for each training data subset until each training data subset passes the verification and generates the target training dataset.

[0198] Regarding the apparatus in the above embodiments, the specific manner in which each module performs its operation has been described in detail in the embodiments related to the method, and will not be elaborated further here.

[0199] Figure 6 This is a schematic diagram of the structure of an electronic device shown in an embodiment of this application.

[0200] See Figure 6 The electronic device 600 includes a memory 610 and a processor 620.

[0201] The processor 620 can be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor can be a microprocessor or any conventional processor.

[0202] Memory 610 may include various types of storage units, such as system memory, read-only memory (ROM), and permanent storage devices. ROM may store static data or instructions required by the processor 620 or other modules of the computer. Permanent storage devices may be read-write storage devices. Permanent storage devices may be non-volatile storage devices that retain stored instructions and data even when the computer is powered off. In some embodiments, permanent storage devices use mass storage devices (e.g., magnetic or optical disks, flash memory) as permanent storage devices. In other embodiments, permanent storage devices may be removable storage devices (e.g., floppy disks, optical drives). System memory may be a read-write storage device or a volatile read-write storage device, such as dynamic random access memory. System memory may store some or all of the instructions and data required by the processor during operation. Furthermore, memory 610 may include any combination of computer-readable storage media, including various types of semiconductor memory chips (e.g., DRAM, SRAM, SDRAM, flash memory, programmable read-only memory), and disks and / or optical disks may also be used. In some embodiments, memory 610 may include a removable storage device that is readable and / or writable, such as a laser disc (CD), a read-only digital multifunction optical disc (e.g., DVD-ROM, dual-layer DVD-ROM), a read-only Blu-ray disc, an ultra-high density optical disc, a flash memory card (e.g., SD card, mini SD card, Micro-SD card, etc.), a magnetic floppy disk, etc. Computer-readable storage media do not contain carrier waves or transient electronic signals transmitted wirelessly or via wired connections.

[0203] The memory 610 stores executable code, which, when processed by the processor 620, can cause the processor 620 to execute part or all of the methods described above.

[0204] Furthermore, the method according to this application can also be implemented as a computer program or computer program product, which includes computer program code instructions for performing some or all of the steps in the method described above.

[0205] Alternatively, this application may be implemented as a computer-readable storage medium (or a non-transitory machine-readable storage medium or a machine-readable storage medium) storing executable code (or computer program or computer instruction code) that, when executed by a processor of an electronic device (or server, etc.), causes the processor to perform part or all of the steps of the methods described above according to this application.

[0206] This application also provides a computer program product, which includes computer instructions that, when executed by a processor, implement the method described above.

[0207] The various embodiments of this application have been described above. These descriptions are exemplary and not exhaustive, nor are they limited to the disclosed embodiments. Many modifications and variations will be apparent to those skilled in the art without departing from the scope and spirit of the described embodiments. The terminology used herein is chosen to best explain the principles, practical application, or improvement of the technology in the market, or to enable others skilled in the art to understand the embodiments disclosed herein.

Claims

1. A method for optimizing a training dataset, characterized in that, include: For the original image dataset, perform at least one quality detection operation to generate the initial training dataset; Forward inference is performed on the initial training dataset to obtain bounding box information containing the target object; Based on the bounding box information, calculate the target area percentage set for the target object; By clustering analysis of the target area proportion set, the initial training dataset is divided into at least one training data subset, and the scene stratification result corresponding to the training data subset is determined. Based on the scenario stratification results, the training data subset is optimized to generate the target training dataset.

2. The method according to claim 1, characterized in that, The quality detection operation includes blurred image filtering and duplicate image removal. For the original image dataset, at least one quality detection operation is performed to generate an initial training dataset, including: After converting the format of the original image dataset, the blurred image filtering operation is performed on the original image dataset to generate a first valid image dataset; and, Perform the duplicate image removal operation on the original image dataset to generate a second valid image dataset; The initial training dataset is generated based on the first valid image dataset and the second valid image dataset.

3. The method according to claim 2, characterized in that, The step of performing the blurring image filtering operation on the original image dataset to generate a first valid image dataset includes: The multiple images to be processed in the original image dataset are converted into grayscale images one by one; The pixel gradient values ​​of the grayscale image are calculated using the Laplacian operator; Based on the pixel gradient values, calculate the gradient variance of the grayscale image; If the gradient variance is less than a preset sharpness threshold, the grayscale image is marked as a blurred image, and the corresponding image to be processed is removed from the original image dataset to obtain the first effective image dataset.

4. The method according to claim 2, characterized in that, The process of performing the duplicate image removal operation on the original image dataset to generate a second valid image dataset includes: Convert the image sizes of multiple images to be processed in the original image dataset to a preset image size; The image to be processed, which has been converted to the preset image size, is converted into a grayscale image, and the mean grayscale value of the grayscale image is calculated. Based on the grayscale mean, calculate the image fingerprint corresponding to the grayscale image; Based on the image fingerprint, calculate the Hamming distance between any two images to be processed; When the Hamming distance is less than or equal to a preset distance threshold, any two images to be processed are marked as duplicate images, and one of the images to be processed is removed from the original image dataset to obtain the second effective image dataset.

5. The method according to claim 1, characterized in that, The step of calculating the target area percentage set for the target object based on the bounding box information includes: For each image to be processed that contains the target object, obtain the image width and image height; Extract the bounding box width and bounding box height for the target object from the bounding box information; Based on the image width, image height, bounding box width, and bounding box height, the target area percentage of each image to be processed is calculated, and the target area percentage set is obtained by summing them up.

6. The method according to claim 1, characterized in that, The step of dividing the initial training dataset into at least one training data subset by cluster analysis of the target area proportion set, and determining the scene stratification result corresponding to the training data subset, includes: Determine the target number of clusters from multiple candidate cluster numbers; Randomly select the target area percentage from the target area percentage set as the initial cluster centroid according to the target cluster number; Based on the distance between each target area percentage in the target area percentage set and the initial cluster centroid, the target area percentage is assigned to the corresponding cluster. Iteratively calculate the change in centroid of each cluster until the change in centroid satisfies the preset convergence condition, and determine the target cluster centroid of the cluster. Based on the target cluster centroid, determine the scene stratification threshold; Based on the scene stratification threshold, the initial training dataset is divided into multiple training data subsets, and the scene stratification results corresponding to the training data subsets are determined.

7. The method according to claim 1, characterized in that, The step of optimizing the training data subset based on the scenario layering results to generate the target training dataset includes: Select a data optimization strategy that corresponds to the scenario layering results; For each subset of training data, a corresponding data optimization strategy is used to perform image optimization operations until each subset of training data passes the verification, thereby generating the target training dataset.

8. An optimization device for a training dataset, characterized in that, include: The quality detection module is used to perform at least one quality detection operation on the original image dataset to generate the initial training dataset; The bounding box information determination module is used to perform forward reasoning on the initial training dataset to obtain bounding box information containing the target object; The target area percentage calculation module is used to calculate the target area percentage set for the target object based on the bounding box information. The scene layering module is used to divide the initial training dataset into at least one training data subset by cluster analysis of the target area proportion set, and determine the scene layering result corresponding to the training data subset. The dataset optimization module is used to optimize the training data subset based on the scenario stratification results and generate the target training dataset.

9. An electronic device, characterized in that, include: processor; as well as A memory having executable code stored thereon, which, when executed by the processor, causes the processor to perform the method as described in any one of claims 1-7.

10. A computer-readable storage medium, characterized in that, It stores executable code that, when executed by a processor of an electronic device, causes the processor to perform the method as described in any one of claims 1-7.