Industrial part defect sample accurate generation method based on conditional diffusion model

By using a conditional diffusion model-based approach, combined with physical constraint noise scheduling, multi-scale feature coupling, and dual-domain feedback optimization, the quality and diversity issues of defect sample generation were addressed, thereby improving the performance of the industrial part defect detection model.

CN121280441BActive Publication Date: 2026-02-17SHANDONG UNIV OF SCI & TECH
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202511843781.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-12-09
Publication Date
2026-02-17
Estimated Expiration
2045-12-09

AI Technical Summary

Technical Problem

Existing technologies struggle to generate high-quality defect samples with realistic physical characteristics, precise multi-scale control, and continuous quality assurance, which limits the training effectiveness and generalization ability of deep learning-based industrial defect detection models.

Method used

A closed-loop collaborative system is constructed using a conditional diffusion model-based approach. This system employs physical constraint noise scheduling, multi-scale feature coupling, dual-domain feedback optimization, and adaptive weight adjustment to generate samples that conform to the physical process characteristics of defects. The system is then used for quality assessment and dynamic adjustment.

Benefits of technology

The generated defect samples are highly consistent with real defects, which improves the recognition accuracy and recall rate of the detection model, especially the detection capability of rare defect types is significantly improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121280441B_ABST
    Figure CN121280441B_ABST
Patent Text Reader

Abstract

The application discloses an industrial part defect sample accurate generation method based on a conditional diffusion model, belongs to the field of image processing and artificial intelligence, and comprises four deep coupling modules of physical constraint noise scheduling, multi-scale feature coupling, double-domain feedback optimization and self-adaptive weight adjustment, forms a closed-loop cooperative system, converts a defect physical formation mechanism into a dynamic noise scheduling strategy, establishes deep interaction of conditional information and a feature map at multiple levels of a diffusion network, realizes quality closed-loop optimization through double evaluation in a pixel domain and a frequency domain, dynamically adjusts training weights according to defect scarcity, the defect sample generated by the method has real physical characteristics, multi-scale accurate control is realized, a quality guarantee closed loop is established, the data imbalance problem is effectively solved, and the performance of an industrial defect detection model is significantly improved.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the field of image processing and artificial intelligence, in particular to an industrial part defect sample accurate generation method based on a conditional diffusion model. BACKGROUND

[0002] Industrial part quality detection is a key link of intelligent manufacturing. With the development of deep learning technology, automatic defect detection methods based on convolutional neural networks are widely used in industrial scenarios. However, these methods rely heavily on a large number of labeled defect samples for model training. In actual production, the proportion of qualified products usually exceeds 95%, and defect samples are extremely scarce, and the number distribution of different types of defects is seriously uneven. For example, on a certain automobile part production line, surface scratch defect samples can reach thousands, while crack defect samples are only tens. This data imbalance leads to a significant decrease in the recognition accuracy of the detection model for the few-sample defect types.

[0003] Traditional data augmentation methods mainly include geometric transformation and color disturbance, such as random rotation, scaling, brightness adjustment, etc. These methods can only perform simple transformations on existing samples and cannot generate new defect morphologies, making it difficult to increase the substantive diversity of defect samples. Defect sample generation methods based on generative adversarial networks to some extent alleviate this problem. CN119180774A discloses an industrial defect sample generation method, which extracts defect features through a CLIP model, compresses the feature vector using a multilayer perceptron, and generates local defects in a diffusion model combined with a mask mechanism. This method uses a Bezier curve to generate an arbitrary shape mask, making the diffusion model focus on the defect area rather than the background. However, this method has the following shortcomings:

[0004] First, the defect generation lacks physical mechanism guidance. This method does not consider the differences in the physical formation process of different defect types, uses fixed linear or cosine noise scheduling, and cannot simulate the crack burst caused by stress concentration, progressive damage caused by wear, and other different physical processes. The generated defect samples may look similar, but lack the physical evolution characteristics of real defects, which may lead to the detection model learning false patterns.

[0005] Second, the feature encoding method is single. This method only uses the CLIP model to extract visual features and fails to fully utilize the multi-level semantic information of defects. Defects contain not only macro-level category semantics but also micro-level morphological features and edge details, and single encoding cannot fully express the multi-scale characteristics of defects. In addition, the injection method of conditional information is simple, and a deep coupling is not established at multiple scale levels of the diffusion model, limiting the accuracy of conditional guidance.

[0006] Third, the lack of quality closed-loop verification. The method does not establish a comprehensive consistency evaluation mechanism for the generated sample and the real defect, and cannot judge whether the generated sample conforms to the statistical distribution of the real defect in multiple dimensions such as texture details and spectral characteristics. The generation process is open-loop, and the model parameters cannot be dynamically adjusted according to the quality evaluation results, resulting in difficulty in continuously optimizing the generation quality.

[0007] Fourth, the training strategy is not suitable for data imbalance. The method uses the same training weight for all defect types, and does not focus on strengthening rare defect types, resulting in insufficient generation quality of small sample defects and inability to effectively expand the training data of rare categories.

[0008] Therefore, the prior art is difficult to generate high-quality defect samples with real physical characteristics, multi-scale precise control and continuous quality assurance, which restricts the training effect and generalization ability of the industrial defect detection model based on deep learning. SUMMARY

