Defect sample data set construction method and device

By fine-tuning training and inference of the Vincentian graph diffusion model to generate new samples, the problem of insufficient number of defect samples in the industrial defect detection model is solved, the efficiency of data set construction and model adaptability are improved, and high-quality and diverse new sample generation is achieved .

CN118537671APending Publication Date: 2024-08-23SHENZHEN LINGYUN VISION TECH CO LTD
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202311816137.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-12-26
Publication Date
2024-08-23

AI Technical Summary

Technical Problem

Existing industrial defect detection models are highly dependent on a large number of labeled defect sample images, and the cost of collecting and labeling these images is high, resulting in an insufficient number of defect samples, limiting the training effect and accuracy of the model, and the efficiency of data enhancement methods in the existing technology Low and inflexible.

Method used

By fine-tuning and training the Vincentian graph diffusion model, new defect sample images are generated, and a rich and diverse defect sample data set is constructed. The fine-tuned and trained model is used for inference to generate new samples, and combined with the preset screening rules and guidance factors, the generation is improved. Sample diversity and quality.

Benefits of technology

It improves the efficiency of constructing defect sample data sets, generates new defect sample images with high quality and diversity, enhances the adaptability and generalization ability of industrial defect detection models, and solves the problem of insufficient sample number.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118537671A
    Figure CN118537671A
Patent Text Reader

Abstract

The invention discloses a defect sample data set construction method and device, an industrial defect detection model training method and device, electronic equipment and a computer storage medium, and belongs to the technical field of industrial defect detection. The construction of the work defect sample data set comprises the following steps: acquiring an initial defect sample data set; according to the initial defect sample data set, performing fine-tuning training on the text graph diffusion model to obtain a text graph diffusion model after fine-tuning training; reasoning according to the fine-tuning trained text graph diffusion model to generate a new defect sample image; and constructing a defect sample data set according to the new defect sample image. According to the technical scheme provided by the embodiment of the invention, the defect sample data set can be efficiently constructed.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application belongs to the field of industrial defect detection technology, and in particular relates to a method and device for constructing a defect sample data set, a method and device for training an industrial defect detection model, and an electronic device and a computer storage medium. Background Art

[0002] In the industrial field, more and more industrial defect detection models using deep learning are used for defect detection, but they also face a significant challenge, that is, the above industrial defect detection models are highly dependent on a large number of labeled defect sample images. However, in the industrial field, the cost of collecting and labeling these defect sample images is high; limited defect sample images will further limit the effectiveness of training industrial defect detection models and the accuracy of trained industrial defect detection models. Therefore, how to enhance the training effect of the model by creating new defect sample images from the perspective of data processing has become a difficult problem to be solved.

[0003] The prior art uses traditional data enhancement technology and defect injection methods to create more training samples based on limited defect sample images through technical means. For example, the diversity of samples can be increased by rotating, scaling, cropping, etc. At the same time, various defects can be injected into the samples manually or semi-automatically to simulate the different types and degrees of defects that may occur in real industrial environments. Through such sample data expansion, the industrial defect detection model can be trained on a richer and more diverse defect sample data set. However, the above technical solutions of the prior art lack flexible learning capabilities. For different types of defects, different combination strategies need to be manually designed, and the construction efficiency of its defect sample data set is low. Summary of the invention

[0004] The present application aims to solve at least one of the technical problems existing in the prior art. To this end, the present application proposes a method and device for constructing a defect sample data set, a method and device for training an industrial defect detection model, and an electronic device and a computer storage medium, which can improve the efficiency of constructing a defect sample data set.

[0005] In a first aspect, the present application provides a method for constructing a defect sample dataset, comprising:

[0006] Obtain an initial defect sample data set;

[0007] Fine-tune the Vincent graph diffusion model according to the initial defect sample data set to obtain a fine-tune Vincent graph diffusion model;

[0008] Perform inference based on the fine-tuned trained Vincent graph diffusion model to generate new defect sample images;

[0009] Construct a defect sample dataset based on new defect sample images.

[0010] In some embodiments, constructing a defect sample dataset according to a new defect sample image includes:

[0011] A defect sample dataset is constructed based on the initial defect sample dataset and the new defect sample images.

[0012] In some embodiments, the initial defect sample data set includes defect images of at least one defect category, and fine-tuning the Vincent graph diffusion model according to the initial defect sample data set to obtain the fine-tuned Vincent graph diffusion model includes:

[0013] For each defect category, a first fine-tuning training sample is constructed based on the defect image of the defect category, and the corresponding defect category identifier and product name identifier; a second fine-tuning training sample is constructed based on all defect images in the initial defect sample data set, and the corresponding product name identifier;

[0014] The Vincent graph diffusion model is trained by using the first fine-tuning training sample and the second fine-tuning training sample at the same time to obtain a Vincent graph diffusion model after fine-tuning training. The Vincent graph diffusion model after fine-tuning training corresponds to the defect category one by one.

[0015] In some embodiments, performing reasoning based on the fine-tuned trained Vincent graph diffusion model to generate a new defect sample image includes:

