Generative Data Augmentation Method, System, Device and Medium for Surface Defects of Industrial Products

Through high-resolution industrial cameras, images are collected and U-Net diffusion model are constructed to generate high-fidelity scratch images, which solves the problems of difficulty in obtaining labeled data and insufficient sample diversity in surface defect detection of industrial products, and improves the recognition accuracy and generalization ability of the model.

CN120125926BActive Publication Date: 2025-07-25NANJING AGRICULTURAL UNIVERSITY +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510623150.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-05-15
Publication Date
2025-07-25
Estimated Expiration
2045-05-15

AI Technical Summary

Technical Problem

The existing industrial product surface defect detection technology has difficulty obtaining labeled data, high cost, and insufficient sample diversity, resulting in low model identification accuracy and poor generalization ability, especially in small samples.

Method used

High-resolution industrial cameras are used to acquire images, build a diffusion model based on U-Net architecture, generate high-fidelity scratched images through reverse sampling mechanism, and merge them with real defective images to build a brand new defective image to improve data set diversity and model performance.

Benefits of technology

It significantly improves the recognition accuracy and generalization ability of the model, solves the problem of small samples, realizes the intelligent migration of scratch defects on different product carriers, and enhances the universality and reuse efficiency of data enhancement solutions.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120125926B_ABST
    Figure CN120125926B_ABST
Patent Text Reader

Abstract

The present invention discloses a generative data augmentation method, system, device, and medium for surface defects of industrial products, which relates to the fields of deep learning and computer vision in industrial quality inspection. It includes collecting original industrial product image data and constructing a scratch image dataset; based on the preprocessed scratch image dataset, constructing a diffusion model based on the U-Net architecture, and using the Adam optimizer to optimize the model parameters; adopting a reverse sampling mechanism to generate high-fidelity scratch images, and saving the generated images to a specified directory; based on image fusion technology, stitching the generated defective product images and real defective product images to construct a new defective product image; the method of the present invention effectively solves the problems of scarce real defect samples and low data augmentation efficiency in industrial scratch detection, significantly improves the recognition accuracy and generalization ability of the detection model, and realizes the intelligent migration of defects such as scratches on different product carriers.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of deep learning and computer vision in industrial quality inspection, and specifically to a generative data augmentation method, system, device and medium for surface defects of industrial products. Background Art

[0002] With the acceleration of the intelligentization process of industrial manufacturing, the surface defect detection technology based on computer vision has become one of the core research directions in the field of intelligent manufacturing. The early manual detection methods are inefficient and subjective, and it is difficult to meet the needs of large-scale industrial production. Subsequently, the defect detection technology based on computer vision emerged, and through means such as image processing and pattern recognition, the automatic recognition of product surface defects was realized. However, traditional methods still have limitations in dealing with complex surfaces, tiny defects and diverse working conditions. In recent years, the rapid development of deep learning technology has provided new solutions for the surface defect detection of industrial products. Especially the excellent performance of convolutional neural networks in the field of image recognition has greatly improved the accuracy and efficiency of defect detection. Nevertheless, the need for a large amount of labeled data in the training process of deep learning models makes the small sample problem a bottleneck restricting its further application. For this reason, researchers have proposed a variety of data augmentation methods, such as rotation, flipping, scaling, etc., but the data generated by these methods often differ from the real defect distribution, and it is difficult to effectively improve the model's recognition ability for complex defects. In this context, generative data augmentation technologies such as generative adversarial networks and diffusion models have gradually attracted attention. By learning the distribution of real data, they generate high-quality samples close to reality, providing new ideas for solving the small sample problem. Particularly noteworthy is that there are three major technical shortcomings in the existing generative models in industrial defect synthesis: insufficient feature decoupling ability, making it difficult to precisely control the independent generation of the geometric and texture attributes of scratches; multi-modal fusion defects, when embedding synthetic scratches into background images, visual artifacts often occur due to lighting consistency and perspective transformation matching deviations; lack of an evaluation system, and existing research mostly evaluates the generation quality based on general indicators such as FID and IS, lacking domain-specific evaluation criteria for industrial quality inspection requirements.

