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 adaptive weight adjustment, the quality and diversity issues of defect sample generation are addressed, thereby improving the performance of industrial part defect detection models.
Patent Information
- Application Number
- CN202511843781.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-09
- Publication Date
- 2026-01-06
- Estimated Expiration
- 2045-12-09
AI Technical Summary
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.
A closed-loop collaborative system based on the conditional diffusion model is constructed by means of physical constraint noise scheduling, multi-scale feature coupling, dual-domain feedback optimization and adaptive weight adjustment. This system generates samples that conform to the characteristics of the physical process of defects and performs multi-scale quality assessment and training weight adjustment.
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.
Smart Images

Figure CN121280441A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the fields of image processing and artificial intelligence, and in particular to a method for accurately generating defect samples of industrial parts based on a conditional diffusion model. Background Technology
[0002] Quality inspection of industrial parts is a crucial aspect of intelligent manufacturing. With the development of deep learning technology, automatic defect detection methods based on convolutional neural networks have been widely applied in industrial scenarios. However, these methods heavily rely on a large number of labeled defect samples for model training. In actual production, the proportion of qualified products typically exceeds 95%, making defect samples extremely scarce, and the distribution of different defect types is severely uneven. For example, on a certain automotive parts production line, there may be thousands of surface scratch defect samples, while there are only dozens of crack defect samples. This data imbalance leads to a significant decrease in the accuracy of the detection model in identifying defect types with fewer samples.
[0003] Traditional data augmentation methods mainly include geometric transformations and color perturbations, such as random rotation, scaling, and brightness adjustment. These methods can only perform simple transformations on existing samples and cannot generate new defect morphologies, making it difficult to increase the substantial diversity of defect samples. Defect sample generation methods based on generative adversarial networks alleviate this problem to some extent. CN119180774A discloses an industrial defect sample generation method that extracts defect features through a CLIP model, compresses feature vectors using a multilayer perceptron, and generates local defects in a diffusion model using a masking mechanism. This method uses Bézier curves to generate masks of arbitrary shapes, allowing the diffusion model to focus on the defect region rather than the background. However, this method has the following shortcomings: First, the defect generation lacks guidance from physical mechanisms. This method does not consider the differences in the physical formation processes of different defect types, and uses a fixed linear or cosine noise schedule, which cannot simulate different physical processes such as crack initiation caused by stress concentration and progressive damage caused by wear. Although the generated defect samples are visually similar, they lack the physical evolution characteristics of real defects, which may lead the detection model to learn false patterns.
[0004] Second, the feature encoding method is simplistic. This method only uses the CLIP model to extract visual features, failing to fully utilize the multi-level semantic information of defects. Defects contain both macroscopic category semantics and microscopic morphological features and edge details, making it difficult for a single encoding to comprehensively express the multi-scale characteristics of defects. Furthermore, the injection of conditional information is simplistic and fails to establish deep coupling across multiple scale levels of the diffusion model, limiting the accuracy of conditional guidance.
[0005] Third, it lacks closed-loop verification of generated quality. This method does not establish a comprehensive consistency assessment mechanism between generated samples and real defects, making it impossible to determine whether the generated samples conform to the statistical distribution of real defects in multiple dimensions such as texture detail and spectral characteristics. The generation process is open-loop, making it impossible to dynamically adjust model parameters based on quality assessment results, thus hindering continuous optimization of generated quality.
[0006] Fourth, the training strategy is not adapted to the imbalanced data. This method uses the same training weights for all defect types and does not focus on strengthening rare defect types, resulting in insufficient quality of generated defects with few samples and failing to effectively expand the training data for rare categories.
[0007] Therefore, 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 effect and generalization ability of deep learning-based industrial defect detection models. Summary of the Invention
[0008] To address the shortcomings of existing technologies, this invention provides a method for accurately generating defect samples of industrial parts based on a conditional diffusion model. This method aims 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 training strategies that are not adapted to data imbalance.
[0009] To achieve the above-mentioned objectives, the present invention adopts the following technical solution: This invention proposes a method for accurately generating defect samples of industrial parts based on a conditional diffusion model. The method first acquires reference samples containing defect features and images of normal industrial parts. Multi-level feature extraction is performed 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 defects, a physical constraint noise scheduling strategy is constructed. The noise variance coefficient at each time point during the forward diffusion process is dynamically adjusted according to the defect type. Adaptive noise addition is performed on the normal industrial part images to generate a noise map sequence that conforms to the physical process characteristics of defects. During the back-diffusion denoising process, a multi-scale feature coupling mechanism is used to perform cross-attention fusion of the conditional encoding information with feature maps from different depth layers of the U-Net backbone network. Based on the spatial prior distribution of defect-prone areas, position-sensitive constraints are applied to the denoising prediction results. The generated defect samples are simultaneously evaluated for multi-scale structural similarity in the pixel domain and Fourier spectral consistency in the frequency domain, calculating the deviation between the generated samples and the real defect samples in terms of texture details and spectral distribution. Based on the deviation, a dual-domain feedback mechanism is used to dynamically adjust the denoising parameters and conditional encoding weights of the diffusion model, forming 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.
[0010] The core innovation of this invention lies in constructing four deeply coupled modules: 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 transforms the physical formation mechanism of defects into dynamic constraints on the diffusion process, enabling generated samples to possess realistic 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 comprehensively evaluates the quality of generated samples through dual consistency verification in the pixel and frequency domains, and feeds back the evaluation results to adjust model parameters, forming a closed loop of continuous quality improvement. The adaptive weight adjustment module dynamically adjusts training weights based on the scarcity of defect types, focusing on enhancing the generation capability of defects with few samples. These four modules form tight parameter-level and state-level coupling; the output of one module directly serves as the key input of the next, and the evaluation results of the subsequent module inversely adjust the parameters of the preceding module, achieving mutual promotion, synergistic effect, and collaborative optimization among the modules.
[0011] Compared with the prior art, the present invention has the following beneficial effects: First, the generated samples possess realistic physical characteristics. Through a physical constraint noise scheduling strategy, the physical formation mechanism of defects is deeply embedded in the diffusion process. Different noise addition strategies are employed for different physical processes, such as stress-induced abrupt changes and gradual accumulation, ensuring that the generated defect samples are highly consistent with real defects in terms of microstructure and evolutionary characteristics. Experiments show that the crack-type defects generated by this invention achieve a more than 15% improvement in similarity to real cracks in edge sharpness and propagation path, while the wear-type defects achieve a more than 20% improvement in fitting the gradual texture features.
[0012] Second, it achieves precise multi-scale control. Through a multi-scale feature coupling mechanism, cross-attention fusion of conditional information and feature maps is established in each stage of encoding, intermediate, and decoding of the U-Net backbone network. Combined with the spatial prior distribution of defect-prone areas, position-sensitive constraints are applied to achieve precise and controllable generation of defect type, morphology, and spatial location. Experiments show that the spatial location accuracy of generated defects is improved by 12%, and the morphological boundary clarity is improved by 18%.
[0013] Third, a quality closed-loop assurance mechanism is established. Through a dual-domain feedback optimization module, the quality of generated samples is evaluated simultaneously in the pixel and frequency domains, calculating the deviation of texture details and spectral distribution. Based on this deviation, the denoising parameters and conditional coding weights of the diffusion model are dynamically adjusted, forming a closed loop that continuously improves quality. Experiments show that after three rounds of closed-loop optimization, the overall similarity between the generated samples and real defects increases from 78% to 92%.
[0014] Fourth, it addresses the problem of data imbalance. An adaptive weight adjustment module dynamically adjusts the training loss weights based on the scarcity of various defects, focusing on enhancing the generation quality of defects with fewer samples. Experiments show that for scarce defect types with fewer than 50 samples, the quality of generated samples is improved by more than 25%, effectively expanding the training data for scarce categories and increasing the detection model's accuracy in identifying defects with fewer samples by 18%.
[0015] Fifth, it improves the performance of the detection model. The high-quality defect samples generated by this invention are used to expand the training dataset. In the task of detecting defects in industrial parts, the average accuracy of the detection model is improved by 8.5%, the recall rate is improved by 10.2%, and the detection capability for rare defect types is significantly improved, with the F1 score improving by more than 14%. Attached Figure Description
[0016] Figure 1 This is a schematic diagram of the overall process of the method of the present invention.
[0017] Figure 2 This is a schematic diagram of the physical constraint noise scheduling module.
[0018] Figure 3 This is a schematic diagram of the multi-scale feature coupling module.
[0019] Figure 4 This is a schematic diagram of the dual-domain feedback optimization module.
[0020] Figure 5 This is a flowchart of the adaptive weight adjustment module.
[0021] Figure 6 This is an interaction diagram of a four-module closed-loop collaborative system. Detailed Implementation
[0022] Please refer to the attached document. Figures 1-6 The present invention will now be described in further detail with reference to the accompanying drawings and specific embodiments. It should be understood that the specific embodiments described herein are for illustrative purposes only and are not intended to limit the scope of the invention.
[0023] Reference Figure 1 This invention provides a method for accurately generating defect samples of industrial parts based on a conditional diffusion model. The method includes the following core steps: Step S1: Multi-level conditional encoding to obtain reference samples containing defect features and images of normal industrial parts. Reference samples are images of defective industrial parts collected from real production environments, including various defect types such as cracks, scratches, dents, and porosity. Normal industrial part images are images of defect-free, qualified products, used as the background for subsequent generation processes. Defect regions are located and cropped from the reference samples to obtain defect examples. The location method can employ manual annotation or an automatic segmentation algorithm. The cropped defect examples are uniformly 256×256 pixels in size.
[0024] Defect samples are input into a multimodal feature encoder for feature extraction. In one embodiment of the invention, the multimodal feature encoder employs the visual-language pre-trained model CLIP. This model is pre-trained on a large scale of image-text pairs through contrastive learning and possesses powerful visual semantic understanding capabilities. The CLIP model includes an image encoder and a text encoder. The image encoder adopts the ViT architecture, encoding defect samples into a 768-dimensional joint feature vector. This vector simultaneously contains visual semantic and geometric structural information, comprehensively expressing the features of the defect.
[0025] A hierarchical decomposition is performed on the joint feature vector, encoding macroscopic defect category features and microscopic morphological features in layers. Specifically, through separable convolution and multi-head attention mechanisms, the 768-dimensional feature vector is decomposed into two subspaces: a 384-dimensional macroscopic category feature subspace and a 384-dimensional microscopic morphological feature subspace. Macroscopic category features express the semantic category of the defect, while microscopic morphological features express detailed features such as edge sharpness and texture roughness. A learnable cross-attention module is used to correlate and map the layered encoded features with the material surface texture features. The material surface texture features are extracted by gray-level co-occurrence matrix analysis of normal industrial part images, including texture parameters such as contrast, correlation, energy, and homogeneity. The cross-attention module calculates the correlation weights between defect features and texture features, generating fused conditional encoding information with a dimension of 512.
[0026] Step S2: Physical constraint noise scheduling, refer to Figure 2 A physical constraint noise scheduling module 1 is constructed. This module dynamically adjusts the noise addition strategy during the forward diffusion process based on the physical formation mechanism of defects.
[0027] First, identify the physical formation process corresponding to the defect type. The formation mechanisms of different defect types differ significantly. Cracks are usually caused by stress concentration, with the formation process characterized by a sudden stress change and rapid crack propagation within a short period. Scratches are caused by friction or impact, with a relatively rapid but uniform formation process. Wear defects are caused by long-term use, with the formation process characterized by gradual accumulation and progressively deepening damage. Porosity defects are caused by poor gas escape during the casting process, with a random and sudden formation process. Based on these physical characteristics, defects are classified into three modes: stress-induced sudden change, gradual accumulation, and mixed types.
[0028] For stress-induced defects such as cracks and porosity, a high-frequency noise rapid injection strategy is employed in the early stages of forward diffusion to simulate the instantaneous changes caused by stress abrupt changes. Specifically, in the diffusion steps... In the initial stage, the noise variance coefficient Setting it to a larger value, preferably 0.02 to 0.05, allows the image to quickly transition to a noisy state. This is important in the later stages. Low-frequency noise is finely adjusted, and the noise variance coefficient is... The noise level is gradually reduced to 0.0001 to 0.001 to simulate the refinement process of crack propagation path. High-frequency noise reflects the macroscopic effect of stress abrupt change, while low-frequency noise depicts the microscopic details of crack edges.
[0029] For progressively accumulating defects, such as wear and corrosion, a time-cumulative noise superposition mode is adopted. Specifically, the noise variance coefficient... With time step The growth is linear or logarithmic, simulating the gradual accumulation of damage. In a preferred embodiment, a logarithmic growth function is used: , in, For the first The noise variance coefficient of the step. To minimize the noise variance, a value of 0.0001 is used. The maximum noise variance is set to 0.02. This represents the current diffusion step number. The total number of diffusion steps is preferably 1000. This formula causes the noise to increase slowly in the initial stage and then accelerate in the later stage, which conforms to the gradual characteristics of wear damage.
[0030] For mixed defects, such as scratches, a segmented noise modulation strategy is employed. During the early diffusion phase, to simulate the rapid formation of scratches, a larger noise variance coefficient is used. In the later stages of diffusion, the edges of the simulated scratches are refined, 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.
[0031] 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: , 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.
[0032] 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: , 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.
[0033] 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.
[0034] The U-Net backbone network employs an encoder-decoder architecture, comprising four downsampling stages and four upsampling stages. In the encoding stage, conditional encoding information is projected onto a dimensional space identical to the feature maps at each scale through learnable linear mapping layers. The initial dimension of the conditional encoding information is 512, projected to 64 dimensions at scale 1, 128 dimensions at scale 2, 256 dimensions at scale 3, and 512 dimensions at scale 4. Projection is achieved through fully connected layers and the ReLU activation function, ensuring effective fusion of the conditional information with feature maps of different depths.
[0035] At each scale level, the relevance weights between the conditional features and the current layer features are calculated using a cross-attention mechanism. The cross-attention mechanism treats the current layer features as the query and the conditional features as the key and value, calculating the attention score between them to generate a scale-adaptive conditional guidance signal. Specifically, let the first... The feature map of the layer is The projected conditional features are Cross-attention is calculated as follows: , in, For querying the matrix, The key matrix, For value matrices, For a learnable projection matrix, The dimension of the key vector, with values... , The attention output represents the guiding signal of the conditional features on the current layer features. Through cross-attention, the conditional information can adaptively focus on spatial regions related to defective features, enhancing the targeting of conditional guidance.
[0036] During the decoding phase, the conditional guidance signal generated in the encoding phase is fused with the upsampled features at the corresponding scale using an element-wise weighted fusion method. The fusion operation employs a gating mechanism, dynamically adjusting the fusion ratio of the conditional signal based on the activation intensity of the current feature. , in, For the first Upsampling features of the layer This is the corresponding conditional guidance signal. For the gated weight matrix, It is the Sigmoid activation function. For element-wise multiplication, The features are fused. The gating mechanism makes the fusion process adaptive, avoiding excessive interference of conditional signals on the features.
[0037] A position-sensitive convolutional layer is embedded in the decoding path to learn the spatial prior distribution of defect-prone regions. Defects in industrial parts are often concentrated in specific areas, such as weld joints, corners, and stress concentration zones. The position-sensitive convolutional layer generates a position weight matrix by learning the spatial distribution pattern of defects in the training data. , representing the prior probability of defects occurring at each spatial location. During denoising prediction, the location weight matrix is multiplied element-wise with the prediction result to enhance the prediction strength in high-risk areas and suppress noise in low-risk areas. Specifically, the denoising prediction result... After position modulation, it becomes: , in, This is the noise map at the current moment. The denoising result predicted by the denoising network. This is the position weight matrix. This is the final prediction after location modulation. By using location-sensitive constraints, the generated defects more closely resemble the actual spatial distribution patterns, improving the realism of the generated samples.
[0038] Step S4: Two-domain consistency assessment, refer to Figure 4 A dual-domain feedback optimization module 3 is constructed. This module simultaneously performs quality assessments on the generated defect samples in both the pixel and frequency domains, calculates the deviation between the generated samples and the real defect samples, and dynamically adjusts the model parameters through a feedback mechanism.
[0039] In the pixel domain, multi-scale structural similarity evaluation is performed. Gaussian pyramids are constructed for both generated and real defect samples to obtain image representations at multiple scale levels. The Gaussian pyramids are generated by Gaussian blurring and downsampling the images; in this embodiment, three pyramid layers are constructed with resolutions of 256×256, 128×128, and 64×64. At each scale level, brightness similarity, contrast similarity, and structural similarity between the generated and real samples are calculated. The structural similarity index (SSIM) is defined as follows: , in, To generate samples, For real samples, They are respectively average brightness They are respectively standard deviation for covariance, It is a constant used to avoid the denominator being zero. , , For an 8-bit grayscale image, the range of pixel values is... The SSIM value range is... The higher the value, the higher the similarity.
[0040] The SSIM values at each scale level are weighted and fused to generate the multi-scale structural similarity index MS-SSIM. , in, This represents the number of pyramid levels, with a value of 3. For the first The SSIM value of the layer, For the first Layer weight coefficients, When the MS-SSIM value is lower than the preset threshold of 0.85, it is determined that the texture details of the generated sample deviate from the actual defects, and the pixel domain deviation is recorded. : , In the frequency domain, a Fourier spectrum consistency assessment is performed. Two-dimensional discrete Fourier transforms are applied to both the generated samples and the actual defect samples to obtain the spectrum amplitude and phase diagrams. The two-dimensional discrete Fourier transform is defined as follows: , in, For spatial domain images, For frequency domain representation, For the width and height of the image, For frequency domain coordinates, The imaginary unit is used. The spectral amplitude is... Phase is .
[0041] The differences in spectral distribution between the generated sample and the real sample in high-frequency and low-frequency components are calculated. The spectral center corresponds to the low-frequency component, reflecting the overall contour and large-scale structure of the image; the spectral edge corresponds to the high-frequency component, reflecting the edge details and texture of the image. The frequency domain is divided into low-frequency and high-frequency regions, with the low-frequency region defined by the radius of the spectral center. The area within, The value is set to 20% of the spectrum size, with the high-frequency region being the radius. Outside of this region, calculate the difference in low-frequency components separately. Difference with high-frequency components : , , in, These are the spectra of the generated sample and the real sample, respectively. These are the coordinate sets for the low-frequency region and the high-frequency region, respectively. This represents the number of pixels within the region. When the high-frequency component difference... Exceeding the threshold of 0.15 or low-frequency component difference When the value exceeds the threshold of 0.10, the spectral characteristics of the generated sample are determined to deviate from the true distribution, and the frequency domain deviation is recorded. : , Among them, the weight of high-frequency components (0.6) is greater than that of low-frequency components (0.4) because the edge details of defects have a greater impact on detection performance.
[0042] Step S5: Dual-domain feedback optimization, based on pixel domain deviation. and frequency domain deviation Generate a comprehensive deviation index: , If the overall deviation If the deviation exceeds the threshold of 0.20, the feedback adjustment mechanism is activated. The main sources of deviation are analyzed. This indicates that pixel domain deviation is the main issue, and texture details do not match; if This indicates that the frequency domain deviation is the main issue, and the spectral characteristics do not conform to the expected values.
[0043] To address the issue of pixel-domain deviation as the primary factor, the fusion weight of conditional coding information in multi-scale feature coupling is increased. Specifically, the cross-attention output is... The fusion coefficient was increased from 0.5 to 0.7, enhancing the guiding role of conditional information in the denoising process and making the texture details of the generated samples closer to real defects. At the same time, the learning rate of the conditional encoder was adjusted from the initial 0.0001 to 0.0003 to accelerate the optimization of conditional features.
[0044] To address the issue of predominantly frequency domain deviation, the activation intensity of the high-frequency feature extraction branch in the denoising network was adjusted. During the decoding stage of U-Net, the number of channels in the high-frequency feature extraction layer was increased from 128 to 192, enhancing the network's ability to express high-frequency details. Simultaneously, a high-frequency consistency loss term was added to the loss function with a weight of 0.3, prompting the network-generated samples to more closely approximate the actual defects in the high-frequency components of the spectrum.
[0045] The adjusted parameters are applied to the next round of diffusion denoising to regenerate defect samples and evaluate the deviation. If the deviation decreases, the adjustment is effective, and the new parameters are continued; if the deviation does not decrease or increases, the parameters are reverted to the previous round, and other adjustment strategies are tried. Through iterative feedback optimization, the deviation between the generated samples and real defects is gradually reduced, forming a closed loop of continuous quality improvement. In a preferred embodiment, the maximum number of iterations is set to 5, and the overall deviation is evaluated after each iteration. The optimization can be stopped when the maximum number of iterations is reached. Experiments show that after 3 to 5 rounds of closed-loop optimization, the overall deviation can be reduced from the initial 0.22 to 0.08, and the quality of the generated samples is significantly improved.
[0046] Step S6: Adaptive weight adjustment, refer to Figure 5 An adaptive weight adjustment module 4 is constructed. This module dynamically adjusts the weight coefficients of different defect types in the training loss function according to the scarcity of various defect samples, focusing on enhancing the generation capability of defects with few samples.
[0047] Statistically analyze the distribution of the number of defect samples of each type in the training dataset. Assume the dataset contains... Type 1 defect, the first The number of samples for this type of defect is Calculate the scarcity index for each type of defect. : , in, The number of categories with the largest number of samples among all defect types. Scarcity. The range of values is A larger value indicates that the type of defect is rarer. For example, the number of crack-type defect samples in a dataset. Number of scratch-type defect samples The scarcity of cracks The scarcity of scratches .
[0048] Based on the scarcity index, training loss weights are assigned to various defects. : , in, This is the weighting amplification factor, preferably 2.0. For defect types with a sufficient number of samples, Approaching 0 Close to 1; for defect types with scarce sample sizes, Approaching 1, It can reach a maximum of 3.0, significantly increasing its importance in training.
[0049] During training, the loss function is in a weighted form: , in, For the first The generation loss for defect types uses mean squared error or KL divergence to measure the difference between generated and real samples. By using weighted loss, the model pays more attention to scarce defect types during training, increasing their optimization intensity and improving generation quality.
[0050] During the middle and later stages of training, the weight coefficients are dynamically adjusted based on the generation quality of various defects. Specifically, at regular training epochs, the quality of the generated samples for each type of defect is evaluated, and the overall deviation is calculated. If the overall deviation of a certain type of defect remains high, it indicates that the generation quality has not met the standards, and the weight coefficient of that type should be further increased. , This adjustment mechanism dynamically responds to the generation quality, applying greater optimization pressure to defect types with poor quality, thus ensuring a balanced improvement in the generation quality of all defect types. Experiments show that after adopting adaptive weight adjustment, the generation quality of scarce defect types improves by more than 25%, and the overall deviation decreases from 0.35 to 0.12, effectively solving the data imbalance problem.
[0051] Reference 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.
[0052] The physical constraint noise scheduling module 1 generates a noise map sequence that conforms to the physical evolution characteristics based on the defect type. This sequence serves as the input to the multi-scale feature coupling module 2. During the backdiffusion denoising process, the multi-scale feature coupling module 2 deeply fuses the conditional coding information with the noise map sequence to generate preliminary defect samples. These samples are then fed into the dual-domain feedback optimization module 3 for quality assessment, calculating the deviation in the pixel and frequency domains. Based on the deviation, the dual-domain feedback optimization module 3 adjusts the noise variance coefficient of the physical constraint noise scheduling module 1 and the fusion weights of the multi-scale feature coupling module 2 in reverse, forming a parameter-level closed-loop feedback. After feedback adjustment, modules 1 and 2 regenerate defect samples, further reducing the deviation.
[0053] The adaptive weight adjustment module 4 dynamically adjusts the training loss weights based on the scarcity and generation quality of various defects. This weight coefficient serves as a global parameter, influencing the training objectives of physical constraint noise scheduling, multi-scale feature coupling, and dual-domain feedback optimization. Through weight adjustment, scarce defect types receive higher priority during training, and the three modules obtain stronger gradient signals when optimizing scarce defects, accelerating convergence.
[0054] The following synergies are achieved among the four modules: Mutual promotion: Physically constrained noise scheduling provides a data foundation that conforms to physical characteristics for subsequent modules, multi-scale feature coupling enables precise control, dual-domain feedback optimization ensures quality, and adaptive weight adjustment solves data imbalance. The four complement each other and work together to improve the quality of generation.
[0055] Synergistic Effect: The improvement effect of using any single module alone is limited, but the effect increases non-linearly when the four modules work together. Experiments show that using only physical constraint noise scheduling improves the generation quality by 8%, adding multi-scale feature coupling improves it to 22%, adding dual-domain feedback optimization improves it to 35%, and finally adding adaptive weight adjustment improves it to 48%, far exceeding the sum of the effects of each module alone.
[0056] Resolving the contradiction: There is a conflict between the diversity and authenticity of generated samples; overemphasizing authenticity may reduce diversity. This invention introduces diversity through physically constrained noise scheduling and ensures authenticity through dual-domain feedback optimization, finding a balance between the two to achieve a synergistic improvement in both diversity and authenticity.
[0057] Adaptive adjustment: The four modules dynamically adjust parameters during training, adaptively optimizing based on the generation quality and data distribution, without the need for manual intervention, forming an intelligent closed-loop system.
[0058] Example 1, Generation of crack-like defects: Crack defect samples of bearing parts were generated using the method of this invention. The training dataset contains 45 real crack samples and 500 normal bearing images. Cracks are stress-induced defects. In the physical constraint noise scheduling, high-frequency noise is injected rapidly in the initial stage, and the noise variance coefficient is... In the later stages, low-frequency noise was used for refinement, and the noise variance coefficient was adjusted. Conditional encoding information is used to extract crack edge sharpness and propagation direction features. Multi-scale features are coupled across three scale levels in U-Net to establish cross-attention, and position-sensitive convolutions are used to learn crack-prone regions in the bearing inner ring and raceway. After generating 100 crack samples, a dual-domain feedback optimization module evaluates and identifies differences in high-frequency components. If the value exceeds the threshold of 0.15, feedback adjustment is initiated, increasing the number of channels in the high-frequency feature extraction branch to 192. After three rounds of optimization, The error was reduced to 0.11, and the overall deviation decreased from 0.24 to 0.09. The generated crack samples were highly consistent with real cracks in terms of edge sharpness and propagation path. After being used to expand the training data, the detection model's crack recognition accuracy increased from 72% to 89%, and the recall increased from 65% to 85%.
[0059] Example 2, Generation of wear-related defects: Wear defect samples of gear parts were generated using the method of this invention. The training dataset contains 30 real wear samples and 600 normal gear images. Wear is a progressively cumulative defect. In the physical constraint noise scheduling, a logarithmically growing time-cumulative noise superposition is adopted, and the noise variance coefficient starts from... Growth to Conditional encoding information extracts progressive texture features and roughness variations in wear. Multi-scale feature coupling fuses the conditional information with four scale levels of U-Net, and position-sensitive convolutions learn the wear-prone regions of the tooth surface. After generating 80 wear samples, a dual-domain feedback optimization module evaluates and identifies pixel-domain deviations. The fusion weights of the conditional coding information were increased to 0.7, and the learning rate of the conditional encoder was increased to 0.0003. After four rounds of optimization, The overall deviation decreased from 0.20 to 0.08, dropping to 0.07. The adaptive weight adjustment module adjusts the weight based on the scarcity of wear. Assign weight coefficients This significantly improves the training priority of wear samples. The generated wear samples are highly consistent with real wear in terms of progressive texture features. After being used to expand the training data, the detection model's accuracy in identifying wear increased from 68% to 86%, and the F1 score increased from 63% to 81%.
[0060] Example 3, Generation of porosity defects: This invention generates porosity defect samples from cast parts using the method described in this invention. The training dataset contains 20 real porosity samples and 800 images of normal castings. Porosity is a stress-induced defect; in the physical constraint noise scheduling, high-frequency noise is rapidly injected in the early stage to simulate the sudden formation of porosity, and low-frequency noise is used for refinement in the later stage to characterize the edge details of the porosity. Conditional encoding information is used to extract the shape features and size distribution of the porosity. Multi-scale feature coupling establishes cross-attention at three scale levels, and position-sensitive convolution learns the porosity-prone regions at thin walls and corners of the casting. After generating 60 porosity samples, a dual-domain feedback optimization module evaluates and identifies the overall deviation. 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%.
[0061] 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.
[0062] 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 accurate generation of defect samples of industrial parts based on a conditional diffusion model, characterized in that, The method comprises the following steps: obtaining a reference sample containing defect features and an image of a normal industrial part, performing multi-level feature extraction on the reference sample, and generating conditional encoding information containing defect type semantics, morphological features and material texture; 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 image of the normal industrial part to generate a noise image sequence conforming 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 applied to the denoising prediction result; the generated defect sample is 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 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; meanwhile, based on the scarcity degree of each type of defect sample, the weight coefficients of different defect types in the training loss function are adaptively adjusted.
2. The method of claim 1, wherein, The multi-level feature extraction comprises: performing defect area positioning and cutting on the reference sample to obtain a defect sample; inputting the defect sample into a multi-modal feature encoder to extract a joint feature vector containing visual semantics and geometric structure; performing hierarchical decomposition on the joint feature vector to layer-coding macro defect category features and micro morphological features; through a learnable cross-attention module, the hierarchically coded features are associated and mapped with the material surface texture features to generate the conditional encoding information.
3. The method of claim 1, wherein, The construction of the physical constraint noise scheduling strategy comprises: identifying the physical formation process corresponding to the defect type, and determining the stress mutation type, gradual accumulation type or mixed type of the defect formation mode; for the stress mutation type defect, 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 the gradual accumulation type defect, a time accumulation type noise superposition mode is adopted to simulate the gradual damage process; according to the noise characteristic requirements at different times, a time-varying noise variance scheduling function is established, so that the noise addition rate dynamically changes with the defect physical evolution characteristics.
4. The method of claim 1, wherein, The multi-scale feature coupling mechanism comprises: in the encoding stage of the U-Net backbone network, the conditional encoding information is projected into the same dimension space as the feature maps of each scale through a learnable linear mapping layer; at each scale level, the correlation weight of the conditional features and the current layer features is calculated through cross-attention to generate a scale-adaptive conditional guidance signal; in the decoding stage, the conditional guidance signal generated in the encoding stage is element-wise weighted and fused with the up-sampled features of the corresponding scale; a position-sensitive convolution layer is embedded in the decoding path to learn the spatial prior distribution of the defect-prone area, and the denoising prediction result is modulated by a position weight matrix.
5. The method of claim 1, wherein, The multi-scale structural similarity evaluation in the pixel domain comprises: A Gaussian pyramid is constructed for the generated sample and the real defect sample respectively, and image representations at multiple scale levels are obtained; At each scale level, the brightness similarity, contrast similarity and structural similarity between the generated sample and the real sample are calculated; The similarities at different scale levels are fused by weighting, and a multi-scale structural similarity index is generated; 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 defect.
6. The method of claim 1, wherein, The Fourier spectrum consistency evaluation in the frequency domain includes: Two-dimensional discrete Fourier transform is performed on the generated sample and the real defect sample respectively, and the spectrum amplitude map and the phase map are obtained; The spectrum distribution difference between the generated sample and the real sample in high frequency components and low frequency components is calculated; Based on the spectrum distribution difference, the consistency of the generated sample with the real defect in edge details and overall outline is evaluated; When the high frequency component difference or the low frequency component difference exceeds the respective threshold interval, it is determined that the spectrum characteristics of the generated sample deviate from the real distribution.
7. The method of claim 1, wherein, The dual-domain feedback mechanism includes: According to the pixel domain deviation degree and the frequency domain deviation degree, a comprehensive deviation index is generated; If the comprehensive deviation index indicates that the pixel domain deviation is dominant, the fusion weight of the conditional coding information in the multi-scale feature coupling is increased; if the comprehensive deviation index indicates that the frequency domain deviation is dominant, the activation strength 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, the defect sample is regenerated and the deviation degree is evaluated, forming an iterative optimization closed loop.
8. The method of claim 1, wherein, The adaptive adjustment of the weight coefficients of different defect types in the training loss function includes: The number distribution of each type of defect sample in the training data set is counted, and the scarcity index of each type of defect is calculated; Based on the scarcity index, higher loss weight is allocated to the defect type with less sample quantity, and lower loss weight is allocated to the defect type with more sample quantity; During the training process, the weight coefficients are dynamically adjusted according to the generation quality of each type of defect, and the weight of the defect type with unsatisfactory generation quality is further improved.
9. The method of claim 2, wherein, The multi-modal feature encoder uses a visual-linguistic pre-training model for feature extraction, and enhances the discriminability of defect features through a contrast learning mechanism; the hierarchical decomposition realizes the decoupling of feature granularity through separable convolution and attention mechanism.
10. The method of claim 3, wherein, The time-varying noise variance scheduling function is adaptively scaled according to the physical time scale parameter of defect formation, so that the timing characteristics of noise addition match the actual defect evolution process; for mixed defects, a segmented noise scheduling strategy is used 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
Alfalfa cold resistance evaluation system based on deep learning
CN120336766A
Cotter pin defect data enhancement method and system
CN120470474A
Condition-controllable image sample expansion method and system for surface defect detection
CN120525000A
Cited By
Abnormal sample image generation method, electronic equipment and storage medium
CN121482535A
Physical mechanism embedded industrial data generation method and device and storage medium
CN121685536A
Industrial data generation method and device embedding physical mechanism and storage medium
CN121685536B
Marine engineering material microstructure defect detection method and system based on image detection
CN121982037A
Method and system for detecting microstructure defects of marine engineering materials based on image detection
CN121982037B