[0009] In view of the shortcomings of the prior art, the present application provides an industrial part defect sample precise generation method based on a conditional diffusion model, aiming to solve the technical problems of lack of physical mechanism guidance in defect sample generation, single feature encoding, lack of closed-loop quality verification and unsuitable training strategy for data imbalance.

[0010] To achieve the above invention purposes, the present application adopts the following technical solutions:

[0011] The present application proposes an industrial part defect sample precise generation method based on a conditional diffusion model. The method first acquires reference samples containing defect features and normal industrial part images, and performs multi-level feature extraction on the reference samples to generate conditional encoding information containing defect type semantics, morphological features and material texture. Then, based on the physical formation mechanism of the defect, a physical constraint noise scheduling strategy is constructed, the noise variance coefficient at each time in the forward diffusion process is dynamically adjusted according to the defect type, and adaptive noise is added to the normal industrial part image to generate a noise image sequence that conforms to the physical process characteristics of the defect. In the reverse diffusion denoising process, through a multi-scale feature coupling mechanism, the conditional encoding information is cross-attention fused with the feature maps of different depth layers of the U-Net backbone network, and based on the spatial prior distribution of the defect-prone area, a position-sensitive constraint is imposed on the denoising prediction result. The generated defect sample is simultaneously subjected to multi-scale structural similarity evaluation in the pixel domain and Fourier spectrum consistency evaluation in the frequency domain, and the deviation degree of the generated sample from the real defect sample in terms of texture details and spectral distribution is calculated. According to the deviation degree, the denoising parameters and the conditional encoding weight of the diffusion model are dynamically adjusted through a dual-domain feedback mechanism to form a closed-loop optimization. At the same time, based on the scarcity of each type of defect sample, the weight coefficients of different defect types in the training loss function are adaptively adjusted.

[0012] The core innovation of the present application is to construct four deeply coupled modules of physical constraint noise scheduling, multi-scale feature coupling, dual-domain feedback optimization and adaptive weight adjustment, forming a closed-loop collaborative system. The physical constraint noise scheduling module converts the physical formation mechanism of defects into dynamic constraints of the diffusion process, so that the generated samples have real physical evolution characteristics. The multi-scale feature coupling module establishes deep interaction between conditional information and feature maps at multiple levels of the diffusion network, achieving precise defect morphology control. The dual-domain feedback optimization module verifies the consistency of the generated samples in the pixel domain and the frequency domain, and evaluates the quality of the generated samples comprehensively, and adjusts the model parameters according to the evaluation results, forming a closed loop of continuous quality improvement. The adaptive weight adjustment module dynamically adjusts the training weight according to the scarcity of the defect type, and focuses on strengthening the generation ability of the few-sample defects. The four modules form a close parameter-level and state-level coupling, the output of the previous module is directly used as the key input of the next module, and the evaluation results of the post-module are used to adjust the parameters of the pre-module, realizing mutual promotion, superposition of efficiency and collaborative optimization among modules.

[0013] Compared with the prior art, the present application has the following beneficial effects:

[0014] First, the generated samples have real physical characteristics. Through the physical constraint noise scheduling strategy, the physical formation mechanism of defects is deeply embedded in the diffusion process, and different noise addition strategies are adopted for different physical processes such as stress mutation and gradual accumulation, so that the generated defect samples are highly consistent with real defects in micro-morphology and evolution characteristics. Experiments show that the similarity of the generated crack defects in edge sharpness and propagation path is improved by more than 15%, and the fitting degree of the wear defects in the gradual texture characteristics is improved by more than 20%.

[0015] Second, multi-scale precise control is achieved. Through the multi-scale feature coupling mechanism, cross-attention fusion of conditional information and feature maps is established at the encoding, intermediate and decoding stages of the U-Net backbone network, combined with the spatial prior distribution of the defect-prone area for position-sensitive constraint, to achieve precise and controllable generation of defect types, morphology and spatial position. Experiments show that the spatial position accuracy of the generated defects is improved by 12%, and the morphology boundary sharpness is improved by 18%.

[0016] Third, a quality closed-loop guarantee mechanism is established. Through the dual-domain feedback optimization module, the quality of the generated samples is evaluated in the pixel domain and the frequency domain at the same time, the deviation degree of texture details and spectral distribution is calculated, and the denoising parameters and conditional coding weights of the diffusion model are dynamically adjusted according to the deviation degree, forming a closed loop of continuous quality improvement. Experiments show that after 3 rounds of closed-loop optimization, the comprehensive similarity between the generated samples and the real defects is improved from 78% to 92%.

[0017] Fourth, solve the problem of data imbalance. Through the adaptive weight adjustment module, the training loss weight is dynamically adjusted according to the scarcity of each type of defect, and the generation quality of the few-sample defects is highlighted. Experiments show that for the scarce defect types with less than 50 samples, the quality of generated samples is improved by more than 25%, effectively expanding the training data of scarce categories, and the recognition accuracy of the detection model for few-sample defects is improved by 18%.

[0018] Fifth, improve the performance of the detection model. The high-quality defect samples generated by the present application are used to expand the training data set. In the task of industrial part defect detection, the average precision of the detection model is improved by 8.5%, the recall rate is improved by 10.2%, and the detection ability of the rare defect type is significantly improved, and the F1 score is improved by more than 14%. BRIEF DESCRIPTION OF DRAWINGS