[0003] Although significant progress has been made in current industrial product surface defect detection technologies, many challenges still remain. First, existing technologies perform poorly in dealing with small-sample problems. Since it is difficult and costly to obtain defective samples in industrial production, the labeled data available for training is limited, and it is difficult for the model to learn comprehensive defect features, thus affecting the detection performance. Second, the samples generated by traditional data augmentation methods differ greatly from real defects and cannot effectively improve the generalization ability of the model. In addition, existing technologies still have deficiencies in dealing with complex surface textures, lighting changes, defect diversity, etc., resulting in the need to improve the detection accuracy and robustness. To address these deficiencies, the generative data augmentation method for industrial product surface defects proposed in the present invention effectively expands the defect sample library and solves the small-sample problem by using a diffusion model to generate high-fidelity scratch images and stitching them with intact images. At the same time, the samples generated by this method are closer to the real defect distribution, which helps to improve the feature learning ability and generalization ability of the model. Through comparative experiments, the present invention shows significant advantages in improving the recognition accuracy of defective products, providing a new direction and strong support for the development of industrial product surface defect detection technologies. Summary of the Invention

[0004] In view of the above problems, the present invention is proposed.

[0005] Therefore, the technical problem solved by the present invention is that the existing industrial scratch detection method based on manually labeled data has difficulties in obtaining labeled data, high costs, and insufficient sample diversity, resulting in low model recognition accuracy and poor generalization ability, and how to effectively solve the small-sample problem of industrial scratches and improve the model performance.

[0006] To solve the above technical problems, the present invention provides the following technical solutions: A generative data augmentation method for surface defects of industrial products, including collecting original industrial product image data and constructing a scratch image dataset; based on the preprocessed scratch image dataset, constructing a diffusion model based on the U-Net architecture, and using the Adam optimizer to optimize the model parameters; adopting a reverse sampling mechanism to generate high-fidelity scratch images, and saving the generated images to a specified directory; based on image fusion technology, splicing the generated defective product images and real defective product images to construct a new defective product image; constructing the scratch image dataset includes collecting industrial product images through a high-resolution industrial camera, precisely intercepting the scratch areas existing on the surface of defective products to form a scratch image dataset, and performing unified image size standardization and grayscale processing on the intercepted scratch images; constructing a diffusion model based on the U-Net architecture includes two parts: an encoder and a decoder. The encoder is used to extract image features, and the decoder is used to reconstruct images. The U-Net architecture is used as the core network of the diffusion model, and the Adam optimizer is combined to optimize the model parameters; adopting the reverse sampling mechanism, through the reverse sampling mechanism of the diffusion model, learning the distribution characteristics of scratch images, generating images very similar to real scratch images, and using the U-Net network for inverse diffusion to generate high-fidelity scratch images.

[0007] As a preferred embodiment of the generative data augmentation method for surface defects of industrial products according to the present invention, wherein: constructing the scratch image dataset includes using a high-resolution industrial camera to collect the finished and defective product images of industrial products, precisely intercepting and preprocessing the scratch areas based on image processing technology, and performing unified processing on the intercepted scratch images.

[0008] As a preferred embodiment of the generative data augmentation method for surface defects of industrial products according to the present invention, wherein: performing unified processing on the intercepted scratch images includes standardizing the image size to a fixed resolution and converting the image to a grayscale image.

[0009] As a preferred embodiment of the generative data augmentation method for surface defects of industrial products according to the present invention, wherein: constructing a diffusion model based on the U-Net architecture includes constructing a generative model based on the diffusion model, and the forward diffusion formula is expressed as:

[0010] ;

[0011] where represents the conditional probability distribution, represents the time step of reverse diffusion, represents the image data at time step represents the image data at time step represents the image data at time step represents the image data at time step represents the normal distribution, is denoted as the diffusion coefficient, is the identity matrix. The U-Net architecture is used as the core network of the diffusion model to define the Gaussian diffusion process.