[0016] Constructing text prompt words based on the product name identifier and the defect category identifier of each defect category;

[0017] Based on the textual cues, the fine-tuned trained text graph diffusion model is used for inference to generate new defect sample images for each defect category.

[0018] In some embodiments, a text prompt word is constructed according to the product name identifier and the defect category identifier of each defect category, including:

[0019] The text prompt words are constructed based on the product name identifier, the defect category identifier of each defect category, and the painting style identifier.

[0020] In some embodiments, based on the text prompt word, when the fine-tuned and trained document graph diffusion model is used for reasoning, the guidance factor of the document graph diffusion model is set within a preset numerical range.

[0021] In some embodiments, the preset value range of the guidance factor is greater than or equal to 5 and less than or equal to 7.5.

[0022] In some embodiments, before constructing the defect sample dataset according to the new defect sample image, the method further includes:

[0023] Screening the new defect sample image according to a preset screening rule to obtain a screened new defect sample image;

[0024] The above-mentioned step of constructing a defect sample data set according to the new defect sample image includes:

[0025] Construct a defect sample dataset based on the screened new defect sample images.

[0026] In some embodiments, screening the new defect sample image according to a preset screening rule to obtain a screened new defect sample image includes:

[0027] According to the pre-trained classification model, the new defect sample image is classified into defect categories to determine the category classification result;

[0028] Obtaining the confidence of the classification result of the new defect sample image;

[0029] The new defect sample images are screened according to the confidence of the category classification result to obtain screened new defect sample images.

[0030] In some embodiments, screening the new defect sample image according to a preset screening rule to obtain a screened new defect sample image includes:

[0031] Obtaining a first feature vector of a new defect sample image and a second feature vector of a defect sample image of an initial defect sample data set;

[0032] Obtaining a vector distance between the first eigenvector and the second eigenvector;

[0033] A new defect sample image whose vector distance is greater than a preset value is selected as a new defect sample image after screening.

[0034] In a second aspect, the embodiment of the present application further provides a method for training an industrial defect detection model, including:

[0035] Construct a defect sample data set through the above method;

[0036] The industrial defect detection model is trained according to the defect sample data set.

[0037] In a third aspect, the embodiment of the present application further provides a device for constructing a defect sample data set, including:

[0038] An initial sample acquisition module is used to acquire an initial defect sample data set;

[0039] A fine-tuning training module is used to perform fine-tuning training on the Vincent graph diffusion model according to the initial defect sample data set to obtain a fine-tuned Vincent graph diffusion model;

[0040] A new sample generation module is used to generate new defect sample images by performing reasoning based on the fine-tuned trained Vincent graph diffusion model;

[0041] The sample set construction module is used to construct a defect sample data set according to the new defect sample image.

[0042] In a fourth aspect, the present application also provides a training device for an industrial defect detection model, including:

[0043] A sample construction module, used to construct a defect sample data set by using the defect sample data set construction device mentioned above;

[0044] The model training module is used to train the industrial defect detection model based on the defect sample data set.

[0045] In a fifth aspect, the present application provides an electronic device comprising a processor and a memory, wherein the processor is used to execute a computer program in the memory, and the computer program can execute the above-mentioned method for constructing a defect sample data set or the method for training an industrial defect detection model.

[0046] In a sixth aspect, the present application provides a computer storage medium for storing a computer program, which can execute the above-mentioned method for constructing a defect sample data set of industrial products or the method for training an industrial defect detection model.

[0047] The embodiment of the present application provides a technical solution for constructing a defect sample data set, which realizes the training of the existing Wensheng graph diffusion model so that it can learn the defect characteristics of each defect category, as well as the image characteristics and image style of the overall product image, so that it can generate new defect sample images of each defect category during the reasoning process. The present application constructs a defect sample data set based on the new defect sample patterns of each defect category mentioned above, so that on the one hand, it has the advantages of high construction efficiency in the process of generating new defect sample images and constructing data sets, and on the other hand, it can construct new defect sample images with characteristics of various defect categories, so that the subsequent industrial defect detection model has better adaptability and generalization ability, and in the above implementation, by adding painting style and guiding factor settings, the diversity of the generated new defect sample images can be further improved to obtain richer new defect sample images.

[0048] Additional aspects and advantages of the present application will be given in part in the description below, and in part will become apparent from the description below, or will be learned through the practice of the present application. BRIEF DESCRIPTION OF THE DRAWINGS

[0049] The above and / or additional aspects and advantages of the present application will become apparent and easily understood from the description of the embodiments in conjunction with the following drawings, in which:

[0050] Figure 1 A flowchart of a method for generating a defect sample in an embodiment of the present application;

[0051] Figure 2 In the embodiment of this application Figure 1 The specific flow chart of step 102 is shown;

[0052] Figure 3 This is a specific flow chart of step 103 in the embodiment of the present application;

[0053] Figure 4 is a flowchart of another method for constructing a defect sample data set in an embodiment of the present disclosure;

[0054] Figure 5 The specific implementation process of step 105 in the embodiment of the present application is shown as follows: Figure 1 ;

