A method and system for optimizing generated defect data based on intelligent screening
By optimizing the generated defect data through an intelligent screening mechanism, the problem of insufficient generalization ability of the generated model in industrial inspection is solved, the authenticity and effectiveness of the samples are improved, and the performance and adaptability of the detection model are enhanced, making it suitable for detection tasks of various industrial products and defect types.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- CHANGZHOU MICROINTELLIGENCE CO LTD
- Filing Date
- 2026-03-25
- Publication Date
- 2026-07-14
Smart Images

Figure CN122391632A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the fields of computer vision and intelligent manufacturing technology, specifically to a method and system for optimizing generated defect data based on intelligent screening. Background Technology
[0002] In the field of industrial inspection, the training of deep learning models relies heavily on a large number of precisely labeled defect samples. However, in actual production lines, defects occur at low frequencies, are unevenly distributed in terms of type, and have highly complex shapes and scales, making it difficult for existing data to cover all defect patterns and meet the training requirements of detection and segmentation models.
[0003] To alleviate the problem of insufficient samples, researchers have proposed using generative models to generate defect samples to expand the training set. In existing technologies, the DFMGAN model, based on generative adversarial networks, can generate realistic images for single products and defect types, but its generalization ability is insufficient. The DefectDiffu model, based on a diffusion model, achieves diversified defect image generation by decoupling the textual conditional embedding network. However, these methods still have significant drawbacks: firstly, the generated results have poor adaptability to downstream detection and segmentation tasks, and some samples fail to improve model performance; secondly, the generated samples are prone to containing invalid negative samples or defect samples that deviate significantly from real-world conditions, leading to negative transfer in model training and limiting their industrial application value.
[0004] Therefore, how to improve the effectiveness of generated samples through intelligent screening mechanisms while maintaining high quality and diversity, so as to make them more in line with actual detection needs, has become an urgent technical problem to be solved. Summary of the Invention
[0005] The purpose of this invention is to overcome at least one technical problem existing in the prior art and to provide a method and system for optimizing generated defective data based on intelligent screening.
[0006] On one hand, embodiments of the present invention provide a method for optimizing generated defect data based on intelligent screening. The optimization method includes: Step S1, defect generation step: based on input real normal samples, real defect samples and their corresponding defect masks, a conditional generation model is used to generate a candidate sample set containing defects; Step S2, intelligent screening step: for each sample in the candidate sample set, its comprehensive quality score is calculated through a multi-dimensional quality assessment system, and based on the comprehensive quality score and a preset threshold rule, the candidate samples are diverted to a high-quality generated dataset, a pending dataset, or directly eliminated; samples in the pending dataset are manually reviewed based on preset review rules, and qualified samples are added. Step S3: Model Training Step: Mix the high-quality generated dataset with real normal samples and real defect samples to construct a target training set for training, and use the target training set to train a preset defect detection model or defect segmentation model; Step S4: Closed-Loop Optimization Step: Analyze the performance of the defect detection model or defect segmentation model, identify its weak points, and generate a targeted regeneration instruction based on this and feed it back to the defect generation step to initiate targeted data supplementation and model iterative optimization; Step S5: Model Deployment Step: Based on the performance of the defect detection model or defect segmentation model, deploy the defect detection model or defect segmentation model that meets the preset requirements online.
[0007] Furthermore, the defect generation step specifically includes: Step S101, Condition Template Construction Sub-step: Establishing a decoupled condition template containing product background conditions and defect type conditions, wherein the condition template is used as a control signal for the generation model in the form of text, image, or mask; Step S102, Controllable Generation Sub-step: Based on the condition template, using a generation model with a diffusion model or generative adversarial network as the backbone, diverse candidate samples are generated in batches by adjusting defect intensity parameters, viewpoint perturbation parameters, and illumination perturbation parameters; Step S103, Automated Initial Screening Sub-step: Automatedly filtering the generated candidate samples to remove samples with image corruption, severe blurring, and feature duplication, forming the candidate sample set.
[0008] Furthermore, step S102 also includes a training step for the generative model: if a diffusion model is used, the product background conditions and defect type conditions are used as decoupling constraints, and standard noise regression loss is used for training, with regional weighting applied to small defect regions; if an adversarial generative network is used, it is first pre-trained on normal samples, and then fine-tuned with a small number of defect samples; the training process monitors convergence and diversity through FID and LPIPS metrics.
[0009] Furthermore, step S1 also includes: cleaning and standardizing the input real normal samples, real defect samples and their corresponding defect masks to generate a structured data list, including: unifying the image color space and resolution to 512. 512, record the scaling factor; perform binarization and geometric correction on the defect mask to unify it to the same coordinate system; the structured data list is in JSON format, recording image number, product name, defect classification, data division method, mask path and working condition metadata, for subsequent traceability and statistics.
[0010] Furthermore, the intelligent screening step specifically includes: Step S201, multi-dimensional feature extraction and scoring sub-step: using a pre-trained feature extraction network, deep feature extraction is performed on the candidate sample set, and four-dimensional quality sub-scores are calculated in parallel, including: authenticity score: the feature distribution distance between the generated sample and the real sample is calculated using the FID or KID algorithm, and the feature distribution distance is converted into an authenticity score based on a preset authenticity score calculation formula; defect reasonableness score: by analyzing the geometric morphological features and texture features of the defect area in the candidate sample, and matching them with the prior knowledge of this type of defect, a defect reasonableness score is obtained. The geometric morphological features include the aspect ratio, area, perimeter, and circularity of the defect area. Usability score: By inputting candidate samples into a pre-trained benchmark defect detection model, the usability score is obtained based on the defect recognition confidence score output by the model; Mask consistency score: The mask consistency score is obtained by calculating the edge alignment and contour matching between the defect image of the candidate sample and its corresponding mask; Step S202, Comprehensive scoring and decision sub-step: The authenticity score, defect rationality score, usability score and mask consistency score are fused by a weighted summation function with preset weights to obtain the comprehensive quality score of each sample; and according to preset high thresholds and low thresholds, the samples are diverted to high-quality generated datasets, pending datasets for review, or low-quality datasets that are directly eliminated.
[0011] Furthermore, the mathematical expression for the weighted summation function with the preset weights is: ; In the formula, The weight parameters for each dimension satisfy... , , To score for authenticity, To score the reasonableness of the defect, Rate usability For mask consistency scoring, This is used to determine the overall quality score.
[0012] Furthermore, the step of supplementing qualified samples from the pending dataset to the high-quality generated dataset after manual review based on preset review rules includes: obtaining authenticity scores, defect reasonableness scores, usability scores, and mask consistency scores; comparing the authenticity scores, defect reasonableness scores, usability scores, and mask consistency scores with their corresponding review thresholds; when three of the scores are greater than or equal to the preset corresponding review thresholds, upgrading the samples from the pending dataset to high-quality samples and supplementing them to the high-quality generated dataset; retaining the samples from the pending dataset as pending samples for re-evaluation in the next closed-loop iteration if and only if the authenticity score and defect reasonableness score are greater than or equal to the preset corresponding review thresholds; and downgrading the samples from the pending dataset to low-quality samples and removing them if only one score is greater than or equal to the preset review threshold.
[0013] Furthermore, the model training steps specifically include: Step S301, Hybrid Training Set Construction Sub-step: The high-quality generated dataset, the real defect sample set, and the real normal sample set are mixed according to a preset ratio, and rare defect categories or small-scale defects are upsampled, while conformal data augmentation is applied to form a target training set; Step S302, Targeted Training Sub-step: An object detection or instance segmentation network is trained using the target training set; During the training process, the loss calculation of pixels in the defect region is weighted higher than that of the background region, and the weight of samples with pseudo-masks from the generation step is dynamically adjusted in the overall loss function based on their mask confidence.
[0014] Furthermore, the closed-loop optimization steps specifically include: Step S401, Performance Diagnosis and Analysis Sub-step: After the defect detection model or defect segmentation model is deployed in the validation set or real production environment, the false negative rate and false positive rate are statistically analyzed under different defect categories, different defect intensities, different product models, and different environmental conditions to locate the weak links in the model performance; Step S402, Directional Instruction Generation Sub-step: The weak links are transformed into specific data generation instructions that can be executed by the defect generation step. The instructions at least explicitly specify the target product, target defect type, target defect intensity range, and scenario conditions that need to be enhanced; Step S403, Iterative Update Sub-step: Based on the instructions, a new round of defect generation and intelligent screening is initiated, the newly generated high-quality samples are added to the high-quality generated dataset, and the periodic retraining and version update of the model are triggered.
[0015] Secondly, embodiments of the present invention provide a system for optimizing generated defect data based on intelligent screening. The system is implemented using the aforementioned method for optimizing generated defect data based on intelligent screening. The system includes: a defect generation module, adapted to generate a candidate sample set containing defects using a conditional generation model based on input real normal samples, real defect samples, and their corresponding defect masks; and an intelligent screening module, adapted to calculate the comprehensive quality score of each sample in the candidate sample set through a multi-dimensional quality assessment system, and, based on the comprehensive quality score and a preset threshold rule, to divert the candidate samples to a high-quality generated dataset, a pending dataset, or directly eliminate them; the samples in the pending dataset are based on a preset complex... After manual review, the kernel rules supplement qualified samples into the high-quality generated dataset; the model training module is suitable for mixing the high-quality generated dataset with real normal samples and real defect samples to construct a target training set for training, and using the target training set to train a preset defect detection model or defect segmentation model; the closed-loop optimization module is suitable for analyzing the performance of the defect detection model or defect segmentation model, identifying its detection weaknesses, and generating targeted regeneration instructions based on this to feed back to the defect generation step to initiate targeted data supplementation and model iterative optimization; the model deployment module is suitable for deploying the defect detection model or defect segmentation model that meets the preset requirements online based on the performance of the defect detection model or defect segmentation model.
[0016] Thirdly, embodiments of the present invention also provide an electronic device, including: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program, when executed by the processor, implements the above-described method for optimizing generated defect data based on intelligent screening.
[0017] Fourthly, embodiments of the present invention also provide a readable storage medium, wherein when the instructions in the storage medium are executed by the processor of an electronic device, the electronic device is able to execute the above-described method for optimizing generated defect data based on intelligent screening.
[0018] The advantages of this invention compared to the prior art are: 1. Improve the authenticity and effectiveness of generated samples: Through a multi-dimensional intelligent screening mechanism, the proportion of invalid negative samples and distorted defective samples is significantly reduced, and the generated data is closer to the real industrial working conditions, avoiding negative transfer in model training.
[0019] 2. Enhance the performance of the detection model: Expand the training set with high-quality generated samples to effectively solve the problem of scarce defective samples, significantly improve the accuracy, recall and robustness of the model, and reduce the false negative rate and false positive rate.
[0020] 3. Strong generalization ability: It supports the detection tasks of multiple industrial products and various defect types. It adapts to changes in working conditions and the launch of new product categories through closed-loop iterative optimization, and has good scalability and practicality.
[0021] 4. Full-process traceability: Through structured data lists and version management, the entire process of sample generation, screening, and model training is traceable and reproducible, facilitating technology iteration and problem investigation. Attached Figure Description
[0022] The present invention will be further described below with reference to the accompanying drawings and embodiments.
[0023] Figure 1 This is a flowchart of a method for optimizing generated defect data based on intelligent screening, provided in Embodiment 1 of the present invention.
[0024] Figure 2 This is a flowchart of another method for optimizing generated defect data based on intelligent screening, provided in Embodiment 1 of the present invention.
[0025] Figure 3 This is a flowchart of step S1 provided in Embodiment 1 of the present invention.
[0026] Figure 4 This is a flowchart of step S2 provided in Embodiment 1 of the present invention.
[0027] Figure 5 This is a flowchart of step S3 provided in Embodiment 1 of the present invention.
[0028] Figure 6 This is a flowchart of step S4 provided in Embodiment 1 of the present invention.
[0029] Figure 7 This is a schematic diagram of a system structure for optimizing generated defect data based on intelligent screening, provided in Embodiment 2 of the present invention.
[0030] Figure 8 This is a partial block diagram of the electronic device provided in Embodiment 3 of the present invention. Detailed Implementation
[0031] Before discussing the exemplary embodiments in more detail, it should be noted that some exemplary embodiments are described as processes or methods depicted as flowcharts. Although the flowcharts describe the operations as sequential processes, many of these operations can be performed in parallel, concurrently, or simultaneously. Furthermore, the order of the operations can be rearranged. The process can be terminated when its operation is completed, but may also have additional steps not included in the figures. The process can correspond to a method, function, procedure, subroutine, subroutine, etc.
[0032] It should be understood that although the terms "first," "second," etc., may be used herein to describe various units, these units should not be limited by these terms. These terms are used merely to distinguish one unit from another. For example, without departing from the scope of the exemplary embodiments, a first unit may be referred to as a second unit, and similarly, a second unit may be referred to as a first unit. The term "and / or" as used herein includes any and all combinations of one or more of the associated listed items.
[0033] The present invention will now be described in detail with reference to the accompanying drawings. These drawings are simplified schematic diagrams, illustrating only the basic structure of the invention, and therefore only show the components relevant to the invention.
[0034] For ease of understanding, the technical terms appearing in the following embodiments are explained here: Negative samples: In defect sample generation and detection tasks, negative samples usually refer to samples that do not contain defects. In generation tasks, if the model generates an image that was originally labeled as "defective" but does not actually contain defects, or if the generated defect features are too fake and cannot reflect the real working conditions, it can also be regarded as an "invalid negative sample".
[0035] Negative transfer: Negative transfer refers to the phenomenon in transfer learning where the knowledge learned from the source task or source data not only fails to help train the target task, but also causes a decline in model performance.
[0036] Generative Adversarial Networks (GANs): GANs are a type of generative model based on game theory, consisting of a generator and a discriminator. The generator is responsible for generating new samples, while the discriminator determines whether the input is "real data" or "generated data." The two are continuously optimized through adversarial training, ultimately enabling the generator to produce highly realistic samples.
[0037] Diffusion models are a type of generative model based on probabilistic reasoning. The basic idea is to progressively add noise to the real samples during the forward pass until the data is completely submerged in noise; during the backward pass, a model is trained to progressively denoise the data, recovering the target sample from the pure noise. Through this progressive denoising method, diffusion models can generate high-quality, detailed samples.
[0038] FID: A commonly used metric for measuring the quality of generated images, used to evaluate the difference in feature distribution between images generated by a generative model and real images.
[0039] LPIPS: A deep network-based perceptual similarity metric used to measure the degree of difference between two images at the "human visual perception level".
[0040] mAP: The most commonly used comprehensive performance evaluation metric in object detection and instance segmentation tasks. It measures the model's precision and recall performance at different thresholds, calculates the AP for each object class, and then averages the results across all classes to obtain the overall performance metric mAP.
[0041] Example 1
[0042] The specific implementation method is as follows: like Figure 1 and 2 The diagram shown is a flowchart of a method for optimizing generated defect data based on intelligent screening, provided by the present invention.
[0043] As an example, the optimization method includes: Step S1, Defect Generation Step: Based on the input real normal samples, real defect samples and their corresponding defect masks, a conditional generation model is used to generate a candidate sample set containing defects; Step S2, Intelligent Screening Step: For each sample in the candidate sample set, its comprehensive quality score is calculated through a multi-dimensional quality assessment system, and based on the comprehensive quality score and a preset threshold rule, the candidate samples are diverted to a high-quality generation dataset, a pending dataset, or directly eliminated; the samples in the pending dataset are manually reviewed based on preset review rules, and qualified samples are added to the high-quality generation dataset; Step S3, Model Training steps: 1. Mix the high-quality generated dataset with real normal samples and real defect samples to construct a target training set for training, and use this target training set to train a preset defect detection model or defect segmentation model; 2. Closed-loop optimization steps: Analyze the performance of the defect detection model or defect segmentation model, identify its weak points, and generate targeted regeneration instructions based on this to feed back to the defect generation step to initiate targeted data supplementation and model iterative optimization; 3. Model deployment steps: Based on the performance of the defect detection model or defect segmentation model, deploy the defect detection model or defect segmentation model that meets the preset requirements online.
[0044] In some feasible implementations, combined with Figure 3As shown, the defect generation step specifically includes: Step S101, Condition Template Construction Sub-step: Establishing a decoupled condition template containing product background conditions and defect type conditions. The condition template serves as the control signal for the generation model in the form of text, images, or masks; Step S102, Controllable Generation Sub-step: Based on the condition template, using a generation model with a diffusion model or generative adversarial network as its backbone, diverse candidate samples are generated in batches by adjusting defect intensity parameters, viewpoint perturbation parameters, and illumination perturbation parameters; Step S103, Automated Initial Screening Sub-step: Automatedly filtering the generated candidate samples to remove samples with image corruption, severe blurring, and feature duplication, forming the candidate sample set. The condition template construction sub-step provides structured constraints for controllable generation, ensuring the goal-orientation of the generation; the controllable generation sub-step achieves diversity coverage under constraints; the automated initial screening sub-step serves as the first quality checkpoint, improving the processing efficiency of subsequent intelligent screening steps.
[0045] Preferably, step S102 further includes a generative model training step: if a diffusion model is used, the product background conditions and defect type conditions are used as decoupling constraints, and standard noise regression loss is used for training, and regional weighting is applied to small defect regions; if an adversarial generative network is used, it is first pre-trained on normal samples, and then fine-tuned with a small number of defect samples; the training process monitors convergence and diversity through FID and LPIPS metrics.
[0046] Preferably, the goal of step S1 is to train a model capable of generating high-quality, diverse defect images based on given conditions. The specific implementation steps (taking the diffusion model route as an example) are as follows: 1. Forward noise addition process: For a real defect image, a small amount of Gaussian noise is added to it at each step. After repeating this hundreds or even thousands of times, the image will eventually become a completely random noise image. This process is deterministic and requires no learning. 2. Backward denoising training: Model input: Randomly select a time step, obtain the noise image corresponding to that step, and two conditional information: a) the product background text description corresponding to the image, b) the defect category label corresponding to the image. Model task: Train a U-Net neural network whose goal is to predict the noise added to the original image. Training process: Input the noisy image and conditional information into the U-Net network, and the network will output a predicted noise. Then compare this predicted noise with the actual added noise, and calculate the mean squared error between them as the loss function. Through the backpropagation algorithm, continuously adjust the weight parameters of the U-Net network to make its noise prediction ability increasingly accurate. Region Weighting: When calculating the loss, the system multiplies the loss value of pixels in the defect region by a weight coefficient greater than 1, based on the defect mask. This means the model is required to be more accurate in predicting noise in defect regions, forcing it to focus more on learning the generation of defect features. 3. Monitoring and Convergence: During training, no filtering module is used. Instead, a batch of real images is periodically extracted from the training set, and images corresponding to the conditions are generated using the current model. Then, the FID and LPIPS metrics between the generated image set and the real image set are calculated. When these metrics no longer significantly improve over several consecutive training cycles, training is stopped, and the model is saved.
[0047] Once the generative model is trained, diverse candidate samples are generated in batches by adjusting defect intensity parameters, viewpoint perturbation parameters, and illumination perturbation parameters. This includes: 1. Controllable parameter sampling: For each (product, defect class) combination, the system presets an intensity parameter range (e.g., 0.2 to 1.0). This intensity parameter in diffusion models is typically achieved by adjusting the number of denoising steps or as part of the conditional input, controlling the prominence of the defect. Simultaneously, the system randomly perturbs the viewpoint (fine-tuned through affine transformation), illumination (adjusted by brightness and contrast), and background texture (by adding very weak noise) to increase data diversity. 2. Generation and pseudo-mask acquisition: If the generative model (such as some improved diffusion models) can directly output image pairs with masks, they are saved directly. If the model can only output images, a post-processing workflow is initiated: using a pre-trained saliency detection model or weakly supervised segmentation model, the generated defect images are analyzed, highlighting the regions most likely to be defects, and a binary "pseudo-mask" is generated through thresholding. This process also outputs a confidence score indicating the reliability of the pseudo-mask. At this point, candidate samples are generated. Since the generated candidate samples may contain duplicates or blurry images that do not meet the requirements, preliminary screening of the candidate samples is necessary after generation. This includes: Removing broken images: Using image sharpness assessment algorithms (such as calculating the Laplacian variance of the image), excessively blurry images are filtered out. Removing duplicate images: The feature vectors of all generated images are calculated (using a pre-trained CNN network). If the cosine similarity of the feature vectors of two images exceeds a threshold, they are considered duplicates, and only one is retained. Limiting to a single pattern: The features of all generated images are analyzed using a clustering algorithm. If the number of images in a certain cluster is too large, a portion is randomly sampled from it to avoid insufficient diversity in the generated set. Finally, the screened candidate samples are combined to obtain the candidate sample set.
[0048] In some feasible implementations, step S1 further includes: cleaning and standardizing the input real normal samples, real defect samples, and their corresponding defect masks to generate a structured data list, including: unifying the image color space and resolution to 512. 512, record the scaling factor; perform binarization and geometric correction on the defect mask to unify it to the same coordinate system; the structured data list is in JSON format, recording image number, product name, defect classification, data division method, mask path and working condition metadata, for subsequent traceability and statistics.
[0049] Preferably, after obtaining real normal samples, real defect samples, and their corresponding defect masks, the samples need to be cleaned and standardized, including: 1. Remove outlier samples: Automated algorithms analyze the image's brightness histogram. If the image is too bright or too dark overall, exceeding the preset reasonable exposure range, it is judged as an exposure anomaly and removed. Simultaneously, it checks whether the file is corrupted and whether it can be correctly decoded into an image matrix. 2. Unify color space: Convert all images from various possible color spaces (such as RGBA, CMYK, grayscale) to the most commonly used RGB color space. 3. Unify resolution: Scale all images to a fixed 512 resolution using image scaling algorithms (such as bilinear interpolation or Lanczos interpolation). The image size is 512 pixels. Simultaneously, the system records the original size and scaling factor of each image, which is crucial for subsequent mask generation and defect size evaluation. Mask binarization and geometric correction: The defect-annotated mask (which may be a grayscale image or a color image with different labels) is thresholded and converted into a pure black and white image, where white represents the defect area and black represents the normal background. Then, morphological operations (such as closing operations) are used to fill tiny holes in the mask caused by inaccurate annotations, and opening operations are used to eliminate isolated noise points, making the boundaries of the defect area smoother and more coherent. Coordinate system one: Ensures that all images and their corresponding masks are perfectly aligned at the pixel level, meaning that every pixel on the mask precisely corresponds to the pixel at the same position in the original image.
[0050] 2. Constructing Condition Templates and Dictionaries: Establishing a Standard Dictionary: Create a structured text dictionary listing all possible product names and defect types in key-value pairs. For example: Product: ["Mobile Phone Case A", "Circuit Board B"], Defect: ["Scratches", "Dents", "Impurities"]. Forming Condition Templates: For text-based condition models: Design a set of reusable natural language phrase templates. For example, a complete condition might be composed of three parts: "A product with [product background] has a defect of [defect type] on its surface [fusion condition]." Here, [product background] is selected from the product dictionary, [defect type] from the defect dictionary, and [fusion condition] from a lexicon describing fusion methods (e.g., "natural attachment", "deep embedding", "shallowness"). For image / mask-based condition models: Input a real, normal image as the "product background condition" and a mask image of the target defect as the "defect location and shape condition" into the model.
[0051] 3. Generate a data list: Create a structured JSON file containing a list of metadata for all samples. Each sample entry records: the image's unique ID, the corresponding product name, the defect category, whether the data belongs to the training or validation set, the storage path of the mask file, whether the sample is real or generated, and environmental metadata at the time of shooting (such as lighting angle, camera model, etc.). This list is the cornerstone of the entire traceability process.
[0052] In some feasible implementations, combined with Figure 4 As shown, the intelligent screening step specifically includes: Step S201, multi-dimensional feature extraction and scoring sub-step: using a pre-trained feature extraction network, deep feature extraction is performed on the candidate sample set, and four-dimensional quality sub-scores are calculated in parallel, including: authenticity score: the feature distribution distance between the generated sample and the real sample is calculated using the FID or KID algorithm, and the feature distribution distance is converted into an authenticity score based on the preset authenticity score calculation formula; defect reasonableness score: by analyzing the geometric morphological features and texture features of the defect area in the candidate sample, and matching them with the prior knowledge of this type of defect, a defect reasonableness score is obtained. The geometric morphological features include the aspect ratio, area, perimeter, and roundness of the defect area. Usability Score: By inputting candidate samples into a pre-trained benchmark defect detection model, the usability score is obtained based on the defect recognition confidence output by the model. Mask Consistency Score: The mask consistency score is obtained by calculating the edge alignment and contour matching between the defect image of the candidate sample and its corresponding mask. Step S202, Comprehensive Score and Decision Sub-step: The authenticity score, defect rationality score, usability score, and mask consistency score are fused using a weighted summation function with preset weights to obtain a comprehensive quality score for each sample. Based on preset high and low thresholds, the samples are diverted to a high-quality generated dataset, a pending dataset for review, or a low-quality dataset that is directly eliminated. The multi-dimensional feature extraction and scoring sub-step comprehensively evaluates from four orthogonal dimensions: generation quality, physical rationality, task utility, and annotation quality. The comprehensive score and decision sub-step transforms the multi-dimensional evaluation results into a single, operable classification decision through configurable weights and thresholds, ensuring that only high-quality, highly usable samples can flow into the downstream training process.
[0053] Preferably, the mathematical expression of the weighted summation function of the preset weights is: ; In the formula, The weight parameters for each dimension satisfy... , , To score for authenticity, To score the reasonableness of the defect, Rate usability For mask consistency scoring, This is used to determine the overall quality score.
[0054] Specifically, generated images (each sample in the candidate sample set) and real images are input into a pre-trained large visual backbone network (such as Inception-V3 or ResNet). Instead of taking the network's final output, the activation values of a certain intermediate layer are extracted. These activation values are high-dimensional feature vectors, considered to contain deep semantic information of the image. Authenticity scoring: The set of feature vectors from all real images is treated as one multivariate probability distribution, and the set of feature vectors from all generated images is treated as another distribution. The FID score is calculated by the Fraser distance (a mathematical method for measuring the similarity between two distributions). The smaller this distance, the higher the authenticity score. Defect plausibility scoring: Geometric morphology analysis: Connected component analysis is performed on the defect mask to extract the geometric attributes of each defect region, such as area, perimeter, aspect ratio, and roundness. For example, for "scratches," the aspect ratio should be large; for "holes," the region should be closed. A reasonable range of geometric parameters is preset according to the defect type; defects that do not conform to this range will receive lower scores. Texture Consistency Analysis: Extract texture features (e.g., using the LBP algorithm) from the defect area and its surrounding normal area, checking whether the texture of the defect area transitions naturally with the surrounding background texture, rather than being abruptly pasted. Usability Score: Input the generated sample (image and its mask) into a currently used or reasonably performing pre-trained defect detection model, allowing the model to infer. If the detection model can correctly detect the location and category of the defect with high confidence, the features of the generated sample are considered effective, and a high usability score is assigned. Mask Consistency Score: Edge Alignment: Extract edges from the generated image and its mask using an edge detection algorithm (e.g., the Canny operator). Then calculate the Hausdorff distance or average distance between these two sets of edges; the smaller the distance, the better the alignment. Contour Smoothness: Analyze the curvature variation of the mask contour; an excessively jagged, unnatural contour is considered to have poor smoothness. Substitute the four sub-scores into a pre-defined weighted summation formula to obtain the comprehensive quality score Q(x). The weights are typically determined based on the business experience or through a grid search on the validation set. For example, if the most pressing issue is improving model recall, the weight of the "usability score" might be increased. The system maintains two thresholds: a high-quality threshold and a low-quality threshold. High-quality samples: those with a composite score exceeding the high-quality threshold are considered "out-of-the-box" and directly flow into the high-quality generated set G+. Undecided samples: those with a composite score between the two thresholds. These samples are sent to a review platform with a graphical interface, where quality control experts manually judge and make a final decision to "adopt" or "reject." Adopted samples are also added to G+. Low-quality samples: those with a composite score below the low-quality threshold are automatically and permanently discarded by the system.All sample IDs, original image paths, mask paths, four sub-scores, overall scores, triage decision results, and the model version number used for selection are recorded in a structured database (such as an SQL database). This allows any selection result to be fully queried and reproduced.
[0055] More specifically, to facilitate understanding of the above implementation method, the working process of the intelligent screening module will be explained in detail here using scratches on a mobile phone glass cover as an example: Example Background: Candidate Sample: A generated image of the iPhone 15 glass cover containing a deep scratch. Input Data: Generated Image (Candidate Sample Set): A 512×512 pixel RGB image; Corresponding Mask: A binary image where white areas represent scratch defects; Metadata: Product="iPhone15", Defect Type="Deep Scratch".
[0056] Step 1: Feature Extraction: Input the generated image into the pre-trained Inception-V3 network and extract the activation values of the penultimate layer (before the global average pooling layer) to obtain a 2048-dimensional feature vector. This feature vector captures the high-level semantic information of the image (such as edges, textures, and shape patterns). The same operation is performed on all real images to build a set of feature vectors for real images.
[0057] Step 2: Four-Dimensional Scoring Calculation: 1. Authenticity Score Calculation: Objective: To evaluate the distribution similarity between generated images and real images; Calculation Process: a) Establishing the Real Distribution: Collect feature vectors from 1000 real mobile phone glass images; calculate the mean μ_real and covariance matrix Σ_real of these vectors; based on this, a multivariate Gaussian distribution N(μ_real, Σ_real) is defined. b) Establishing the Generated Distribution: Collect feature vectors from all generated samples in the current batch; calculate the mean μ_gen and covariance matrix Σ_gen; obtain the distribution N(μ_gen, Σ_gen). c) Calculating the FID score: ;Calculation yielded: FID = 28.5; d) Converted to a 0-1 score: The smaller the FID, the better. We convert it into a 0-1 score through linear mapping (1 point when FID=0, 0 points when FID=100).
[0058] 2. Defect Reasonableness Score Calculation: Objective: To assess whether the shape of the scratch conforms to physical laws. Calculation process: a) Geometric feature extraction: Perform connected component analysis on the mask to find the largest defect area and calculate the geometric properties: Area: A = 850 pixels, Perimeter: P = 210 pixels, Minimum bounding rectangle: Long side L = 95 pixels, Short side W = 9 pixels. b) Feature scoring: Aspect ratio: AR = L / W = 95 / 9≈10.56; For scratches, the expected AR > 8, score: min(AR / 15,1) = 0.70; Circularity: For scratches, the expected value is C < 0.3, and the score is: Continuity: Calculate the Euler number (number of holes) of the mask. In this example, it is a single connected region with no holes, so the continuity score is assigned as 0.90. c) Texture consistency analysis: Calculate the LBP texture features in the scratched area and the surrounding normal area respectively; calculate the cosine similarity of the texture features of the two areas: 0.65; texture score: 0.65. d) Comprehensive defect reasonableness score: .
[0059] 3. Usability Score Calculation: Objective: To evaluate whether the current detection model can identify the defect. Calculation Process: a) Baseline Model Inference: Input the generated image into the YOLOv5 scratch detection model deployed on the current production line. Model output: Detection box confidence: 0.82; Class confidence (scratch): 0.78; Intersection over Union (IoU): 0.75 (compared to the real mask). b) Score Calculation: .
[0060] 4. Mask Consistency Score Calculation. Objective: To evaluate the alignment between image defects and mask annotations. Calculation process: a) Edge extraction: Extract edges from the original image using the Canny operator: obtain E_image; extract edges from the mask: obtain E_mask; both are binary edge images. b) Distance calculation: For each edge point in E_image, find the nearest neighbor in E_mask and calculate the distance; average all distances: average distance d_avg = 3.2 pixels. c) Score conversion: That is, a distance of 0 earns 1 point, and the greater the distance, the lower the score. In this example, the distance is relatively large, indicating that the mask boundary is offset from the actual scratch boundary in the image.
[0061] Step 3: Comprehensive Scoring and Triage Decision: Comprehensive score calculation: , , , Calculation process: Threshold settings: High-quality threshold T_high = 0.75, low-quality threshold T_low = 0.45. Decision result: The comprehensive score Q(x) = 0.689, which satisfies: T_low(0.45) < 0.689 < T_high(0.75) → determination: pending sample.
[0062] In some feasible embodiments, the process of supplementing the qualified samples to the high-quality generation dataset after manually reviewing the samples in the pending dataset based on a preset review rule includes: obtaining a authenticity score, a defect rationality score, an availability score, and a mask consistency score; comparing the authenticity score, the defect rationality score, the availability score, and the mask consistency score with their corresponding review thresholds respectively; when three of the scores are greater than or equal to the preset corresponding review thresholds, upgrading the sample in the pending dataset to a high-quality sample and supplementing it to the high-quality generation dataset; when and only when the authenticity score and the defect rationality score are greater than or equal to the preset corresponding review thresholds, retaining the sample in the pending dataset as a pending sample for re-evaluation in the next round of closed-loop iteration; when only one score is greater than or equal to the preset review threshold, downgrading the sample in the pending dataset to a low-quality sample and excluding it. That is, the samples in the pending dataset are not directly discarded, but are further screened based on a predetermined rule through manual screening or automatic screening, and the samples that meet the requirements flow into the high-quality generation dataset.
[0063] In some feasible embodiments, combined with Figure 5 As shown, the model training step specifically includes: Step S301, a mixed training set construction sub-step: mixing the high-quality generation dataset, the real defect sample set, and the real normal sample set according to a preset ratio, and performing upsampling on rare defect categories or small-scale defects, and at the same time applying conformal data augmentation operations to form a target training set; Step S302, a targeted training sub-step: using the target training set to train a target detection or instance segmentation network; during the training process, applying a higher weight to the loss calculation of the pixels in the defect area than the background area, and for the samples with pseudo-masks from the generation step, dynamically adjusting their weights in the overall loss function according to their mask confidence. The mixed training set construction sub-step solves the data imbalance problem and improves the overall diversity of the dataset through scientific mixing and sampling strategies; the targeted training sub-step, through the special design of the loss function, on the one hand strengthens the model's learning ability for difficult samples (small defects), and on the other hand robustly processes the annotation noise inherent in the generated data, thereby maximizing the training benefit of the high-quality generation dataset.
[0064] Specifically, the hybrid training set construction sub-step includes: a) Data isolation: At the beginning of the process, all real data is divided into three parts: training set, validation set, and test set. The test set must consist entirely of real data, and generated data must never be mixed into the test set in any subsequent stage. This is the gold standard for evaluating the model's generalization ability. b) Hybrid strategy: Dynamic sampling: Instead of simply merging all data, a sampler is designed. This sampler assigns different sampling probabilities to different samples based on the sample's category (real defect, generated defect, real normal) and the rarity of the defect. For example, samples of rare defect classes will be sampled with a higher probability, thus appearing multiple times in a training iteration. Data augmentation: A series of conformal augmentation transformations are applied to the training images, such as random horizontal flipping, small-angle rotation, and slight brightness and contrast adjustments. The key principle is that any geometric transformation applied to the image must be applied synchronously and consistently to the corresponding mask to ensure that the image and annotations always maintain pixel-level alignment. For a specific example, the data composition is as follows: 48 real defect images; 93 generated high-quality samples (G+); and 500 real normal images. The hybrid strategy is as follows: Detection task: A 1:1:1 sampling ratio is used: 48 real + 93 generated = 141 defect samples, and 500 normal samples. In each training round, 141 defective images and 141 normal images are randomly sampled. Data augmentation includes: random horizontal flipping (flipping both the image and the mask simultaneously); brightness adjustment of ±10%; and small-angle rotation (±5 degrees).
[0065] Specifically, the targeted training sub-steps include (taking YOLO as an example): a) Loss function composition: Classification loss: measures whether the model correctly predicts the defect category; Bounding box regression loss: measures whether the model accurately predicts the defect location box; Confidence loss: measures the model's confidence in whether a defect exists within the box; Segmentation loss: For segmentation tasks, an additional branch is added to calculate the binary cross-entropy loss or Dice loss between the predicted mask and the real mask. b) Special processing for generated data: Region weighting: When calculating the segmentation loss, defect pixels, especially small defect pixels, are given higher loss weights, forcing the model to focus more on small targets that are difficult to learn. Confidence weight: For samples from the generation module with low-confidence "pseudo-masks," when calculating their segmentation loss, the overall loss of the sample is multiplied by a weight coefficient less than 1, thereby reducing the negative impact of unreliable annotations on model training. Specifically, the YOLOv8 segmentation model training process is as follows: Loss function configuration: classification loss + bounding box loss + segmentation mask loss; the loss weight for pixels in the scratch region is set to 1.5; for pseudo-mask samples, the weight is set according to their confidence level (0.7-1.0). Training process: Optimizer: AdamW, learning rate 0.001; training cycle: 300 epochs; early stopping strategy: stop if there is no improvement in mAP on the validation set for 20 consecutive epochs.
[0066] Preferably, the evaluation process also includes model assessment, with core metric evaluation: running the trained model on a real test set and calculating precision, recall, F1-score, and mean precision (mAP). These metrics reflect the model's overall capabilities. Fine-grained analysis: Analysis by defect intensity: grouping test samples according to the severity of defects (e.g., size, contrast) and calculating mAP for each group. This verifies the model's stability under different difficulty levels. Calculating missed and over-detected defects: analyzing which real defects were missed by the model and which normal regions were misclassified as defects. Comprehensive selection: considering not only mAP but also the model's inference speed (frame rate) and computational resource usage (GPU memory). Ultimately, a balance is struck between performance and efficiency, selecting an optimal model weight file and exporting it to the required deployment format.
[0067] In some feasible implementations, combined with Figure 6 As shown, the closed-loop optimization steps specifically include: Step S401, Performance Diagnosis and Analysis Sub-step: After the defect detection model or defect segmentation model is deployed in the validation set or real production environment, the false negative rate and false positive rate are statistically analyzed under different defect categories, different defect intensities, different product models, and different environmental conditions to locate the weak links in the model performance; Step S402, Directional Instruction Generation Sub-step: The weak links are transformed into specific data generation instructions that can be executed by the defect generation step. The instructions at least explicitly specify the target product, target defect type, target defect intensity range, and scenario conditions that need to be enhanced; Step S403, Iterative Update Sub-step: Based on the instructions, a new round of defect generation and intelligent screening is initiated, the newly generated high-quality samples are added to the high-quality generated dataset, and the periodic retraining and version update of the model are triggered.
[0068] Preferably, the specific implementation steps are as follows: a) Error analysis: In-depth analysis of the model's failure cases on the test set. For example, it was found that the model had a particularly high false negative rate for "fine scratches" on "circuit board B", or that it was prone to false positives for "phone casing A" under "side lighting" conditions. b) Generation condition reconstruction: These specific weaknesses were transformed into instructions executable by the generation module. For example, the instructions became: Product = "circuit board B", Defect = "scratch", Intensity = 0.3-0.6 (simulating inconspicuous scratches), Lighting condition = "side lighting". c) Initiate targeted generation: Using the same generation model as the first round, but sampling and generation were only performed under these specific, finely defined combinations of conditions. Subsequently, the newly generated samples were again strictly filtered by the intelligent screening module, and high-quality samples were added to the G+ dataset. For example, error analysis found that the model still had a high false negative rate (approximately 40%) for "very shallow scratches" (intensity < 0.3); and the scratch detection performance was poor at a specific angle (45 degrees side view). Targeted generation command: {"Product Background": ["iPhone15", "Huawei Mate60"],"Defect Type": ["Shallow Scratches"],"Intensity Range": [0.1, 0.3],"Viewing Conditions": ["45-degree Side View"],"Number of Generates": 80}. Execution Result: 80 targeted samples were generated. After intelligent filtering, 32 high-quality samples were added to G+.
[0069] Preferably, this also includes retraining and update strategies, with the following implementation steps: a) Version management: Use a dedicated MLOps platform to manage the dataset (G+ version), model code, training configuration, and trained weight files in a coherent manner. Every training iteration can be accurately reproduced. b) Periodic retraining: Set a plan (e.g., monthly), or automatically trigger a new round of model training when the G+ dataset grows to a certain size. c) Canary release and validation: Deploy both the new and old models simultaneously on the online system. Initially, only a small portion (e.g., 5%) of production traffic is diverted to the new model, while the rest is handled by the old model. Monitor the performance of the new model on this 5% traffic in real time (e.g., false negative rate, false positive rate) and compare it with the old model's performance during the same period. If the new model performs stably or better, gradually increase its traffic proportion (e.g., 20% → 50% → 100%) to complete the full deployment. If the new model performs poorly during the canary release period, immediately switch traffic back to the old model for a rapid rollback, ensuring the stability of the production environment.
[0070] In the above embodiments, the intelligent screening process filters and corrects the generated defect samples, significantly reducing the proportion of false "negative samples" and distorted defect samples, making the generated data closer to real-world working conditions. Expanding the training set with feedback-optimized generated defect samples significantly improves the accuracy, recall, and robustness of the detection and segmentation model even when defect samples are scarce. This method can be widely applied to various industrial products and defect types, possessing good scalability and industrial application value.
[0071] Example 2
[0072] Please see Figure 7 This embodiment provides a system architecture diagram for optimizing generated defect data based on intelligent screening.
[0073] As an example, the method for optimizing generated defect data based on intelligent screening as described in Embodiment 1 is used. The system includes: The defect generation module 700 is suitable for generating a candidate sample set containing defects based on input real normal samples, real defect samples and their corresponding defect masks, using a conditional generation model.
[0074] The intelligent screening module 710 is suitable for calculating the comprehensive quality score of each sample in the candidate sample set through a multi-dimensional quality assessment system, and for diverting the candidate samples to the high-quality generated dataset, the pending dataset, or directly eliminating them based on the comprehensive quality score and a preset threshold rule; after the samples in the pending dataset are manually reviewed based on preset review rules, qualified samples are added to the high-quality generated dataset.
[0075] The model training module 720 is suitable for mixing the high-quality generated dataset with real normal samples and real defect samples to construct a target training set for training, and using the target training set to train a preset defect detection model or defect segmentation model.
[0076] The closed-loop optimization module 730 is suitable for analyzing the performance of the defect detection model or defect segmentation model, identifying its weak points, and generating a directional regeneration instruction based on this and feeding it back to the defect generation step to initiate targeted data supplementation and model iterative optimization.
[0077] The model deployment module 740 is suitable for deploying a defect detection model or defect segmentation model that meets preset requirements based on the performance of the defect detection model or defect segmentation model.
[0078] It is not difficult to see that this embodiment is a system implementation corresponding to the first embodiment, and this embodiment can be implemented in conjunction with the first embodiment. The relevant technical details mentioned in the first embodiment are still valid in this embodiment, and will not be repeated here to reduce repetition. Accordingly, the relevant technical details mentioned in this embodiment can also be applied to the first embodiment.
[0079] It is worth mentioning that all modules involved in this embodiment are logical units. In practical applications, a logical unit can be a physical unit, a part of a physical unit, or a combination of multiple physical units. Furthermore, to highlight the innovative aspects of this invention, this embodiment does not introduce units that are not closely related to solving the technical problem proposed by this invention; however, this does not mean that other units are absent from this embodiment.
[0080] Example 3
[0081] Please see Figure 8 The present invention also provides an electronic device, including: a memory and a processor; the memory stores at least one program instruction; the processor loads and executes the at least one program instruction to implement the method for optimizing generated defect data based on intelligent screening provided in Embodiment 1.
[0082] The memory 702 and processor 701 are connected via a bus, which may include any number of interconnecting buses and bridges, connecting various circuits of one or more processors 701 and memory 702 together. The bus may also connect various other circuits, such as peripheral devices, voltage regulators, and power management circuits, which are well known in the art and therefore will not be described further herein. A bus interface provides an interface between the bus and the transceiver. The transceiver may be a single element or multiple elements, such as multiple receivers and transmitters, providing a unit for communicating with various other devices over a transmission medium. Data processed by processor 701 is transmitted over a wireless medium via an antenna, which further receives data and transmits it to processor 701.
[0083] Processor 701 is responsible for managing the bus and general processing, and can also provide various functions, including timing, peripheral interfaces, voltage regulation, power management, and other control functions. Memory 702 can be used to store data used by processor 701 during operation.
[0084] Example 4
[0085] This invention also proposes a storage medium storing a method for optimizing generated defect data based on intelligent screening. When the program for optimizing the generated defect data based on intelligent screening is executed by a processor, it implements the method steps for optimizing the generated defect data based on intelligent screening as described above. Since this storage medium adopts all the technical solutions of all the above embodiments, it has at least all the beneficial effects brought about by the technical solutions of the above embodiments, which will not be elaborated further here.
[0086] The above descriptions are merely embodiments of the present invention. Commonly known structures and characteristics are not described in detail here. Those skilled in the art are aware of all common technical knowledge in the field prior to the application date or priority date, are aware of all existing technologies in that field, and have the ability to apply conventional experimental methods prior to that date. Those skilled in the art can, based on the guidance provided in this application, improve and implement this solution in combination with their own capabilities. Some typical known structures or methods should not be obstacles for those skilled in the art to implement this application. It should be noted that those skilled in the art can make several modifications and improvements without departing from the structure of the present invention. These should also be considered within the scope of protection of the present invention, and will not affect the effectiveness of the implementation of the present invention or the practicality of the patent. The scope of protection claimed in this application should be determined by the content of its claims, and the specific embodiments described in the specification can be used to interpret the content of the claims.
Claims
1. A method for optimizing generated defect data based on intelligent screening, characterized in that, The optimization method includes: Step S1, Defect Generation Step: Based on the input real normal samples, real defect samples and their corresponding defect masks, a candidate sample set containing defects is generated using a conditional generation model; Step S2, Intelligent Screening Step: For each sample in the candidate sample set, calculate its comprehensive quality score through a multi-dimensional quality assessment system, and based on the comprehensive quality score and preset threshold rules, divert the candidate samples to the high-quality generated dataset, the pending dataset, or remove them directly; after the samples in the pending dataset are manually reviewed based on preset review rules, qualified samples are added to the high-quality generated dataset. Step S3, Model Training Step: Mix the high-quality generated dataset with real normal samples and real defect samples to construct a target training set for training, and use the target training set to train the preset defect detection model or defect segmentation model. Step S4, Closed-loop optimization step: Analyze the performance of the defect detection model or defect segmentation model, identify its weak points, and generate a targeted regeneration instruction based on this and feed it back to the defect generation step to initiate targeted data supplementation and model iterative optimization. Step S5, Model Deployment Step: Based on the performance of the defect detection model or defect segmentation model, deploy the defect detection model or defect segmentation model that meets the preset requirements online.
2. The method for optimizing generated defect data based on intelligent screening according to claim 1, characterized in that, The defect generation step specifically includes: Step S101, Condition Template Construction Sub-step: Establish a decoupled condition template containing product background conditions and defect type conditions. The condition template is used as a control signal for generating the model in the form of text, image or mask. Step S102, Controllable Generation Sub-step: Based on the condition template, using a generation model with a diffusion model or generative adversarial network as the backbone, diverse candidate samples are generated in batches by adjusting the defect intensity parameter, viewpoint perturbation parameter and illumination perturbation parameter. Step S103, Automated initial screening step: The generated candidate samples are automatically filtered to remove samples with image corruption, severe blurring and duplicate features, forming the candidate sample set.
3. The method for optimizing generated defect data based on intelligent screening according to claim 2, characterized in that, Step S102 further includes a training step for the generative model: if a diffusion model is used, the product background conditions and defect type conditions are used as decoupling constraints, and standard noise regression loss is used for training, and regional weighting is applied to small defect areas; if an adversarial generative network is used, it is first pre-trained on normal samples, and then fine-tuned with a small number of defect samples. The training process monitors convergence and diversity using FID and LPIPS metrics.
4. The method for optimizing generated defect data based on intelligent screening according to claim 1, characterized in that, Step S1 further includes: cleaning and standardizing the input real normal samples, real defect samples and their corresponding defect masks to generate a structured data list, including: a unified image color space and a resolution of 512. 512, record the scaling factor; perform binarization and geometric correction on the defect mask to unify it to the same coordinate system; the structured data list is in JSON format, recording image number, product name, defect classification, data division method, mask path and working condition metadata, for subsequent traceability and statistics.
5. The method for optimizing generated defect data based on intelligent screening according to claim 1, characterized in that, The intelligent screening steps specifically include: Step S201, Multi-dimensional Feature Extraction and Scoring Sub-step: Utilizing a pre-trained feature extraction network, deep feature extraction is performed on the candidate sample set, and four-dimensional quality sub-scores are calculated in parallel, including: Authenticity Score: The feature distribution distance between the generated sample and the real sample is calculated using the FID or KID algorithm, and the feature distribution distance is converted into an authenticity score based on a preset authenticity score calculation formula; Defect Reasonableness Score: By analyzing the geometric morphological and texture features of the defect region in the candidate sample and matching them with prior knowledge of this type of defect, a defect reasonableness score is obtained. The geometric morphological features include the aspect ratio, area, perimeter, and roundness of the defect region; Usability Score: By inputting the candidate sample into a pre-trained benchmark defect detection model, a usability score is obtained based on the defect recognition confidence output by the model; Mask Consistency Score: By calculating the edge alignment and contour matching degree between the defect image of the candidate sample and its corresponding mask, a mask consistency score is obtained. Step S202, Comprehensive Scoring and Decision Sub-step: The authenticity score, defect rationality score, usability score and mask consistency score are fused by a weighted summation function with preset weights to obtain the comprehensive quality score of each sample; and the samples are diverted to high-quality generated datasets, pending datasets for review, or low-quality datasets that are directly eliminated, based on preset high and low thresholds.
6. The method for optimizing generated defect data based on intelligent screening according to claim 5, characterized in that, The mathematical expression for the weighted summation function with the preset weights is: ; In the formula, The weight parameters for each dimension satisfy... , , To score for authenticity, To score the reasonableness of the defect, Rate usability For mask consistency scoring, This is used to determine the overall quality score.
7. The method for optimizing generated defect data based on intelligent screening according to claim 5, characterized in that, The step of supplementing qualified samples from the pending dataset into the high-quality generated dataset after manual review based on preset review rules includes: Obtain authenticity score, defect reasonableness score, usability score, and mask consistency score; The authenticity score, defect reasonableness score, usability score, and mask consistency score are compared with their corresponding review thresholds. When three of the scores are greater than or equal to the preset review thresholds, the samples in the pending dataset are upgraded to high-quality samples and added to the high-quality generated dataset. If and only if the authenticity score and the defect reasonableness score are greater than or equal to the preset corresponding review threshold, the sample in the pending dataset is retained as a pending sample and will be re-evaluated in the next closed-loop iteration. If only one score is greater than or equal to the preset review threshold, the sample in the pending dataset will be downgraded to a low-quality sample and removed.
8. The method for optimizing generated defect data based on intelligent screening according to claim 1, characterized in that, The model training steps specifically include: Step S301, Hybrid Training Set Construction Sub-step: The high-quality generated dataset, real defect sample set and real normal sample set are mixed according to a preset ratio, and rare defect categories or small-scale defects are upsampled. At the same time, conformal data augmentation operations are applied to form the target training set. Step S302, Targeted Training Sub-step: Train an object detection or instance segmentation network using the target training set; during training, apply a higher weight to the loss calculation of defect region pixels than to the background region, and dynamically adjust the weight of samples with pseudo-masks from the generation step in the overall loss function based on their mask confidence.
9. The method for optimizing generated defect data based on intelligent screening according to claim 1, characterized in that, The closed-loop optimization steps specifically include: Step S401, Performance Diagnosis and Analysis Sub-step: After the defect detection model or defect segmentation model is deployed in the validation set or real production environment, the false negative rate and false positive rate are statistically analyzed under different defect categories, different defect intensities, different product models and different environmental conditions to locate the weak links in the model performance. Step S402, Targeted Instruction Generation Sub-step: The weak link is transformed into a specific data generation instruction that can be executed by the defect generation step. The instruction at least explicitly specifies the target product, the target defect type, the target defect intensity range, and the scenario conditions that need to be enhanced. Step S403, Iterative Update Sub-step: Based on the instruction, start a new round of defect generation and intelligent screening, supplement the newly generated high-quality samples to the high-quality generated dataset, and trigger the periodic retraining and version update of the model.
10. A system for optimizing generated defect data based on intelligent screening, wherein the system is implemented using the method for optimizing generated defect data based on intelligent screening as described in any one of claims 1-9, characterized in that, The system includes: The defect generation module is suitable for generating a candidate sample set containing defects based on input real normal samples, real defect samples and their corresponding defect masks, using a conditional generation model. The intelligent screening module is applicable to each sample in the candidate sample set, which calculates its comprehensive quality score through a multi-dimensional quality assessment system, and based on the comprehensive quality score, the candidate samples are diverted to the high-quality generated dataset, the pending dataset, or directly eliminated based on the preset threshold rules; the samples in the pending dataset are manually reviewed based on preset review rules, and qualified samples are added to the high-quality generated dataset. The model training module is suitable for mixing the high-quality generated dataset with real normal samples and real defect samples to construct a target training set for training, and using the target training set to train a preset defect detection model or defect segmentation model. The closed-loop optimization module is suitable for analyzing the performance of the defect detection model or defect segmentation model, identifying its weak points, and generating targeted regeneration instructions based on these to feed back to the defect generation step, so as to initiate targeted data supplementation and model iterative optimization. The model deployment module is suitable for deploying defect detection models or defect segmentation models that meet preset requirements based on the performance of the defect detection model or defect segmentation model.