[0012] As a preferred solution of the generative data augmentation method for surface defects of industrial products described in the present invention, wherein: the optimization of model parameters using the Adam optimizer includes introducing mixed-precision training, scaling the gradients based on GradScaler, and setting the gradient accumulation steps using the gradient accumulation strategy.

[0013] As a preferred solution of the generative data augmentation method for surface defects of industrial products described in the present invention, wherein: the generation of high-fidelity scratch images using the reverse sampling mechanism includes, based on the trained diffusion model, loading the pre-trained model weights to generate new scratch images, and the reverse diffusion formula is expressed as:

[0014] ;

[0015] wherein, represents the conditional probability distribution, represents the parameters of the deep learning model U-Net, represents at time step the image data, represents at time step the image data, represents the normal distribution, represents the mean of the normal distribution, represents the covariance matrix of the normal distribution, represents the time step of reverse diffusion.

[0016] As a preferred solution of the generative data augmentation method for surface defects of industrial products described in the present invention, wherein: the construction of new defective product images includes reading intact images and scratch images, locating and extracting the scratch areas and scratch splicing positions, and performing weighted mixing on the target areas.

[0017] Another object of the present invention is to provide a generative data augmentation system for surface defects of industrial products, which can solve the problems of difficult acquisition, high cost, and insufficient sample diversity of labeled data in the current industrial scratch detection technology through a solution combining a diffusion model based on the U-Net architecture and a reverse sampling mechanism, and significantly improve the model recognition accuracy and generalization ability.

[0018] As a preferred solution of the generative data augmentation system for surface defects of industrial products described in the present invention, it includes a data acquisition and preprocessing module, a diffusion model training and generation module, and an image fusion and synthesis module. The data acquisition and preprocessing module is used to obtain the surface image of the industrial lid through a high-resolution industrial camera, accurately intercept the scratch area, perform preprocessing operations such as standardization and grayscale conversion, and construct a scratch feature data set that meets the model input requirements. The diffusion model training and generation module is used to train a diffusion model based on the U-Net architecture, add learned scratch distributions through the forward diffusion process, and generate high-fidelity scratch images using the reverse diffusion formula. The image fusion and synthesis module is used for cross-carrier defect migration, fusing the generated grayscale scratch images with the color intact product images, locating the scratch splicing area through Canny edge detection, generating masks by combining Gaussian blur and morphological operations, and performing weighted mixing to generate defective product composite images for training the detection model.

[0019] A computer device includes a memory and a processor. The memory stores a computer program, and the processor executes the computer program to implement the steps of the generative data augmentation method for surface defects of industrial products.

[0020] A computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, it implements the steps of the generative data augmentation method for surface defects of industrial products.

[0021] Advantages of the present invention: The generative data augmentation method for surface defects of industrial products provided by the present invention uses a high-resolution industrial camera to collect images and accurately intercept the scratch area, constructs a standardized defect feature library, realizes the intelligent migration of defects such as scratches on different product carriers, and significantly improves the generality and reuse efficiency of the data augmentation solution. The design of the diffusion model based on the U-Net architecture, based on the strong feature extraction ability of U-Net, effectively captures the fine features of scratches and improves the quality of the generated images. The introduction of the Adam optimizer and mixed-precision training speeds up the model training speed and ensures the accuracy and stability of parameter optimization. The use of the reverse sampling mechanism to generate high-fidelity scratch images realizes the realistic generation of scratch images and enhances the diversity of data. The image fusion technology constructs a new defective product image. The fusion algorithm based on adaptive threshold and morphological processing controls the pixel gradient in the edge transition area, enabling the synthetic defect to be more naturally integrated into the product surface and effectively improving the performance of the defect detection model. Description of the Drawings

[0022] To more clearly illustrate the technical solutions of the embodiments of the present invention, the following will briefly introduce the accompanying drawings required for the description of the embodiments. Obviously, the accompanying drawings in the following description are only some embodiments of the present invention. For those of ordinary skill in the art, without creative efforts, other accompanying drawings can also be obtained based on these drawings.