[0055] Figure 6 The specific implementation process of step 105 in the embodiment of the present application is shown as follows: Figure 2 ;

[0056] Figure 7 A flowchart of a method for training an industrial defect detection model in an embodiment of the present application;

[0057] Figure 8 A schematic diagram of the structure of a device for constructing a defect sample data set in an embodiment of the present application;

[0058] Fig. 9 This is a schematic diagram of the structure of a training device for an industrial defect detection model in an embodiment of the present application;

[0059] Fig.10 This is a schematic diagram of the structure of an electronic device in an embodiment of the present application. DETAILED DESCRIPTION

[0060] The embodiments of the present application will be described in more detail below with reference to the accompanying drawings. Although certain embodiments of the present application are shown in the accompanying drawings, it should be understood that the present application can be implemented in various forms and should not be construed as being limited to the embodiments described herein. Instead, these embodiments are provided to provide a more thorough and complete understanding of the present application. It should be understood that the drawings and embodiments of the present application are only for exemplary purposes and are not intended to limit the scope of protection of the present application.

[0061] It should be understood that the various steps described in the method implementation of the present application can be performed in different orders and / or performed in parallel. In addition, the method implementation may include additional steps and / or omit the steps shown. The scope of the present application is not limited in this respect.

[0062] The term "including" and its variations used herein are open inclusions, i.e., "including but not limited to". The term "based on" means "based at least in part on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". The relevant definitions of other terms will be given in the following description.

[0063] It should be noted that the concepts such as "first" and "second" mentioned in this application are only used to distinguish different devices, modules or units, and are not used to limit the order or interdependence of the functions performed by these devices, modules or units.

[0064] It should be noted that the modifications of "one" and "plurality" mentioned in the present application are illustrative rather than restrictive, and those skilled in the art should understand that unless otherwise clearly indicated in the context, it should be understood as "one or more".

[0065] In the prior art, it is difficult to collect enough defect sample images in industrial defect detection technology, resulting in the problem of insufficient number of defect sample images, which in turn affects the subsequent training of the industrial defect detection model used. The insufficient number of samples obviously cannot guarantee the training effect. Although the prior art can use data enhancement technology and defect injection methods to create more training sample images based on limited defect samples, there is still the defect of low generation efficiency, which also limits the adaptability and generalization ability of the industrial defect detection model.

[0066] An embodiment of the present application provides a scheme for constructing a defect sample data set, in which a new defect sample image is generated by using a Vincent graph diffusion model, and the Vincent graph diffusion model has good learning ability; at the same time, considering that the cost of retraining the diffusion model is high when training the diffusion model, a fine-tuning strategy is first used in an embodiment of the present application to construct an initial defect sample data set based on a small number of existing defect images, and the Vincent graph diffusion model is fine-tuned and trained using the fine-tuned Vincent graph diffusion model, so that the Vincent graph diffusion model after fine-tuning training can be more suitable for industrial scenarios, and the Vincent graph diffusion model can be quickly migrated from natural images to industrial scenarios. The Vincent graph diffusion model after fine-tuning training can subsequently be used to quickly perform inference and generate high-quality new defect sample images, and then a defect sample data set is constructed based on the new defect sample images, thereby realizing the generation of defect sample images and solving the problem of lack of sufficient defect sample images in industrial defect detection technology.

[0067] The technical solutions of the embodiments of the present application are described in detail below with reference to the accompanying drawings. Figure 1 FIG. 1 is a flow chart of a method for generating a defect sample in an embodiment of the present application. The method can be executed on an electronic device, including but not limited to a server, a local computer, etc. Figure 1 As shown, the method comprises the following steps:

[0068] Step 101: Obtain an initial defect sample data set;

[0069] In this step, defect images in industrial scenes are collected, and then an initial defect sample data set is constructed. Usually, the number of defect images in industrial scenes is small, which cannot meet the needs of directly training the industrial defect detection model. However, in the embodiment of the present application, it can realize fine-tuning training of the Vincent graph diffusion model. Therefore, in this step, defect images are collected and an initial defect sample data set is constructed. Furthermore, the collected defect images can be annotated and the defect category of each defect image can be determined.

[0070] Step 102: fine-tune the Vincent graph diffusion model according to the initial defect sample data set to obtain a fine-tune Vincent graph diffusion model;

[0071] The Vincent graph diffusion model used in the embodiments of the present application can use an existing diffusion model as a base, such as the stable diffusion model Stable diffusion, or other diffusion models with similar functions. Since the usage scenarios and initial settings of this type of model are quite different from the specific industrial scenarios in the embodiments of the present application, the Vincent graph diffusion model is not directly applied in the embodiments of the present application to generate defect sample images. Instead, the Vincent graph diffusion model is first fine-tuned using the initial defect sample data set collected in the specific industrial scenario. The learning ability of the diffusion model is used to enable it to learn the style and feature representation of the defect image in the specific industrial scenario, and obtain a diffusion model adapted to the specific industrial scenario. In the specific fine-tuning training process, the maximum number of iterations can be set in advance, and the fine-tuning training is completed when the maximum number of iterations is met.