[0019] Figure 1 It is the overall flowchart of the method of the present application.

[0020] Figure 2 It is the structure diagram of the physical constraint noise scheduling module.

[0021] Figure 3 It is the structure diagram of the multi-scale feature coupling module.

[0022] Figure 4 It is the structure diagram of the dual-domain feedback optimization module.

[0023] Figure 5 It is the work flowchart of the adaptive weight adjustment module.

[0024] Figure 6 It is the interaction relationship diagram of the four-module closed-loop cooperative system. DETAILED DESCRIPTION

[0025] Please refer to the accompanying Figures 1-6 , the present application will be further described in detail below in combination with the drawings and specific embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application, and are not used to limit the present application.

[0026] Referring to Figure 1 , the present application provides an industrial part defect sample accurate generation method based on a conditional diffusion model, which includes the following core steps:

[0027] Step S1: Multi-level conditional encoding, obtain reference samples containing defect features and normal industrial part images. The reference samples are defect industrial part images collected in the real production environment, containing various defect types such as cracks, scratches, pits, and pores. The normal industrial part images are defect-free qualified product images, which are used as the background basis for subsequent generation process. The reference samples are positioned and cropped for defect area, obtaining defect samples. The positioning method can use manual annotation or automatic segmentation algorithm, and the size of the cropped defect samples is uniform as 256x256 pixels.

[0028] The defect samples are input into a multi-modal feature encoder for feature extraction. In an embodiment of the present application, the multi-modal feature encoder uses a visual-linguistic pre-trained model CLIP, which is pre-trained on a large-scale image-text pair through contrastive learning, and has strong visual semantic understanding ability. The CLIP model includes an image encoder and a text encoder, and the image encoder uses the ViT architecture to encode the defect samples into a 768-dimensional joint feature vector. This vector contains both visual semantic and geometric structure information, and can fully express the features of the defect.

[0029] The joint feature vector is hierarchically decomposed to layer the macro defect category features and micro morphological features. Specifically, through separable convolution and multi-head attention mechanism, the 768-dimensional feature vector is decomposed into two subspaces: a macro category feature subspace of 384 dimensions and a micro morphological feature subspace of 384 dimensions. The macro category feature expresses the semantic category of the defect, and the micro morphological feature expresses the edge sharpness, texture roughness, and other detailed features of the defect. Through a learnable cross-attention module, the hierarchically encoded features are associated and mapped with the material surface texture features. The material surface texture features are extracted by gray level co-occurrence matrix analysis on the normal industrial part images, including contrast, correlation, energy, and homogeneity texture parameters. The cross-attention module calculates the correlation weight between the defect features and the texture features, generating the fused conditional encoding information with a dimension of 512.

[0030] Step S2: Physical constraint noise scheduling, refer to Figure 2 , construct a physical constraint noise scheduling module 1. This module dynamically adjusts the noise addition strategy in the forward diffusion process according to the physical formation mechanism of the defect.

[0031] Firstly, the physical formation process corresponding to the defect type is identified. The formation mechanism of different types of defects is significantly different. Crack type defects are usually caused by stress concentration, and the formation process is characterized by stress mutation, and the crack rapidly expands in a short time. Scratch type defects are caused by friction or collision, and the formation process is relatively rapid but relatively uniform. Wear type defects are caused by long-term use, and the formation process is characterized by gradual accumulation and gradual deepening of damage. Pore type defects are caused by poor gas discharge during the casting process, and the formation process has randomness and suddenness. According to these physical properties, the defects are divided into three modes of stress mutation type, gradual accumulation type and mixed type.

[0032] For stress mutation type defects such as cracks and pores, a high-frequency noise rapid injection strategy is adopted in the initial stage of forward diffusion to simulate the instantaneous change caused by stress mutation. Specifically, in the initial stage of diffusion steps , the noise variance coefficient is set to a large value, preferably 0.02 to 0.05, so that the image quickly transforms to the noise state. In the later stage , a low-frequency noise fine adjustment is adopted, and the noise variance coefficient is gradually reduced to 0.0001 to 0.001 to simulate the refinement process of the crack propagation path. High-frequency noise reflects the macro effect of stress mutation, and low-frequency noise depicts the micro details of the crack edge.

[0033] For gradual accumulation type defects such as wear and corrosion, a time accumulation type noise superposition mode is adopted. Specifically, the noise variance coefficient increases linearly or logarithmically with time step to simulate the gradual accumulation process of damage. In the preferred embodiment, a logarithmic growth function is adopted:

[0034] ,

[0035] wherein, is the noise variance coefficient of the th step, is the minimum noise variance, which is 0.0001, is the maximum noise variance, which is 0.02, is the current diffusion step, is the total diffusion step, preferably 1000. This formula makes the noise grow slowly at first and then accelerate, which is consistent with the gradual accumulation characteristics of wear damage.

[0036] For mixed type defects such as scratches, a segmented noise scheduling strategy is adopted. In the early stage of diffusion, the rapid formation of scratches is simulated, and a larger noise variance coefficient is adopted; in the middle and later stages of diffusion, the refinement of the scratch edge is simulated, and the noise variance coefficient is gradually reduced to By switching noise addition modes in segments, the evolution process of the generated samples is matched with the actual defect formation process.