[0023] Figure 1 This is the overall flowchart of the generative data augmentation method for surface defects of industrial products provided in the first embodiment of the present invention.

[0024] Figure 2 This is the overall flowchart of the generative data augmentation system for surface defects of industrial products provided in the third embodiment of the present invention. Specific Embodiments

[0025] To make the above objects, features, and advantages of the present invention more obvious and understandable, the following will provide a detailed description of the specific embodiments of the present invention in conjunction with the accompanying drawings of the specification. Obviously, the described embodiments are part of the embodiments of the present invention, rather than all of them. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present invention.

[0026] Embodiment 1, referring to Figure 1 , which is an embodiment of the present invention, provides a generative data augmentation method for surface defects of industrial products, including:

[0027] S1: Collect the original industrial product image data and construct a scratch image dataset.

[0028] Furthermore, constructing the scratch image dataset includes using a high-resolution industrial camera to collect the images of finished and defective industrial products, accurately intercepting and preprocessing the scratch area based on image processing technology, excluding the interference of other defects or stains on the product surface, and uniformly processing the intercepted scratch images to avoid the model being overly sensitive to the image size and improve the recognition accuracy of the model.

[0029] It should be noted that uniformly processing the intercepted scratch images includes standardizing the image size to a fixed resolution and converting the image to a grayscale image to reduce the interference of color information on the scratch features and highlight the shape and texture features of the scratches.

[0030] It should also be noted that the high-resolution camera ensures the capture of fine scratch features, accurately intercepts the scratch area, avoids interference from irrelevant backgrounds, significantly improves the quality of the dataset and the efficiency of model training, ensures data consistency, and avoids the model's sensitivity to size. The grayscale image processing highlights the scratch morphology and texture features, reduces color interference, improves the model's robustness and feature extraction efficiency, and effectively solves the problems of uneven data quality and difficult feature extraction in traditional methods.

[0031] S2: Based on the preprocessed scratch image dataset, construct a diffusion model based on the U-Net architecture, and use the Adam optimizer to optimize the model parameters.

[0032] Furthermore, constructing a diffusion model based on the U-Net architecture includes constructing a generative model based on the diffusion model. The forward diffusion formula is expressed as:

[0033] ;

[0034] Where, represents the conditional probability distribution, represents the time step of reverse diffusion, represents the image data at time step the image data at time step represents the image data at time step the image data at time step represents the normal distribution, represents the diffusion coefficient, is the identity matrix. The U-Net architecture is used as the core network of the diffusion model to define the Gaussian diffusion process.

[0035] It should be noted that the generative model includes the diffusion model learning the latent distribution of the data and generating samples similar to the real data distribution, generating scratch images of various shapes, sizes, and directions, and improving the diversity of the dataset and the generalization ability of the model.

[0036] It should be noted that the parameters of using the U-Net architecture as the core network of the diffusion model are expressed as:

[0037] ;

[0038] Where, represents a feature dimension of 64, represents the feature dimension multiplication coefficient, represents the number of input channels. The U-Net architecture can effectively extract image features and perform image segmentation, extract the edge and texture features of the scratch for the generation of scratch images, and lay the foundation for Gaussian diffusion after deployment. The Gaussian diffusion process is expressed as:

[0039] ;

[0040] Among them, represents resizing the image, represents the step size.

[0041] It should be noted that optimizing the model parameters using the Adam optimizer includes adaptively adjusting the diffusion learning rate. The parameters for optimizing the model parameters using the Adam optimizer are represented as:

[0042] ;

[0043] Among them, represents the initial learning rate, represents the exponent in scientific notation, represents the total number of training steps, represents the number of gradient accumulation steps. Introduce mixed-precision training, scale the gradients based on GradScaler, and set the number of gradient accumulation steps using the gradient accumulation strategy. In the training loop, load the scratch image data batch by batch, input the scratch image data into the diffusion model, calculate the loss value through mixed precision, and update the model parameters using the gradient accumulation strategy. Save a model checkpoint every 1000 training steps for subsequent training recovery or model evaluation to improve the training efficiency of the model.