[0072] During the specific execution of the fine-tuning training process of this step, in order to allow the diffusion model to learn the overall characteristics of the industrial scenario and the specific defect characteristics of each defect category, the above two parts of the training process are executed simultaneously during the fine-tuning training process; at the same time, for the Vincent graph diffusion model after fine-tuning training, in order to ensure that it can generate defect sample images of different defect categories, the Vincent graph diffusion model after fine-tuning training also corresponds to the defect category one by one, and each defect type is set with a corresponding Vincent graph diffusion model. The specific execution process of this step is described below. Figure 2 In the embodiment of this application Figure 1 The specific flow chart of step 102 is shown in FIG. Figure 2 As shown, the following steps are included:

[0073] Step 201: for each defect category, a first fine-tuning training sample is constructed based on the defect image of the defect category, and the corresponding defect category identifier and product name identifier; a second fine-tuning training sample is constructed based on all defect images in the initial defect sample data set, and the corresponding product name identifier;

[0074] When the initial defect sample data set is established in step 101, the defect category of each defect image has been determined, in order to be able to fine-tune and train the Vincent graph diffusion model corresponding to each defect category. In this step, a training sample for training the Vincent graph diffusion model for each defect category is first constructed; therefore, in this step, for each defect category, first, based on the defect image of the defect category, and the corresponding defect category identifier and product name identifier, a first fine-tuning training sample is first constructed, and the "defect category identifier" "product name identifier" in the first fine-tuning training sample is used as a text prompt word; second, based on all the defect images in the initial defect sample data set, and the corresponding product name identifier, a second fine-tuning training sample is constructed, and the "product name identifier" in the second fine-tuning training sample is used as another text prompt word. In the above embodiments of the present application, the defect category identifier can represent different defect categories, and the product name identifier can represent specific industrial products. The specific naming method can be determined according to the requirements of the Vincent graph diffusion model.

[0075] Step 202: training the Vincent graph diffusion model using the first fine-tuning training sample and the second fine-tuning training sample at the same time to obtain a Vincent graph diffusion model after fine-tuning training, wherein the Vincent graph diffusion model after fine-tuning training corresponds one-to-one to the defect category;

[0076] The first fine-tuning training sample constructed in the above step 201 only includes defect images of the defect category, and the defect category identifier and product name identifier therein are used as text prompt words input to the Vincent graph diffusion model, so that the defect characteristics of the defect category can be fully learned during the training process using the first fine-tuning training sample; the second fine-tuning training sample constructed above includes all defect images in the initial defect sample data set, and the product name identifier is used as a text prompt word input to the Vincent graph diffusion model, which can learn all features of the image under the industrial defect, including the image features of the background part of the defect image. In this step, the Vincent graph diffusion model is trained using the above first fine-tuning training sample and the second fine-tuning training sample at the same time, so that the Vincent graph diffusion model after fine-tuning training corresponding to the defect category can be obtained. On the one hand, the defect style and characteristics of a specific category can be learned, and bound to the text prompt words including the defect category identifier and the product name identifier; on the other hand, the overall characteristics of the defect image can be learned and bound to the product name identifier, and at the same time, the Vincent graph diffusion model can be prevented from overfitting to a specific defect category.

[0077] In the embodiment of the present application, the Vincent graph diffusion model is fine-tuned and trained by the above technical solution, so that the Vincent graph diffusion model after fine-tuning and training can generate new sample defect images that are similar in style to the defect images in the original industrial scene and have diverse defect features. Based on the fine-tuning training scheme, if there are N defect categories, N Vincent graph diffusion models will be obtained after fine-tuning and training.

[0078] In the implementation of the present application, during the fine-tuning training process, in which the Vincent graph diffusion model is trained simultaneously using the first fine-tuning training sample and the second fine-tuning training sample, weight coefficient sharing is achieved, and the training of the above two samples can be performed alternately. The proportion used by each sample can be controlled by the loss function of the Vincent graph diffusion model, so that whether it is the first fine-tuning training sample or the second fine-tuning training sample, the loss value of the loss function is within the required range.

[0079] Step 103, performing reasoning according to the fine-tuned trained Vincent graph diffusion model to generate a new defect sample image;

[0080] After fine-tuning the Vincent graph diffusion model, the fine-tuned Vincent graph diffusion model can be used in this step to generate new defect sample images. For the Vincent graph diffusion model used in the embodiments of the present application, it can generate images based on text prompts. Therefore, in some embodiments, text prompts can be constructed first, and then new defect sample images can be generated based on the text prompts. Specifically, Figure 3 shown.

[0081] Figure 3 103 is a specific flow chart of step 103 in the embodiment of the present application. Figure 3 As shown, the following steps are included:

[0082] Step 301: construct a text prompt word according to the product name identifier and the defect category identifier of each defect category;