[0037] Based on the noise characteristic requirements of different defect types and diffusion stages, a time-varying noise variance scheduling function is established. This function adaptively scales according to the physical timescale parameters of defect formation, ensuring that the temporal characteristics of noise addition match the actual defect evolution process. Physical timescale parameters... Characterizing the rate of defect formation, crack-like defects Smaller, preferably 0.1, wear-related defects The value is relatively large, preferably 5.0. The time-varying noise variance scheduling function is:

[0038] ,

[0039] in, The basic noise variance coefficient, This is a parameter representing the physical time scale. (Through...) The adjustment can flexibly adapt to the physical evolution rate of different defect types.

[0040] Adaptive noise addition is applied to images of normal industrial parts to generate a sequence of noise maps that conform to the physical characteristics of defects. The forward diffusion process follows a Markov chain. noise map of the step Through Gaussian noise is added to generate:

[0041] ,

[0042] in, For the first Step images, For the first The noise variance coefficient of the step. Standard Gaussian noise, obeying distributed, It is the identity matrix. This process is performed iteratively. Increase from 1 to Finally, a noise map sequence is obtained. Due to the adoption of a physically constrained noise scheduling strategy, the evolutionary characteristics of this sequence are highly consistent with the formation process of real defects.

[0043] Step S3: Multi-scale feature coupling, refer to Figure 3 A multi-scale feature coupling module 2 is constructed. In the backdiffusion denoising process, this module deeply integrates conditional coding information with multiple scale levels of the U-Net backbone network to achieve precise defect morphology control.

[0044] The U-Net backbone network adopts an encoder-decoder architecture, including 4 down-sampling stages and 4 up-sampling stages. In the encoding stage, the conditional encoding information is projected into the same dimensional space as the feature map of each scale through a learnable linear mapping layer. The initial dimension of the conditional encoding information is 512, which is projected to 64 dimensions at the 1st scale level, to 128 dimensions at the 2nd scale level, to 256 dimensions at the 3rd scale level, and to 512 dimensions at the 4th scale level. The projection is realized through a fully connected layer and a ReLU activation function, ensuring that the conditional information can be effectively fused with the feature maps of different depths.

[0045] At each scale level, the correlation weight of the conditional feature and the current layer feature is calculated through a cross-attention mechanism. The cross-attention mechanism takes the current layer feature as the query and the conditional feature as the key and value, calculates the attention score between them, and generates a scale-adaptive conditional guidance signal. Specifically, let the feature map of the i-th layer be , the projected conditional feature be , and the cross-attention calculation be:

[0046] ,

[0047] wherein, is the query matrix, is the key matrix, is the value matrix, is the learnable projection matrix, is the dimension of the key vector, and , is the attention output, representing the guidance signal of the conditional feature to the current layer feature. Through cross-attention, the conditional information can adaptively focus on the spatial region related to the defect feature, enhancing the pertinence of conditional guidance.

[0048] In the decoding stage, the conditional guidance signal generated in the encoding stage is element-wise weighted and fused with the up-sampling feature of the corresponding scale. The fusion operation adopts a gating mechanism to dynamically adjust the fusion proportion of the conditional signal according to the activation strength of the current feature ,

[0049] wherein, is the up-sampling feature of the i-th layer, is the corresponding conditional guidance signal, is the gating weight matrix, is the Sigmoid activation function, is the element-wise multiplication, is the fused feature. The gating mechanism makes the fusion process adaptive, avoiding excessive interference of the conditional signal to the feature.

[0050] ​​In the decoding path, a position-sensitive convolution layer is embedded to learn the spatial prior distribution of defect-prone areas. Defects of industrial parts often concentrate in specific areas, such as welding joints, corner positions, stress concentration areas, etc. The position-sensitive convolution layer learns the spatial distribution pattern of defects in the training data to generate a position weight matrix , which represents the prior probability of defects occurring at each spatial position. When denoising prediction is performed, the position weight matrix is multiplied element-wise with the prediction result to enhance the prediction strength in the prone area and suppress the noise in the non-prone area. Specifically, the denoised prediction result after position modulation is:

[0051] ,

[0052] wherein, is the noise map at the current time, is the denoised result predicted by the denoising network, is the position weight matrix, is the final prediction after position modulation. Through position-sensitive constraints, the generated defects are more consistent with the actual spatial distribution rules, improving the authenticity of the generated samples.

[0053] Step S4: dual-domain consistency evaluation, referring to Figure 4 , a dual-domain feedback optimization module 3 is constructed. This module simultaneously performs quality evaluation in the pixel domain and the frequency domain for the generated defect samples, calculates the deviation degree of the generated samples from the real defect samples, and dynamically adjusts the model parameters through the feedback mechanism.

[0054] In the pixel domain, multi-scale structural similarity evaluation is performed. A Gaussian pyramid is constructed for the generated samples and the real defect samples to obtain image representations at multiple scale levels. The Gaussian pyramid is generated by Gaussian blurring and downsampling of the image. In this embodiment, a 3-layer pyramid is constructed with resolutions of 256x256, 128x128 and 64x64. At each scale level, the brightness similarity, contrast similarity and structural similarity between the generated samples and the real samples are calculated. The structural similarity index SSIM is defined as:

[0055] ,

[0056] wherein, is the generated sample, is the real sample, are the average brightness of , respectively, are the standard deviations of , respectively, is the covariance of , and is a constant to avoid division by zero, , , For 8-bit grayscale images, the pixel value range is [0, 255], and the SSIM value range is [-1, 1]. The larger the value is, the higher the similarity is.

[0057] The SSIM values of each scale level are weighted and fused to generate a multi-scale structural similarity index MS-SSIM:

[0058] ,

[0059] wherein, is the number of pyramid layers, and is 3, is the SSIM value of the i-th layer, is the weight coefficient of the i-th layer, When the MS-SSIM value is lower than a preset threshold value 0.85, it is determined that the texture details of the generated sample deviate from the real defect, and the pixel domain deviation degree is recorded as

[0060] ,

[0061] In the frequency domain, Fourier spectrum consistency evaluation is performed. Two-dimensional discrete Fourier transform is performed on the generated sample and the real defect sample respectively to obtain the spectrum amplitude and phase. The two-dimensional discrete Fourier transform is defined as:

[0062] ,

[0063] wherein, is a spatial domain image, is a frequency domain representation, is the width and height of the image, is a frequency domain coordinate, is an imaginary unit. The spectrum amplitude is , and the phase is .

[0064] The spectrum distribution difference of the generated sample and the real sample in the high frequency component and the low frequency component is calculated. The spectrum center corresponds to the low frequency component, reflecting the overall outline and large-scale structure of the image; the spectrum edge corresponds to the high frequency component, reflecting the edge details and texture of the image. The frequency domain is divided into a low frequency region and a high frequency region, the low frequency region is the region within the spectrum center radius , and the high frequency region is the region beyond the radius . The low frequency component difference and the high frequency component difference are calculated respectively:

[0065] ​​​​​ ,

[0066] ,

[0067] wherein, are the frequency spectrum of the generated sample and the real sample respectively, are the coordinate set of the low-frequency region and the high-frequency region respectively, is the number of pixels in the region. When the high-frequency component difference exceeds the threshold value 0.15 or the low-frequency component difference exceeds the threshold value 0.10, it is determined that the frequency spectrum characteristics of the generated sample deviate from the real distribution, and the frequency domain deviation degree :

[0068] ,

[0069] wherein, the high-frequency component weight 0.6 is greater than the low-frequency component weight 0.4, because the edge details of the defect have a greater impact on the detection performance.

[0070] Step S5: dual-domain feedback optimization, according to the pixel domain deviation degree and the frequency domain deviation degree , a comprehensive deviation degree index is generated:

[0071] ,

[0072] If the comprehensive deviation degree exceeds the threshold value 0.20, a feedback adjustment mechanism is started. Analyze the main source of the deviation degree, if , it indicates that the pixel domain deviation is dominant, and the texture details do not match; if , it indicates that the frequency domain deviation is dominant, and the spectral characteristics do not conform.

[0073] For the case where the pixel domain deviation is dominant, increase the fusion weight of the conditional coding information in the multi-scale feature coupling. Specifically, the fusion coefficient of the cross-attention output is increased from 0.5 to 0.7, enhancing the guiding role of the conditional information in the denoising process, so that the texture details of the generated sample are closer to the real defect. At the same time, the learning rate of the conditional encoder is adjusted from the initial 0.0001 to 0.0003, accelerating the optimization of the conditional features.

[0074] For the case where the frequency domain deviation is dominant, adjust the activation strength of the high-frequency feature extraction branch in the denoising network. In the decoding stage of the U-Net, increase the channel number of the high-frequency feature extraction layer from the original 128 channels to 192 channels, enhancing the expression ability of the network to high-frequency details. At the same time, add a high-frequency consistency loss term in the loss function, with a weight of 0.3, to make the generated sample by the network more close to the real defect in the high-frequency component of the spectrum.

[0075] The adjusted parameters are applied to the next round of diffusion denoising process, the defect samples are regenerated and the deviation degree is evaluated. If the deviation degree decreases, it indicates that the adjustment is effective, and the new parameters are continued to be used; if the deviation degree does not decrease or increases, the last round of parameters is rolled back and other adjustment strategies are tried. Through iterative feedback optimization, the deviation degree between the generated samples and the real defects is gradually reduced, forming a closed loop with continuously improved quality. In a preferred embodiment, the maximum number of iterations is set to 5, and after each iteration, the comprehensive deviation degree is evaluated, and when the maximum number of iterations is reached, the optimization is stopped. Experiments show that after 3 to 5 rounds of closed-loop optimization, the comprehensive deviation degree can be reduced from 0.22 to 0.08, and the quality of the generated samples is significantly improved.

[0076] Step S6: adaptive weight adjustment, referring to Figure 5 , an adaptive weight adjustment module 4 is constructed. According to the scarcity of each type of defect sample, the weight coefficients of different defect types in the training loss function are dynamically adjusted, and the generation ability of the few-sample defects is emphasized.

[0077] The number distribution of each type of defect sample in the training data set is counted. Assuming that the data set contains defect types, the number of samples of the th defect type is . The scarcity index of each defect type is calculated as :