[0044] It should also be noted that the diffusion model learns the scratch image distribution, and the U-Net architecture jointly constructs an efficient and stable scratch image generation model, effectively solving the problems of limited sample diversity and inability to simulate real scenarios in traditional data augmentation methods; using the Adam optimizer to optimize the model parameters avoids gradient disappearance or gradient explosion during model training and improves the convergence speed of the model.

[0045] S3: Use the reverse sampling mechanism to generate high-fidelity scratch images and save the generated images to the specified directory.

[0046] Furthermore, using the reverse sampling mechanism to generate high-fidelity scratch images includes generating scratch images of various shapes, sizes, and directions based on the trained diffusion model, loading the pre-trained model weights to generate new scratch images, and the reverse diffusion formula is expressed as:

[0047] ;

[0048] Among them, represents the conditional probability distribution, represents the parameters of the deep learning model U-Net, represents at time step the image data, represents at time step the image data, represents a normal distribution, represents the mean of the normal distribution, represents the covariance matrix of the normal distribution, represents the time step of reverse diffusion.

[0049] It should be noted that loading the pre-trained model weights includes loading the trained model weights from the saved optimal model file to ensure that the model can generate images based on the learned scratch feature distribution.

[0050] It should also be noted that the reverse sampling mechanism generates samples similar to real scratch images according to the data distribution learned by the diffusion model, ensuring the diversity and authenticity of the generated scratch images. Based on the data augmentation method of the diffusion model, it effectively solves the problems that the samples generated by traditional methods lack diversity and cannot simulate real scenarios.

[0051] S4: Based on image fusion technology, stitch the generated defective product image and the real defective product image to construct a new defective product image.

[0052] Furthermore, constructing a new defective product image includes reading the intact image and the scratch image, locating and extracting the scratch area and the scratch stitching position, and performing weighted mixing on the target area.

[0053] It should be noted that locating and extracting the scratch area and the scratch stitching position includes using Canny edge detection and contour analysis to calculate the center point of the object in the intact image and the range of the area where scratches may appear, and randomly generating a rotated square within the scratch area to locate the stitching position of the scratch.

[0054] It should be noted that performing weighted mixing on the target area includes adjusting the scratch image to the same size as the target area, generating a mask through Gaussian blur, Canny edge detection, and morphological operations, and using the mask to perform weighted mixing on the target area of the scratch image and the intact image to ensure that the scratch naturally blends into the intact image.

[0055] It should also be noted that Canny edge detection and contour analysis accurately locate the scratch area and the scratch stitching position, ensure that the scratch image naturally blends into the intact image, realize the weighted mixing of the scratch image and the intact image, ensure that the scratch edge transitions naturally, and avoid obvious boundaries. The scratch positioning method based on image analysis technology effectively solves the problems in traditional methods that the scratch position is random, lacks naturalness, and the scratch does not blend naturally with the background and is prone to obvious boundaries.

[0056] Embodiment 2, an embodiment of the present invention, provides a generative data augmentation method for surface defects of industrial products. In order to verify the beneficial effects of the present invention, scientific demonstration is carried out through economic benefit calculation and simulation experiments.

[0057] First, use a high-resolution industrial camera to collect 500 finished industrial lid images as background images, and collect 100 industrial lid images with scratches as real scratch images. Grayscale the real scratch images and intercept the scratch areas to form a scratch image dataset. Use the Canny edge detection algorithm to perform edge detection on the background images and extract the range of areas where scratches may appear.

[0058] Use the preprocessed scratch image dataset to train a generative model based on the diffusion model. Use the U-Net architecture as the core network of the diffusion model and set the parameters: the feature dimension is 64, the feature dimension multiplication factor is (1, 2, 4), and the number of input channels is 1. Use the Adam optimizer for model training, with an initial learning rate of 2e-5, a total number of training steps of 7000 steps, and a gradient accumulation step of 4.