[0083] For the fine-tuned and trained Vincent graph diffusion model in the above embodiment, it has learned the defect features of each defect category, as well as the image features and image style of the overall product image. When using the Vincent graph diffusion model for reasoning, this step can be used to construct text prompt words based on the product name identifier and the defect category identifier of each defect category. In addition, the number of constructed text prompt words is the same as the number of defect categories, and corresponding text prompt words can be constructed for each defect category. The text prompt word can specifically be in the form of "a "defect category identifier" "product name identifier"".

[0084] Step 302: Based on the text prompt words, the fine-tuned and trained Vignette diffusion model is used for inference to generate new defect sample images for each defect category.

[0085] In this step, since the Vincent Image Diffusion Model has basic image generation capabilities and has learned the defect features of each defect category, as well as the image features and image style of the overall product image during the fine-tuning training process, it can generate new defect sample images for each defect category during the inference process.

[0086] In some embodiments, in order to improve the diversity of new defect images of each defect category generated by the Wensheng graph diffusion model, a style identifier can be added to the text prompt word, and multiple style identifiers can be set to generate new defect sample images with different styles. In the embodiment of the present application, the above step 302 constructs a text prompt word according to the product name identifier and the defect category identifier of each defect category, which can specifically include:

[0087] The text prompt words are constructed based on the product name identifier, the defect category identifier of each defect category, and the painting style identifier.

[0088] Specifically, the text prompt word can be in multiple forms such as "a photo of an "identifier" "object name", "a sketch of an "identifier" "object name", or "a 3D rendering of an "identifier" "object name". By adding different painting style identifiers to the text prompt words, the generated new defect sample images can have different painting styles, thereby fully improving their diversity.

[0089] In some embodiments, based on the above-mentioned text prompt words, when the fine-tuned trained Vincent graph diffusion model is used for reasoning, the guiding factor of the Vincent graph diffusion model can be set. In the Vincent graph diffusion model, the guiding factor mainly controls the quality and diversity of image generation. The higher the guiding factor is set, the higher the quality of the generated image, that is, the higher the matching degree with the text prompt word, and the lower the guiding factor is set, the better the diversity of the generated image. In the embodiment of the present application, the guiding factor is set so that it takes into account both the generation quality and diversity requirements. Therefore, in the embodiment of the present application, the guiding factor of the Vincent graph diffusion model is set within a preset numerical range, and the preset numerical range is greater than or equal to 5 and less than or equal to 7.5.

[0090] Step 104: construct a defect sample data set according to the new defect sample image.

[0091] Through the above steps of the embodiment of the present application, the existing Wensheng graph diffusion model is trained to enable it to learn the defect characteristics of each defect category, as well as the image characteristics and image style of the overall product image, so that it can generate new defect sample images of each defect category during the reasoning process. This step is to construct a defect sample data set based on the new defect sample patterns of each defect category mentioned above. On the one hand, it has the advantages of high construction efficiency in the process of generating new defect sample images and constructing data sets. On the other hand, it can construct new defect sample images with characteristics of various defect categories, so that the subsequent industrial defect detection model has better adaptability and generalization ability. In addition, by adding painting style and guiding factor settings in the above steps, the diversity of the generated new defect sample images can be further improved to obtain richer new defect sample images.

[0092] In the above embodiments of the present application, when constructing a defect sample data set, in addition to including a new defect sample image, an initial defect sample data set may also be included, that is, the defect sample data set is constructed according to the new defect sample image, including: constructing a defect sample data set according to the initial defect sample data set and the new defect sample image.

[0093] Figure 4 is a flow chart of another method for constructing a defect sample data set in an embodiment of the present disclosure, such as Figure 4 It is stated that Figure 1 Based on the embodiment shown, it also includes:

[0094] Step 105: Screening the new defect sample image according to a preset screening rule to obtain a screened new defect sample image;

[0095] This step can also preset certain screening rules to screen the new defect sample images inferred by the above-mentioned Wensheng graph diffusion model based on the screening rules, so as to obtain samples with better quality and / or more extensive diversity. The preset rules can be determined based on confidence or vector distance, etc., and can be specifically referred to as follows Figure 5 and Figure 6 The embodiment shown.

[0096] In the embodiment of the present application, step 104 specifically includes:

[0097] Construct a defect sample dataset based on the screened new defect sample images.

[0098] Figure 5 The specific implementation process of step 105 in the embodiment of the present application is shown as follows: Figure 1 ,like Figure 6 As shown, it includes the following steps:

[0099] Step 501: perform defect classification processing on the new defect sample image according to the pre-trained classification model to determine the classification result;

[0100] Step 502: Obtain the confidence level of the classification result of the new defect sample image;

[0101] Step 503: Screen the new defect sample images according to the confidence of the category classification result to obtain new defect sample images whose confidence reaches a preset threshold as the screened new defect sample images.

[0102] By screening new defect sample images according to the confidence level, new defect sample images with unclear classification results or misclassified ones can be deleted, thereby obtaining new defect sample images with higher quality.

[0103] Figure 6 The specific implementation process of step 105 in the embodiment of the present application is shown as follows: Figure 2 ,like Figure 6 As shown, it includes the following steps:

[0104] Step 601, obtaining a first feature vector of a new defect sample image and a second feature vector of a defect sample image of an initial defect sample data set;