[0078] ,

[0079] wherein is the number of the category with the largest number of samples among all defect types. The value of the scarcity ranges from , and the larger the value is, the more scarce the defect is. For example, in a certain data set, the number of crack defect samples is , and the number of scratch defect samples is , then the scarcity of crack is , and the scarcity of scratch is .

[0080] Based on the scarcity index, the training loss weight of each type of defect is allocated as :

[0081] ,

[0082] wherein is a weight amplification coefficient, preferably 2.0. For defect types with sufficient number of samples, is close to 0, is close to 1; for defect types with scarce number of samples, is close to 1, The maximum is 3.0, which significantly improves its importance in training.

[0083] In the training process, the loss function adopts a weighted form:

[0084] ,

[0085] wherein, is the generation loss of the th defect type, which measures the difference between the generated sample and the real sample by mean square error or KL divergence. Through the weighted loss, the model pays more attention to the scarce defect type during training, increases its optimization effort, and improves the generation quality.

[0086] In the middle and later stages of training, the weight coefficient is dynamically adjusted according to the generation quality of each defect type. Specifically, every certain training round, the quality of each defect type is evaluated, and the comprehensive deviation degree is calculated. If the comprehensive deviation degree of a certain defect type is still high, it indicates that the generation quality is not up to standard, and the weight coefficient of this type is further increased:

[0087] ,

[0088] This adjustment mechanism makes the weight dynamically respond to the generation quality, and applies more optimization pressure to the defect type with poor quality, ensuring balanced improvement of the generation quality of all defect types. Experiments show that after adaptive weight adjustment, the generation quality of the scarce defect type is improved by more than 25%, and the comprehensive deviation degree is reduced from 0.35 to 0.12, effectively solving the data imbalance problem.

[0089] Referring to Figure 6 , the physical constraint noise scheduling module 1, the multi-scale feature coupling module 2, the dual-domain feedback optimization module 3, and the adaptive weight adjustment module 4 form a deeply coupled closed-loop collaborative system.

[0090] The physical constraint noise scheduling module 1 generates a noise map sequence that conforms to the physical evolution characteristics according to the defect type, which is used as the input of the multi-scale feature coupling module 2. The multi-scale feature coupling module 2 deeply fuses the conditional encoding information and the noise map sequence in the reverse diffusion denoising process to generate a preliminary defect sample. This sample enters the dual-domain feedback optimization module 3 for quality evaluation, and the deviation degrees in the pixel domain and the frequency domain are calculated. The dual-domain feedback optimization module 3 adjusts the noise variance coefficient of the physical constraint noise scheduling module 1 and the fusion weight of the multi-scale feature coupling module 2 according to the deviation degrees, forming a closed-loop feedback at the parameter level. After feedback adjustment, the module 1 and the module 2 regenerate the defect sample, further reducing the deviation degree.

[0091] The adaptive weight adjustment module 4 dynamically adjusts the training loss weight according to the scarcity and generation quality of each type of defect. The weight coefficient, as a global parameter, affects the training target of the physical constraint noise scheduling, multi-scale feature coupling and dual-domain feedback optimization. Through weight adjustment, the scarcity defect type obtains higher priority in training, and the three modules obtain stronger gradient signals when optimizing the scarcity defect, accelerating convergence.

[0092] The following synergistic effects are achieved among the four modules:

[0093] Mutual promotion: The physical constraint noise scheduling provides a data basis that meets the physical characteristics for subsequent modules, the multi-scale feature coupling realizes precise control, the dual-domain feedback optimization guarantees quality, and the adaptive weight adjustment solves data imbalance. The four modules complement each other and jointly improve the generation quality.

[0094] Superimposed synergies: The improvement effect of using any module alone is limited, but after the four modules are used together, the effect shows nonlinear growth. Experiments show that using only the physical constraint noise scheduling improves the generation quality by 8%, adding the multi-scale feature coupling improves it to 22%, adding the dual-domain feedback optimization improves it to 35%, and finally adding the adaptive weight adjustment improves it to 48%, far exceeding the sum of the individual effects of each module.

[0095] Conflict resolution: There is a contradiction between the diversity and authenticity of generated samples. Excessive emphasis on authenticity may reduce diversity. The invention introduces diversity through physical constraint noise scheduling and guarantees authenticity through dual-domain feedback optimization, finding a balance between the two and achieving a synergistic improvement in diversity and authenticity.

[0096] Adaptive adjustment: The four modules dynamically adjust parameters during training, adaptively optimize according to generation quality and data distribution, and do not require human intervention, forming an intelligent closed-loop system.

[0097] Example 1, crack defect generation:

[0098] Crack defect samples of bearing parts are generated using the method of the invention. The training data set contains 45 real crack samples and 500 normal bearing images. Cracks belong to stress mutation type defects. In the physical constraint noise scheduling, high-frequency noise is injected quickly in the early stage, and the noise variance coefficient is . The conditional encoding information extracts the edge sharpness and expansion direction features of the crack. The multi-scale feature coupling establishes cross-attention at the 3 scale levels of U-Net, and the position-sensitive convolution learns the crack-prone areas of the bearing inner ring and raceway. After generating 100 crack samples, the dual-domain feedback optimization module evaluates and finds that the high-frequency component difference , exceeding the threshold 0.15, the feedback adjustment is started, the number of channels of the high-frequency feature extraction branch is increased to 192, after 3 rounds of optimization, , the comprehensive deviation is reduced to 0.11, and the comprehensive deviation is reduced from 0.24 to 0.09. The generated crack sample is consistent with the real crack in edge sharpness and expansion path, and after expanding the training data, the recognition accuracy of the detection model for the crack is improved from 72% to 89%, and the recall rate is improved from 65% to 85%.