[0059] Secondly, use the trained diffusion model to generate 100 new scratch images, combine the generated scratch images with the background images to generate 100 new defective product images, and use the Canny edge detection algorithm and morphological operations to generate masks to ensure the natural fusion of the scratch images and the background images.

[0060] Then, form group A dataset with 500 background images and 100 real scratch images, form group B dataset with group A dataset and 100 generated defective product images. Use the Fast RCNN model to train and evaluate group A and group B datasets, record indicators such as loss values and accuracies of group A and group B models during the training process, and compare and analyze the learning effects and generalization capabilities of the two groups of models, as shown in Table 1:

[0061] Table 1 Comparative analysis table of models

[0062] Experimental group Data volume Ratio of scratch images Model training time Loss value Accuracy Group A 600 16.67% 10h 0.12 70% Group B 700 14.29% 12h 0.08 85%

[0063] By comparing the experimental data of group A and group B in Table 1, the following conclusions can be drawn: The generated defective product images are added to the training process of the group B model, effectively expanding the diversity of the training dataset and enhancing the model's recognition ability for scratch features; The group B model can better learn scratch features and optimize model parameters during the training process, thereby reducing the model loss value; Since the scale of the group B dataset is larger, the model training time increases slightly.

[0064] The experimental results show that the industrial scratch data augmentation method based on the diffusion model proposed in the present invention can effectively improve the recognition accuracy of the scratch detection model and enhance the generalization ability of the model.

[0065] Example 3, refer to Figure 2, which is an embodiment of the present invention, provides a generative data augmentation system for surface defects of industrial products, including a data acquisition and preprocessing module 100, a diffusion model training and generation module 200, and an image fusion and synthesis module 300.

[0066] Among them, S5: The data acquisition and preprocessing module 100 includes an image acquisition sub-module 101 and an image preprocessing sub-module 102.

[0067] Furthermore, the image acquisition sub-module 101 is used to collect image data of industrial products by using a high-resolution industrial camera, precisely intercept defective product images, retain the scratch area, and construct a scratch image dataset; the image preprocessing sub-module 102 is used to standardize the size of the intercepted scratch images to a fixed resolution and convert them into grayscale images to reduce the interference of color information and highlight the scratch features.

[0068] It should be noted that the image acquisition sub-module 101 is the starting point of the data acquisition and preprocessing module 100, which transmits data to the image preprocessing sub-module 102 and provides raw data for subsequent steps; the image preprocessing sub-module 102 uniformly processes the collected images to make the scratch image dataset meet the requirements of model training.

[0069] It should also be noted that the data acquisition and preprocessing module 100 is the core part of the generative data augmentation for surface defects of industrial products, providing a data basis for subsequent diffusion model training and image fusion.

[0070] S6: The diffusion model training and generation module 200 includes a model definition sub-module 201, a diffusion process definition sub-module 202, and a model training and generation sub-module 203.

[0071] Furthermore, the model definition sub-module 201 is used to select the U-Net diffusion model architecture and set model parameters; the diffusion process definition sub-module 202 is used to define the forward or reverse diffusion process to generate images similar to the input images; the model training and generation sub-module 203 is used to train the diffusion model, learn the distribution characteristics of scratch images, and generate new scratch images.

[0072] It should be noted that the model definition sub-module 201 is the basis for the diffusion process definition sub-module 202 and the model training and generation sub-module 203, determining the structure and parameters of the model; the diffusion process definition sub-module 202 is a description of the model learning process; the model training and generation sub-module 203 is the core of the diffusion model training and generation module 200, which learns the distribution characteristics of scratch images through training the model and generates new scratch images through the reverse diffusion process.

[0073] It should also be noted that the diffusion model training and generation module 200 is a prerequisite step for the image fusion and synthesis module 300, and the newly generated scratched image output by the model training and generation module 203 is the input data of the image fusion and synthesis module 300.

[0074] S7: The image fusion and synthesis module 300 includes an image loading and preprocessing sub-module 301, a scratched area location and extraction sub-module 302, and a scratched image stitching sub-module 303.