[0105] Step 602: Obtain the vector distance between the first eigenvector and the second eigenvector;

[0106] Step 603: Select new defect sample images whose vector distance is greater than a preset value as the screened new defect sample images.

[0107] In the embodiment of this step, by selecting new defect sample images whose vector distance is greater than a preset value, it is possible to select a certain amount of samples that are distributed far away from the initial defect sample data set, so that the samples in the final defect sample data set are more extensive and diverse, thereby enabling the downstream industrial product defect detection model to learn more extensive and diverse knowledge.

[0108] Figure 7 A training method for an industrial defect detection model in an embodiment of the present application is as follows: Figure 7 As shown, including:

[0109] Step 701: Obtain the Figure 1-Figure 6 A defect sample data set constructed by any one of the method embodiments;

[0110] As recorded in the above embodiments of the present application, the defect sample data set obtained in this step has high generation efficiency, and the generated new defect sample images have high quality, and can well reflect the defect image style and feature representation of each defect category. At the same time, it has the advantage of wider diversity and is far from the concentrated distribution of the initial defect sample data set.

[0111] Step 702: Train the industrial defect detection model based on the defect sample data set.

[0112] The industrial defect detection model in this step is a variety of models that can be trained using defect sample data sets and directly or indirectly detect defects in industrial products. It can include a classification model that can distinguish whether there are defects, a defect area division model that can divide defect areas, or a defect area extraction model that can extract defect areas. After the industrial defect detection model is trained using the high-quality defect sample data set generated in the above embodiment, due to the above advantages of the defect sample data set, the trained industrial defect detection model has good adaptability, detection accuracy and generalization ability.

[0113] Corresponding to the above method embodiment, the present application embodiment also provides a device for constructing a defect sample data set. Figure 8 FIG. 1 is a schematic diagram of a structure of a device for constructing a defect sample data set in an embodiment of the present application. Figure 8 As shown, it includes an initial sample acquisition module 11, a fine-tuning training module 12, a new sample generation module 13 and a sample construction module 14, wherein the initial sample acquisition module 11 is used to obtain an initial defect sample data set; the fine-tuning training module 12 is used to fine-tune the Vincent graph diffusion model according to the initial defect sample data set to obtain the Vincent graph diffusion model after fine-tuning training; the new sample generation module 13 is used to perform inference according to the Vincent graph diffusion model after fine-tuning training to generate new defect sample images; the sample set construction module 14 is used to construct a defect sample data set according to the new defect sample images.

[0114] In some embodiments, the sample set construction module 12 is specifically configured to construct a defect sample data set according to the initial defect sample data set and the new defect sample image.

[0115] In some embodiments, the initial defect sample data set includes defect images of at least one defect category, and the fine-tuning training module 12 includes:

[0116] A fine-tuning training sample construction unit is used to construct a first fine-tuning training sample for each defect category according to the defect image of the defect category, and the corresponding defect category identifier and product name identifier; and to construct a second fine-tuning training sample according to all defect images in the initial defect sample data set, and the corresponding product name identifier;

[0117] A training unit is used to train the Vincent graph diffusion model using the first fine-tuning training sample and the second fine-tuning training sample at the same time to obtain a Vincent graph diffusion model after fine-tuning training, wherein the Vincent graph diffusion model after fine-tuning training corresponds one-to-one to the defect category.

[0118] In some embodiments, the new sample generation module 13 includes:

[0119] A prompt word construction unit, used for constructing a text prompt word according to a product name identifier and a defect category identifier of each defect category;

[0120] The reasoning unit is used to perform reasoning based on the text prompt words using the fine-tuned trained text graph diffusion model to generate new defect sample images for each defect category.

[0121] In some embodiments, the prompt word construction unit is specifically used to construct a text prompt word according to the product name identifier, the defect category identifier of each defect category, and the painting style identifier.

[0122] In some embodiments, when the reasoning unit performs reasoning based on the text prompt word using the fine-tuned and trained document graph diffusion model, the reasoning unit sets the guidance factor of the document graph diffusion model within a preset value range.

[0123] In some embodiments, the preset value range of the guidance factor is greater than or equal to 5 and less than or equal to 7.5.

[0124] In some embodiments, a screening unit is further included, which is used to screen the new defect sample images according to a preset screening rule before constructing the defect sample data set according to the new defect sample images to obtain screened new defect sample images;

[0125] The sample set construction module 14 is specifically configured to construct a defect sample data set according to the screened new defect sample images.

[0126] In some embodiments, the above-mentioned screening unit is specifically used to perform defect category classification processing on the new defect sample image according to a pre-trained classification model to determine the category classification result; obtain the confidence of the category classification result of the new defect sample image; and screen the new defect sample image according to the confidence of the category classification result to obtain a screened new defect sample image.

[0127] In some embodiments, the above-mentioned screening unit is specifically used to obtain a first feature vector of a new defect sample image and a second feature vector of a defect sample image of an initial defect sample data set; obtain a vector distance between the first feature vector and the second feature vector; and select a new defect sample image whose vector distance is greater than a preset value as a new defect sample image after screening.