[0099] Example 2, wear defect generation:

[0100] The wear defect sample of the gear part is generated by using the method of the application. The training data set contains 30 real wear samples and 600 normal gear images. Wear belongs to the progressive cumulative type of defects. In the physical constraint noise scheduling, the logarithmic growth time cumulative noise superposition is adopted, and the noise variance coefficient is increased from to . The conditional coding information extracts the progressive texture features and roughness changes of wear. The multi-scale feature coupling fuses the conditional information with the four scale levels of U-Net, and the position sensitive convolution learns the easy wear area of the tooth surface. After generating 80 wear samples, the dual-domain feedback optimization module evaluates that the pixel domain deviation , the fusion weight of the conditional coding information is increased to 0.7, and the learning rate of the conditional encoder is increased to 0.0003, after 4 rounds of optimization, , the comprehensive deviation is reduced to 0.07, and the comprehensive deviation is reduced from 0.20 to 0.08. The adaptive weight adjustment module allocates the weight coefficient according to the scarcity of wear , which significantly improves the training priority of the wear sample. The generated wear sample is consistent with the real wear in progressive texture features, and after expanding the training data, the recognition accuracy of the detection model for wear is improved from 68% to 86%, and the F1 score is improved from 63% to 81%.

[0101] Example 3, pore defect generation:

[0102] The pore defect sample of the casting part is generated by using the method of the application. The training data set contains 20 real pore samples and 800 normal casting images. Pore belongs to the stress mutation type of defects. In the physical constraint noise scheduling, high-frequency noise is injected in the early stage to simulate the sudden formation of pores, and low-frequency noise is used in the later stage to depict the edge details of pores. The conditional coding information extracts the shape features and size distribution of pores. Multi-scale feature coupling establishes cross attention in 3 scale levels, and position sensitive convolution learns the easy pore area of casting thin wall and corner. After generating 60 pore samples, the dual-domain feedback optimization module evaluates that the comprehensive deviation , wherein the frequency domain deviation The initial deviation was high. The high-frequency feature extraction branch was adjusted, the number of channels was increased to 192, and a high-frequency consistency loss term with a weight of 0.3 was added to the loss function. After five rounds of optimization, the overall deviation decreased to 0.06. The adaptive weight adjustment module was based on the extremely high scarcity of stomata. Assign weight coefficients This maximizes the training priority of stomatal samples. The generated stomatal samples are highly consistent with real stomata in shape and size distribution. After being used to expand the training data, the detection model's accuracy in identifying stomata increased from 60% to 83%, recall increased from 55% to 78%, and F1 score increased from 57% to 80%.

[0103] The results were validated on an industrial parts dataset containing 5 defect types, 2000 normal samples, and 200 defect samples. Using the method of this invention, 1000 defect samples were generated to expand the training data, improving the average precision of the detection model from 74.2% to 82.7%, an improvement of 8.5 percentage points. The recall rate improved from 68.5% to 78.7%, an improvement of 10.2 percentage points. For rare defect types with fewer than 50 samples, the quality of the generated samples improved by more than 25%, and the detection F1 score improved from an average of 62% to 76%, an improvement of 14 percentage points. The overall deviation between the generated samples and real defects decreased from an initial 0.22 to 0.08, with continuous quality improvement after 3 to 5 rounds of closed-loop optimization. Compared with the baseline method using only CLIP features and fixed noise scheduling, the overall performance improvement of this invention reached more than 35%, fully validating the effectiveness of the four-module closed-loop collaborative system.

[0104] The above description is merely a preferred embodiment of the present invention and is not intended to limit the invention. For those skilled in the art, the present invention can be modified and varied in various ways. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principle of the present invention should be included within the scope of protection of the present invention.

Claims