[0075] Furthermore, the image loading and preprocessing sub-module 301 is used to read the intact image and the generated scratched image, and calculate the center point of the object and the range of the area where scratches may appear using Canny edge detection and contour analysis; the scratched area location and extraction sub-module 302 is used to randomly generate a rotated square within the range of the area where scratches may appear to locate the stitching position of the scratches; the scratched image stitching sub-module 303 is used to adjust the scratched image to the same size as the target area, generate a mask through Gaussian blur and Canny edge detection, and perform weighted mixing of the scratched image and the target area of the intact image to ensure that the scratches are naturally integrated into the intact image.

[0076] It should be noted that the image loading and preprocessing sub-module 301 is the starting point of the image fusion and synthesis module 300, providing the original data for subsequent steps; the performance of the image fusion and synthesis module 300 depends on the quality of the scratched image output by the diffusion model training and generation module 200.

[0077] If the function is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or a part of this technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods in various embodiments of the present invention. The aforementioned storage medium includes: USB flash drives, mobile hard disks, read-only memories (ROM, Read-Only Memory), random access memories (RAM, Random Access Memory), magnetic disks, or optical discs, etc., which can store program codes.

[0078] The logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as a definable sequence list of executable instructions for implementing logical functions, and can be specifically implemented in any computer-readable medium for use by an instruction execution system, apparatus, or device (such as a computer-based system, a system including a processor, or other systems that can fetch and execute instructions from the instruction execution system, apparatus, or device), or used in combination with these instruction execution systems, apparatus, or devices. For the purposes of this specification, a "computer-readable medium" can be any device that can contain, store, communicate, propagate, or transport a program for use by or in combination with an instruction execution system, apparatus, or device.

[0079] More specific examples (non-exhaustive list) of computer-readable media include the following: an electrical connection part (electronic device) having one or more wirings, a portable computer diskette (magnetic device), a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber device, and a portable compact disc read-only memory (CDROM). Additionally, a computer-readable medium can even be paper or other suitable media on which a program can be printed, because the program can be obtained electronically, for example, by optically scanning the paper or other media, followed by editing, interpretation, or other appropriate processing as necessary, and then stored in a computer memory.

[0080] It should be understood that the various parts of the present invention can be implemented by hardware, software, firmware, or a combination thereof. In the above-described embodiments, multiple steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented by hardware, as in another embodiment, any one or a combination of the following techniques well known in the art can be used: discrete logic circuits having logic gate circuits for implementing logical functions on data signals, application-specific integrated circuits having appropriate combinational logic gate circuits, programmable gate arrays (PGAs), field-programmable gate arrays (FPGAs), etc. It should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and not to limit them. Although the present invention has been described in detail with reference to the preferred embodiments, those of ordinary skill in the art should understand that the technical solutions of the present invention can be modified or equivalently replaced without departing from the spirit and scope of the technical solutions of the present invention, and they should all be covered by the scope of the claims of the present invention.

Claims

1. A generative data augmentation method for surface defects of industrial products, characterized in that, Including: Collect the original industrial product image data and construct a scratch image dataset; Based on the preprocessed scratch image dataset, construct a diffusion model based on the U-Net architecture, and use the Adam optimizer to optimize the model parameters; Adopt the reverse sampling mechanism to generate high-fidelity scratch images, and save the generated images to the specified directory; Based on the image fusion technology, stitch the generated defective product images and real defective product images to construct a new defective product image; Constructing the scratch image dataset includes collecting industrial product images through a high-resolution industrial camera, accurately intercepting the scratch areas on the surface of defective products to form a scratch image dataset, and performing unified image size standardization and grayscale processing on the intercepted scratch images; Constructing a diffusion model based on the U-Net architecture includes an encoder and a decoder. The encoder is used to extract image features, and the decoder is used to reconstruct images. The U-Net architecture is used as the core network of the diffusion model, and the Adam optimizer is combined to optimize the model parameters; Adopt the reverse sampling mechanism. Through the reverse sampling mechanism of the diffusion model, learn the distribution characteristics of scratch images, generate images very similar to real scratch images, and use the U-Net network for inverse diffusion to generate high-fidelity scratch images.