[0128] The present application embodiment provides a device for constructing a defect sample data set, which is similar to the above Figure 1-6 Corresponding to any of the method embodiments shown, the above method can be executed and the corresponding technical effect can be achieved. The embodiments of the present application will not be described in detail. The specific methods and technical effects achieved can refer to the above embodiments.

[0129] Fig. 9 A training device for an industrial defect detection model in an embodiment of the present application, such as Fig. 9 As shown, the training device of the industrial defect detection model includes: a sample construction module 21 and a model training module 22.

[0130] Sample building block 21, for Figure 8 The defect sample data set construction device shown constructs the defect sample data set;

[0131] The model training module 22 is used to train the industrial defect detection model according to the defect sample data set.

[0132] The present application embodiment provides a training device for an industrial defect detection model, which is similar to the above Figure 8 Corresponding to any of the method embodiments shown, the above method can be executed and the corresponding technical effect can be achieved. The embodiments of the present application will not be described in detail. The specific methods and technical effects achieved can refer to the above embodiments.

[0133] The following specific reference Fig.10 , which shows a schematic diagram of the structure of an electronic device 700 suitable for implementing the embodiment of the present application. The electronic device 700 in the embodiment of the present application may include but is not limited to mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. The electronic device shown is only an example and should not bring any limitation to the functions and occupancy range of the embodiments of the present application.

[0134] like Fig.10As shown, the electronic device 700 may include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 701, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 702 or a program loaded from a storage device 708 into a random access memory (RAM) 703. In the RAM 703, various programs and data required for the operation of the electronic device 600 are also stored. The processing device 701, the ROM 702, and the RAM 703 are connected to each other via a bus 704. An input / output (I / O) interface 705 is also connected to the bus 704.

[0135] Typically, the following devices may be connected to the I / O interface 705: input devices 706 including, for example, a touch screen, a touchpad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; output devices 707 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; storage devices 708 including, for example, a magnetic tape, a hard disk, etc.; and communication devices 709. The communication device 709 may allow the electronic device 700 to communicate with other devices wirelessly or by wire to exchange data. Although the electronic device 700 having various devices is shown, it should be understood that it is not required to implement or have all the devices shown. More or fewer devices may be implemented or have alternatively.

[0136] In particular, according to an embodiment of the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present application includes a computer program product, which includes a computer program carried on a non-transitory computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through a communication device 709, or installed from a storage device 708, or installed from a ROM 702. When the computer program is executed by the processing device 701, the above-mentioned functions defined in the detection method of the industrial product of the embodiment of the present application are executed.

[0137] It should be noted that the computer-readable medium mentioned above in the present application may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present application, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present application, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. The computer readable signal medium may also be any computer readable medium other than a computer readable storage medium, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer readable medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.

[0138] In some embodiments, the client and the server may communicate using any currently known or future developed network protocol such as HTTP (HyperText Transfer Protocol), and may be interconnected with any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), an internet (e.g., the Internet), and a peer-to-peer network (e.g., an ad hoc peer-to-peer network), as well as any currently known or future developed network.

[0139] The computer-readable medium may be included in the electronic device, or may exist independently without being incorporated into the electronic device.

[0140] The computer-readable medium carries one or more programs. When the one or more programs are executed by the electronic device, the electronic device:

[0141] Obtain an initial defect sample data set;

[0142] Fine-tune the Vincent graph diffusion model according to the initial defect sample data set to obtain a fine-tune Vincent graph diffusion model;

[0143] Perform inference based on the fine-tuned trained Vincent graph diffusion model to generate new defect sample images;

[0144] Construct a defect sample dataset based on new defect sample images.

[0145] or,

[0146] Construct a defect sample data set through the above method;

[0147] The industrial defect detection model is trained based on the defect sample dataset.

[0148] Computer program code for performing the operations of the present application may be written in one or more programming languages ​​or a combination thereof, including, but not limited to, object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer via any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).

[0149] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present application. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0150] The units involved in the embodiments described in this application may be implemented by software or hardware, wherein the name of a unit does not, in some cases, constitute a limitation on the unit itself.

[0151] The functions described above herein may be performed at least in part by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), and the like.

[0152] In the context of the present application, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0153] According to one or more embodiments of the present application, the present application provides a computer-readable storage medium, which stores a computer program, and the computer program is used to execute any method for constructing a defect sample data set or training an industrial defect detection model as provided in the present application.

[0154] The above description is only a preferred embodiment of the present application and an explanation of the technical principles used. Those skilled in the art should understand that the scope of disclosure involved in the present application is not limited to the technical solution formed by a specific combination of the above technical features, but should also cover other technical solutions formed by any combination of the above technical features or their equivalent features without departing from the above disclosed concept. For example, the above features are replaced with the technical features with similar functions disclosed in this application (but not limited to) by each other to form a technical solution.