1. A method for accurately generating defect samples of industrial parts based on a conditional diffusion model, characterized in that, Includes the following steps: Acquire reference samples containing defect features and images of normal industrial parts; perform multi-level feature extraction on the reference samples to generate conditional coding information containing defect type semantics, morphological features and material texture. Based on the physical formation mechanism of defects, a physical constraint noise scheduling strategy is constructed. The noise variance coefficient at each moment in the forward diffusion process is dynamically adjusted according to the defect type. Adaptive noise addition is performed on the normal industrial part image to generate a noise map sequence that conforms to the characteristics of the defect physical process. In the backdiffusion denoising process, the conditional coding information is fused with the feature maps of different depth layers of the U-Net backbone network through a multi-scale feature coupling mechanism, and a position-sensitive constraint is applied to the denoising prediction result based on the spatial prior distribution of defect-prone areas. The generated defect samples are simultaneously evaluated for multi-scale structural similarity in the pixel domain and Fourier spectral consistency in the frequency domain, and the deviation between the generated samples and the real defect samples in terms of texture details and spectral distribution is calculated. Based on the deviation, the denoising parameters and conditional coding weights of the diffusion model are dynamically adjusted through a dual-domain feedback mechanism to form a closed-loop optimization; at the same time, based on the scarcity of various defect samples, the weight coefficients of different defect types in the training loss function are adaptively adjusted. The multi-level feature extraction includes: The defect region is located and cropped from the reference sample to obtain a defect sample; The defect sample is input into a multimodal feature encoder to extract a joint feature vector containing visual semantics and geometric structure; The joint feature vector is decomposed hierarchically, and the macroscopic defect category features and microscopic morphological features are encoded hierarchically. The conditional coding information is generated by associating and mapping the hierarchically encoded features with the material surface texture features through a learnable cross-attention module. The construction of the physical constraint noise scheduling strategy includes: Identify the physical formation process corresponding to the defect type, and determine the defect formation mode of stress-induced abrupt change, gradual accumulation, or hybrid type; For stress-induced defects, a high-frequency noise rapid injection strategy is adopted in the early stage of forward diffusion, and a low-frequency noise fine adjustment is adopted in the later stage; for progressive accumulation defects, a time-cumulative noise superposition mode is adopted to simulate the progressive damage process. Based on the noise characteristics requirements at different times, a time-varying noise variance scheduling function is established so that the noise addition rate changes dynamically with the physical evolution characteristics of the defect. The multi-scale feature coupling mechanism includes: During the encoding stage of the U-Net backbone network, the conditional encoding information is projected onto the same dimensional space as the feature maps at each scale through a learnable linear mapping layer. At each scale level, the correlation weights between the conditional features and the current layer features are calculated through cross-attention, generating a scale-adaptive conditional guidance signal; During the decoding stage, the conditional guidance signal generated during the encoding stage is fused with the upsampled features at the corresponding scale using an element-wise weighted fusion. Position-sensitive convolutional layers are embedded in the decoding path to learn the spatial prior distribution of defect-prone regions, and the denoising prediction results are modulated by the position weight matrix.

2. The method according to claim 1, characterized in that, The multi-scale structural similarity assessment of the pixel domain includes: Gaussian pyramids were constructed for both generated samples and real defect samples to obtain image representations at multiple scale levels. At each scale level, the brightness similarity, contrast similarity, and structural similarity between the generated samples and the real samples are calculated. The similarity at each scale level is weighted and fused to generate a multi-scale structural similarity index; When the multi-scale structural similarity index is lower than a preset threshold, it is determined that the texture details of the generated sample deviate from the real defects.

3. The method according to claim 1, characterized in that, The Fourier spectral consistency assessment in the frequency domain includes: Two-dimensional discrete Fourier transforms are performed on the generated samples and the real defect samples respectively to obtain the spectrum amplitude diagram and phase diagram; Calculate the difference in spectral distribution between the generated sample and the real sample in the high-frequency and low-frequency components; Based on the aforementioned spectral distribution differences, the consistency between the generated samples and real defects in terms of edge details and overall contour is evaluated. When the difference between high-frequency components or low-frequency components exceeds their respective threshold ranges, the spectral characteristics of the generated sample are determined to deviate from the true distribution.

4. The method according to claim 1, characterized in that, The dual-domain feedback mechanism includes: A comprehensive deviation index is generated based on the pixel domain deviation and frequency domain deviation. If the comprehensive deviation index indicates that pixel domain deviation is dominant, then the fusion weight of conditional coding information in multi-scale feature coupling is increased; if the comprehensive deviation index indicates that frequency domain deviation is dominant, then the activation intensity of the high-frequency feature extraction branch in the denoising network is adjusted. The adjusted parameters are applied to the next round of diffusion denoising process to regenerate defect samples and evaluate the deviation, forming an iterative optimization closed loop.

5. The method according to claim 1, characterized in that, The weight coefficients for different defect types in the adaptively adjusted training loss function include: The distribution of the number of defect samples of each type in the statistical training dataset is analyzed, and the scarcity index of each type of defect is calculated. Based on the scarcity index, higher loss weights are assigned to defect types with fewer samples, and lower loss weights are assigned to defect types with more samples. During training, the weight coefficients are dynamically adjusted based on the generation quality of various defects, and the weights of defect types that fail to meet the generation quality standards are further increased.

6. The method according to claim 1, characterized in that, The multimodal feature encoder uses a vision-language pre-trained model for feature extraction and enhances the discriminative power of defective features through a contrastive learning mechanism; the hierarchical decomposition achieves coarse-grained decoupling of features through separable convolution and attention mechanisms.

7. The method according to claim 1, characterized in that, The time-varying noise variance scheduling function is adaptively scaled according to the physical time scale parameter of defect formation, so that the temporal characteristics of noise addition match the actual defect evolution process; for hybrid defects, a segmented noise scheduling strategy is adopted to switch the noise addition mode at different diffusion stages.

Citation Information

Patent Citations

  • Industrial defect sample generation method and device, electronic equipment and storage medium

    CN119180774A

  • Muscle imaging method, medium and equipment based on conditional diffusion model and electrical impedance

    CN120198324A

  • Video generation method and apparatus, and method and apparatus for training video generation model

    WO2024248736A1