2. The generative data augmentation method for surface defects of industrial products according to claim 1, wherein: The construction of the scratch image dataset includes, Use a high-resolution industrial camera to collect the finished and defective product images of industrial products, accurately intercept and preprocess the scratch areas based on image processing technology, and perform unified processing on the intercepted scratch images.

3. The generative data augmentation method for surface defects of industrial products according to claim 2, characterized in that: The unified processing of the intercepted scratch images includes, Standardize the image size to a fixed resolution and convert the image to a grayscale image.

4. The generative data augmentation method for surface defects of industrial products according to claim 3, wherein: The construction of a diffusion model based on the U-Net architecture includes, Construct a generative model based on the diffusion model. The forward diffusion formula is expressed as: where \(q\) represents the conditional probability distribution, \(t\) represents the time step of reverse diffusion, and \(x\) t represents the image data at time step \(t\), and \(x\) t-1 represents the image data at time step \(t - 1\). represents the normal distribution, \(\beta\) represents the diffusion coefficient, \(I\) is the identity matrix, and the U-Net architecture is used as the core network of the diffusion model to define the Gaussian diffusion process.

5. The generative data augmentation method for surface defects of industrial products according to any one of claims 1, 2 or 4, characterized in that: The use of the Adam optimizer to optimize the model parameters includes, Introduce mixed-precision training, scale the gradients based on GradScaler, and use the gradient accumulation strategy to set the gradient accumulation steps.

6. The generative data augmentation method for surface defects of industrial products according to claim 5, characterized in that: The use of the reverse sampling mechanism to generate high-fidelity scratch images includes, Based on the trained diffusion model, load the pre-trained model weights to generate new scratch images. The inverse diffusion formula is expressed as: where p θ represents the conditional probability distribution, θ represents the parameters of the deep learning model U-Net, x t represents the image data at time step t, x t-1 represents the image data at time step t-1, represents the normal distribution, represents the mean of the normal distribution, ∑ θ (x t , t) represents the covariance matrix of the normal distribution, and t represents the time step of reverse diffusion.

7. The generative data augmentation method for surface defects of industrial products according to any one of claims 1, 2, 4 or 6, characterized in that: The construction of the new defective product image includes, Read the intact image and the scratch image, locate and extract the scratch area and the scratch stitching position, and perform weighted mixing on the target area.

8. A generative data augmentation system for surface defects of industrial products, which is used to implement the generative data augmentation method for surface defects of industrial products as described in any one of claims 1 to 7, and is characterized in that: Including a data acquisition and preprocessing module (100), a diffusion model training and generation module (200), and an image fusion and synthesis module (300); The data acquisition and preprocessing module (100) is used to obtain the surface image of the industrial lid through a high-resolution industrial camera, accurately intercept the scratch area, perform standardization and grayscale preprocessing operations, and construct a scratch feature dataset that meets the model input requirements; The diffusion model training and generation module (200) is used to train a diffusion model based on the U-Net architecture, add learning of the scratch distribution through the forward diffusion process, and generate high-fidelity scratch images using the inverse diffusion formula; The image fusion and synthesis module (300) is used for cross-carrier defect migration, fusing the generated grayscale scratch image with the color intact product image, locating the scratch splicing area through Canny edge detection, generating a mask by combining Gaussian blur and morphological operations, and performing weighted mixing to generate a defective product synthesis image for training the detection model.

9. A computer device, comprising a memory and a processor, the memory storing a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the generative data augmentation method for surface defects of industrial products described in any one of claims 1 to 7.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the steps of the generative data augmentation method for surface defects of industrial products described in any one of claims 1 to 7.

Citation Information

Patent Citations

  • A lightweight TFT-LCD module scratch detection method based on a convolutional neural network

    CN109712117A

  • Multi-target image data enhancement method based on adversarial neural network

    CN114519798A