[0155] In addition, although each operation is described in a specific order, this should not be construed as requiring these operations to be performed in the specific order shown or to be performed in a sequential order. Under certain circumstances, multitasking and parallel processing may be advantageous. Similarly, although some specific implementation details are included in the above discussion, these should not be construed as limiting the scope of the application. Some features described in the context of a separate embodiment can also be implemented in a single embodiment in combination. On the contrary, the various features described in the context of a single embodiment can also be implemented in multiple embodiments individually or in any suitable sub-combination mode.

[0156] Although the subject matter has been described in language specific to structural features and / or methodological logical actions, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or actions described above. On the contrary, the specific features and actions described above are merely example forms of implementing the claims.

Claims

1. A method for constructing a defect sample data set, characterized in that: include: Obtain an initial defect sample data set; Fine-tune the Vincent graph diffusion model according to the initial defect sample data set to obtain a fine-tune Vincent graph diffusion model; Performing reasoning based on the fine-tuned trained Vincent graph diffusion model to generate new defect sample images; A defect sample data set is constructed according to the new defect sample image.

2. The method according to claim 1, characterized in that The step of constructing a defect sample data set according to the new defect sample image comprises: A defect sample dataset is constructed according to the initial defect sample dataset and the new defect sample image.

3. The method according to claim 1, characterized in that The initial defect sample data set includes defect images of at least one defect category, and fine-tuning the Vincent graph diffusion model according to the initial defect sample data set to obtain the Vincent graph diffusion model after fine-tuning training includes: For each defect category, a first fine-tuning training sample is constructed based on defect images of the defect category, and corresponding defect category identifiers and product name identifiers; a second fine-tuning training sample is constructed based on all defect images in the initial defect sample data set, and corresponding product name identifiers; The Vincent graph diffusion model is trained by using the first fine-tuning training sample and the second fine-tuning training sample to obtain a fine-tuned Vincent graph diffusion model, and the fine-tuned Vincent graph diffusion model corresponds to the defect category one by one.

4. The method according to claim 3, characterized in that The method of performing reasoning based on the fine-tuned trained Vincent graph diffusion model to generate a new defect sample image includes: Constructing text prompt words based on the product name identifier and the defect category identifier of each defect category; Based on the text prompt words, the fine-tuned and trained Vincent graph diffusion model is used for reasoning to generate new defect sample images for each defect category.

5. The method according to claim 4, characterized in that The step of constructing a text prompt word according to the product name identifier and the defect category identifier of each defect category includes: The text prompt words are constructed based on the product name identifier, the defect category identifier of each defect category, and the painting style identifier.

6. The method according to claim 4, characterized in that When the text prompt word is used to perform reasoning using the fine-tuned and trained document graph diffusion model, the guidance factor of the document graph diffusion model is set within a preset value range.

7. The method according to claim 6, characterized in that The preset value range of the guiding factor is greater than or equal to 5 and less than or equal to 7.

5.

8. The method according to claim 1, characterized in that Before constructing the defect sample data set according to the new defect sample image, the method further includes: Screening the new defect sample image according to a preset screening rule to obtain a screened new defect sample image; The step of constructing a defect sample data set according to the new defect sample image comprises: Construct a defect sample dataset based on the screened new defect sample images.

9. The method according to claim 8, characterized in that Screening the new defect sample image according to a preset screening rule to obtain a screened new defect sample image includes: Perform defect classification processing on the new defect sample image according to the pre-trained classification model to determine the category classification result; Obtaining the confidence of the classification result of the new defect sample image; The new defect sample images are screened according to the confidence of the category classification result to obtain screened new defect sample images.

10. The method according to claim 8, characterized in that The screening of the new defect sample image according to a preset screening rule to obtain a screened new defect sample image includes: Acquire a first feature vector of a new defect sample image and a second feature vector of the defect sample image of the initial defect sample data set; Obtaining a vector distance between the first eigenvector and the second eigenvector; A new defect sample image whose vector distance is greater than a preset value is selected as a new defect sample image after screening.

11. A training method for an industrial defect detection model, characterized in that: include: Constructing a defect sample data set by the method described in any one of claims 1 to 10; The industrial defect detection model is trained according to the defect sample data set.

12. A device for constructing a defect sample data set, characterized in that: include: An initial sample acquisition module is used to acquire an initial defect sample data set; A fine-tuning training module, used for fine-tuning the Vincent graph diffusion model according to the initial defect sample data set to obtain a fine-tuned Vincent graph diffusion model; A new sample generation module, used for performing reasoning according to the fine-tuned and trained Vincent graph diffusion model to generate a new defect sample image; The sample set construction module is used to construct a defect sample data set according to the new defect sample image.

13. A training device for an industrial defect detection model, characterized in that: include: A sample construction module, used to construct a defect sample data set by using the defect sample data set construction device according to claim 12; The model training module is used to train the industrial defect detection model according to the defect sample data set.

Citation Information

Patent Citations

  • Industrial part defect image generation method and system based on image generation model

    CN115953506A

  • Electronic component defect image generation method and system based on diffusion model

    CN115984424A

  • Method for generating defects by finely adjusting Stable Diffusion model based on DreamBooth

    CN116862902A

  • Power transformation defect data small sample expansion method and system based on diffusion model

    CN117115818A