Training method and device for defect classification model for diaphragm surface defects

By generating a defect classification model trained by adversarial networks, combined with grayscale features and cropping technology, the problem of unknown defect classification on the surface of lithium battery separators is solved, improving detection accuracy and reducing production costs.

CN118155004BActive Publication Date: 2024-10-11SHENZHEN ZVIT TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410584943.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-05-13
Publication Date
2024-10-11
Estimated Expiration
2044-05-13

AI Technical Summary

Technical Problem

The existing technology is difficult to accurately classify unknown defects or unknown forms of known defects on the surface of lithium battery separators, resulting in insufficient defect detection accuracy.

Method used

The generative adversarial network is used to train the defect classification model. By obtaining the grayscale features of the diaphragm surface image and cropping the defect area, combined with the images of known defect categories and unknown defect categories, the preset defect classification model is trained, the loss function is optimized and used Cosine similarity evaluation of feature vectors.

Benefits of technology

It improves the accuracy of defect detection on the diaphragm surface, can accurately classify known defects and determine the categories of unknown defects, and provide timely alarms to reduce production costs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118155004B_ABST
    Figure CN118155004B_ABST
Patent Text Reader

Abstract

The embodiment of the present invention discloses a method and device for training a defect classification model for diaphragm surface defects, wherein the method comprises: obtaining multiple diaphragm surface images and performing grayscale feature calculation, detecting according to a preset feature threshold, and determining a defect area as a first sample image; performing defect classification on the first sample image to obtain a corresponding known defect category; obtaining a second sample image of an unknown defect category, wherein the second sample image is a defect image of an industrial product similar to the diaphragm; training a defect classification model based on the first sample image, the second sample image, and their corresponding defect categories; selecting at least one sample image from multiple first sample images of known defect categories; and training a preset defect classification model based on a preset generative adversarial network and generating a third sample image under an unknown defect category. The present invention can improve the accuracy of detecting tab folding defects.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of industrial machine vision automatic detection, and in particular to a method and device for training a defect classification model for diaphragm surface defects, a method, a device, a computer device and a computer-readable medium. Background Art

[0002] As a new type of green battery, lithium battery has occupied the largest market share in the battery market after more than ten years of rapid development and has become the most competitive battery in the field of chemical energy applications. As an important component of lithium-ion batteries, the demand for lithium battery separators is also increasing with the rapid development of electronic industries such as automobiles, mobile phones, and tablets. In order to improve the performance and safety of separators, reduce corporate production costs, and improve product credibility, lithium battery separators need to add defect detection links during the production process. By accurately identifying and classifying the surface defects of the separator, defective separators can be prevented from entering the subsequent process, and production personnel can be helped to eliminate the causes of equipment failures and improve the yield of separator products.

[0003] During the production process of diaphragms, due to production processes and equipment failures, defects such as pinholes, sand holes, droplets, coating leaks, and wrinkles may appear on the surface of the diaphragms. The diaphragm defect visual inspection equipment based on deep learning can achieve high-precision defect classification by collecting and training various defect samples. However, due to technical limitations, it is impossible to accurately classify unknown defects or unknown forms of known defects that appear during the production process of diaphragms. Summary of the invention

[0004] Based on this, it is necessary to propose a training method and device method, device, computer equipment and computer-readable medium for a defect classification model for diaphragm surface defects in response to the above-mentioned problems.

[0005] In the first part of the present invention, a method for training a defect classification model for diaphragm surface defects is provided, characterized in that the method comprises:

[0006] Acquire a plurality of diaphragm surface images, calculate grayscale features of the diaphragm surface images to obtain grayscale features of the diaphragm surface images, and detect the grayscale features of the diaphragm surface images according to a preset feature threshold to determine a defective area in the diaphragm surface images as a first sample image;

[0007] Performing defect classification on the first sample images to obtain a defect category corresponding to each first sample image, wherein the defect category includes a plurality of known defect categories;

[0008] Acquire a second sample image, wherein the defect category of the second sample image is an unknown defect category, wherein the second sample image is a defect image of an industrial product similar to the diaphragm;

[0009] Training a preset defect classification model based on the first sample image, the second sample image and their corresponding defect categories;

[0010] Wherein, the method further comprises:

[0011] Selecting at least one sample image from the first sample images of the plurality of known defect categories; generating a third sample image of the one unknown defect category based on the selected at least one sample image based on a preset generative adversarial network;

[0012] A preset defect classification model is trained based on the third sample image.

[0013] In an optional embodiment, the step of calculating the grayscale features of the diaphragm surface image to obtain the grayscale features of the diaphragm surface image, and detecting the grayscale features of the diaphragm surface image according to a preset feature threshold to determine the defect area in the diaphragm surface image as the first sample image also includes: calculating the grayscale features of the diaphragm surface image to obtain the grayscale features of the diaphragm surface image; detecting the grayscale features of the diaphragm surface image according to a preset grayscale threshold, grayscale variance threshold, defect spacing threshold, roundness threshold, and flatness threshold to obtain the defect area in the diaphragm surface image; and cropping the defect area according to a preset area size to obtain a first sample image corresponding to the defect area.

[0014] In an optional embodiment, the step of training a preset defect classification model based on the first sample image, the second sample image and their corresponding defect categories further includes: training the preset defect classification model based on the defect categories corresponding to the first sample image and the second sample image machines, and calculating the loss function under the training, wherein the defect classification model is a convolutional neural network model of DenseNet121; the calculation formula of the loss function loss is:

[0015] ;

[0016] in, is the number of defect categories, and The value of is equal to the number of the plurality of known defect categories plus 1; A data set representing multiple known defect categories; A data set representing unknown defect categories; , Represent sample images respectively , The defect category; and is a preset function.

[0017] In an optional embodiment, the step of selecting at least one sample image from the first sample images of the multiple known defect categories further includes: selecting at least one sample image from the first sample images of the multiple known defect categories according to a preset ratio value.

[0018] In an optional embodiment, after the step of training the preset defect classification model based on the third sample image, it also includes: calculating the loss function under the training, and completing the training of the defect classification model when the loss function is lower than a preset value or the number of training times reaches the maximum number of training times.

[0019] In an optional embodiment, the method also includes: determining a sample image from the first sample images corresponding to each known defect category as a template sample image under the known defect category; inputting the template sample image into the defect classification model, obtaining the corresponding feature vector, and determining the minimum value of the similarity between the template sample image and other sample images under the defect category as the similarity threshold corresponding to the defect category; obtaining the image to be detected corresponding to the diaphragm to be detected, and inputting the image to be detected into the defect classification model that has been trained; obtaining the defect category information and feature vector information output by the defect classification model, and outputting the defect classification result of the diaphragm to be detected based on the defect category information and feature vector information.

[0020] In an optional embodiment, the step of obtaining the defect category information and feature vector information output by the defect classification model, and outputting the defect classification result of the membrane to be detected based on the defect category information and feature vector information, further includes: if the defect category information and feature vector information output by the defect classification model are matched, then the defect category information is used as the defect classification result of the membrane to be detected; otherwise, the similarity between the feature vector information and the feature vector of the template sample image corresponding to each known defect category is calculated, and the defect classification result of the membrane to be detected is determined based on the relationship between the calculated similarity and the similarity threshold corresponding to each defect category; wherein the calculated similarity is greater than the similarity threshold corresponding to the defect category corresponding to the defect classification result of the membrane to be detected; if the similarity is less than the similarity threshold of all known defect categories, the defect classification result is determined to be an unknown defect category.

[0021] In an optional embodiment, the step of calculating the similarity between the feature vector information and the feature vector of the template sample image corresponding to each known defect category further includes: calculating the cosine value between the feature vector information and the feature vector of the template sample image corresponding to the known defect category as the similarity.

[0022] In the second part of the present invention, a training device for a defect classification model for diaphragm surface defects is provided, the device comprising:

[0023] A first defect sample acquisition module is used to acquire a plurality of diaphragm surface images, perform grayscale feature calculation on the diaphragm surface images to obtain grayscale features of the diaphragm surface images, and detect the grayscale features of the diaphragm surface images according to a preset feature threshold to determine a defect area in the diaphragm surface image as a first sample image;

[0024] A defect classification and labeling module, used to classify the defects of the first sample images to obtain a defect category corresponding to each first sample image, wherein the defect category includes a plurality of known defect categories;

[0025] A second defect sample acquisition module, used for acquiring a second sample image, wherein the defect category of the second sample image is an unknown defect category, wherein the second sample image is a defect image of an industrial product similar to the diaphragm;

[0026] A model training module, used for training a preset defect classification model based on the first sample image, the second sample image and their corresponding defect categories;

[0027] an iterative defect sample acquisition module, configured to select at least one sample image from the first sample images of the plurality of known defect categories; and generate a third sample image of the unknown defect category according to the selected at least one sample image based on a preset generative adversarial network;

[0028] The model iteration training module is used to train a preset defect classification model based on the third sample image.

[0029] In an optional embodiment, the device further includes a defect detection module, which is used to:

[0030] Determine a sample image from the first sample images corresponding to each known defect category as a template sample image under the known defect category;

[0031] Input the template sample image into the defect classification model, obtain the corresponding feature vector, and determine the minimum value of the similarity between the template sample image and other sample images under the defect category as the similarity threshold corresponding to the defect category;

[0032] Acquire an image to be detected corresponding to the diaphragm to be detected, and input the image to be detected into the trained defect classification model;

[0033] The defect category information and the feature vector information output by the defect classification model are obtained, and the defect classification result of the diaphragm to be inspected is output according to the defect category information and the feature vector information.

[0034] In the third part of the present invention, a computer device is provided, which includes a processor and a memory, the memory is used to store a computer program; the processor is used to execute the steps of the training method for the defect classification model for diaphragm surface defects as described in the first aspect above according to the computer program.

[0035] In the fourth part of the present invention, a computer-readable storage medium is provided, wherein the computer-readable storage medium is used to store a computer program, wherein the computer program is used to execute the steps of the method for training a defect classification model for diaphragm surface defects as described in the first aspect above.

[0036] The embodiments of the present invention have the following beneficial effects:

[0037] After adopting the above-mentioned defect classification model training method, device, computer equipment and computer-readable storage medium for diaphragm surface defects, in the process of training the defect classification model for detecting diaphragm surface defects, the diaphragm surface image is collected and the defect area is cropped and annotated as a training sample of the known defect category; and the defect images of other industrial products similar to the diaphragm are used as training samples of unknown defect categories to train the defect classification model. Among them, the defect classification model is further trained by generating an adversarial network, attacking the classification boundary, so that the feature space of its known defect category is shrunk, and the accuracy of defect detection is improved.

[0038] Furthermore, in the present application, by optimizing the loss function of the model and adding the cosine similarity evaluation of the feature vector, when applied to the defect detection on the diaphragm surface, it can ensure the accurate classification rate of known defects on the diaphragm surface while also determining the new defect forms on the diaphragm surface into unknown categories, thereby improving the classification accuracy of the model, and also being able to generate timely alarms for new fault forms of the equipment, reminding on-site staff to repair the equipment, thereby reducing the generation cost caused by the fault. BRIEF DESCRIPTION OF THE DRAWINGS

[0039] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0040] in:

[0041] Figure 1 A schematic flow chart of a method for training a defect classification model for diaphragm surface defects in one embodiment;

[0042] Figure 2 A structural schematic diagram and a classification schematic diagram of a defect classification model in an embodiment;

[0043] Figure 3 A schematic diagram of the structure of a method and device for training a defect classification model for diaphragm surface defects in one embodiment;

[0044] Figure 4 A schematic diagram of the structure of a computer device for running the above-mentioned training method for the defect classification model for diaphragm surface defects in one embodiment. DETAILED DESCRIPTION

[0045] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0046] In this embodiment, a method for training a defect classification model for diaphragm surface defects and a method for classifying diaphragm surface defects based on the defect classification model trained by the method are provided, which can improve the accuracy of diaphragm defect detection, and can also accurately detect unknown defect categories, thereby improving the accuracy of defect classification.

[0047] The above-mentioned training method for the defect classification model for diaphragm surface defects and the method for classifying diaphragm surface defects based on the defect classification model trained by the method can be based on industrial application scenarios. In the industrial production process of the diaphragm, the image of the diaphragm is collected, and visual inspection is performed based on the collected image to determine whether the diaphragm has defects, so as to prevent the defective diaphragm from entering the subsequent power and improve the yield of the diaphragm product. The visual inspection of the diaphragm image is based on a deep learning model, such as a convolutional neural network model, etc., which is not limited here. Before the inspection, the corresponding deep learning model needs to be trained, and the corresponding training method is explained here.

[0048] For details, see Figure 1 , a flow chart of the training method of the defect classification model for the diaphragm surface defects is given, including Figure 1 Steps S101-S106 shown:

[0049] Step S101: Acquire multiple diaphragm surface images, calculate the grayscale features of the diaphragm surface images to obtain the grayscale features of the diaphragm surface images, and detect the grayscale features of the diaphragm surface images according to a preset feature threshold to determine the defect area in the diaphragm surface image as the first sample image.

[0050] An image acquisition device is provided on the membrane production line to acquire the surface image of the membrane to be detected, i.e., the membrane surface image. Here, the image data acquired by the image acquisition device can be converted into image data used in the defect detection process according to the requirements of image detection, i.e., the membrane surface image. Here, the defect classification model needs to be trained, so it is necessary to acquire multiple images corresponding to the membranes to be detected, i.e., the number of the membrane surface images is multiple.

[0051] Furthermore, after obtaining the diaphragm surface image, it is necessary to further process the diaphragm surface image to obtain the corresponding defect small image therein as a sample image for model training, that is, the first sample image. Specifically, the grayscale features of the diaphragm surface image are calculated. Here, the grayscale value distribution of the normal area and the defect area in the diaphragm surface image is analyzed to obtain the grayscale thresholds Th_dark and Th_bright for distinguishing dark defects and bright defects. The grayscale features in the diaphragm surface image are detected by one or more of the preset grayscale thresholds, grayscale variance thresholds, defect spacing thresholds, roundness thresholds, flatness thresholds, etc., so as to determine the defect area in the diaphragm surface image, that is, the defect small image to be classified contained therein. Then, according to the preset area size, the defect area is cropped to obtain the first sample image corresponding to the defect area. Here, the bright defect area and the dark defect area in the diaphragm surface image are included. When cropping, the corresponding middle of the defect area can be centered and cropped according to the fixed preset area size to obtain the first sample image.

[0052] Step S102: performing defect classification on the first sample images to obtain a defect category corresponding to each first sample image, wherein the defect category includes a plurality of known defect categories.

[0053] It should be noted that in this embodiment, not only the known membrane surface defects need to be classified and identified (known defect categories), but also the unknown membrane surface defects need to be classified and identified. Therefore, after acquiring the first sample image and performing classification and annotation, the annotation of the unknown defect category (unknown defect category) needs to be considered.

[0054] Specifically, the first sample image is defect-classified to obtain a defect category corresponding to each first sample image (here, the number of known defect categories is N defect categories), wherein the defect category includes a plurality of known defect categories. Here, each first sample image and the corresponding defect category are obtained.

[0055] Step S103: Acquire a second sample image, and the defect category of the second sample image is an unknown defect category, wherein the second sample image is a defect image of an industrial product similar to the diaphragm.

[0056] Furthermore, for unknown defect categories, corresponding defect samples can be obtained by collecting defect images of industrial products similar to the diaphragm as the second sample image, and used as defect samples of the N+1th category, that is, training data for the unknown defect category.

[0057] In other embodiments, the aforementioned first sample image and a generative adversarial network may be used to generate defect samples of the N+1th category.

[0058] Industrial defect images similar to known samples are used to select defect samples of unknown categories. At the same time, the generative adversarial network method is used to generate new defect samples of unknown defect categories during the model iteration process, thereby attacking the classification boundaries of the model and further reducing the feature space of known categories.

[0059] Step S104: training a preset defect classification model based on the first sample image, the second sample image and their corresponding defect categories.

[0060] After obtaining the first sample image and the second sample image and the corresponding defect category annotations, the preset defect classification model can be trained to complete the training of the defect classification model. Among them, the defect classification model is used to classify the surface defects of the diaphragm, and the model can classify unknown defect categories. In a specific embodiment, the above-mentioned defect classification model is a convolutional neural network model, for example, it can be a convolutional neural network structure model based on DenseNet121. Here, it is necessary to add the calculation of the loss function, wherein the loss function is based on the calculation of the similarity of the feature vector. In another embodiment, the above-mentioned convolutional neural network model also includes a comprehensive classification based on the classification label and the feature vector similarity evaluation.

[0061] In the process of training the defect classification model, the preset defect classification model is trained based on the defect categories corresponding to the first sample image and the second sample image, and the loss function under this training is calculated, wherein the calculation formula of the loss function loss is:

[0062] ;

[0063] in, is the number of defect categories, and The value of is equal to the number of the plurality of known defect categories plus 1; A data set representing multiple known defect categories; A data set representing unknown defect categories; , Represent sample images respectively , The defect category; and for The corresponding feature vector.

[0064] The current model is trained as the first training, and then the model parameters after training and the corresponding feature vector are determined after the first training, and then the corresponding loss function is calculated according to the calculated feature vector.

[0065] In this embodiment, if the loss function satisfies a preset value, or the total number of training times reaches the maximum number of training times, the training of the defect classification model can be terminated. Otherwise, the defect classification model needs to be iteratively trained.

[0066] The process of iteratively training the defect classification model includes the following steps S105-S106:

[0067] Step S105: selecting at least one sample image from the first sample images of the plurality of known defect categories; generating a third sample image of the one unknown defect category based on the selected at least one sample image based on a preset generative adversarial network;

[0068] Step S106: training a preset defect classification model based on the third sample image.

[0069] Specifically, in the training process of the above defect classification model, a generative adversarial network is used, and some images are selected from the defect samples of the known defect categories (the first sample images) determined above, to generate defect sample images of the unknown defect categories of the N+1th category as the third sample images. Then, the defect classification model is iteratively trained based on the third sample images, and then the loss function is calculated after the iterative training is completed, and it is determined whether to continue the model iterative training or terminate the model training based on the loss function and the number of iterative training.

[0070] Specifically, the above process of selecting sample images is to select at least one sample image from the first sample images of the multiple known defect categories according to a preset ratio value to ensure that the number of sample images under each defect category is the same, so as to ensure the stability of model training and improve the accuracy of model classification.

[0071] The trained defect classification model can detect and classify the surface defects of the diaphragm on the diaphragm production line. The image to be detected corresponding to the diaphragm to be detected is obtained, the image to be detected is detected to obtain the defect thumbnail therein, and then the defect thumbnail is input into the aforementioned defect classification model, so that the defect classification model can output the corresponding classification result.

[0072] Specifically, the defect classification model calculates the feature vector information corresponding to the defect thumbnail, and then calculates the similarity between the feature vector information and each defect category, and performs defect classification results corresponding to the defect thumbnail based on the similarity. The model output results include defect classification information and corresponding similarity, and the defect thumbnail is accurately classified based on the classification label and feature similarity.

[0073] In the defect classification model, in order to determine which defect the image to be classified corresponds to, it is necessary to calculate the similarity between the features of the image and the features of each defect category. Specifically, a sample image is determined from the first sample image corresponding to each known defect category as a template sample image under the known defect category; the template sample image is input into the defect classification model to obtain the corresponding feature vector. Here, the feature vector can be a linear layer feature vector ; Then determine the minimum value of the similarity between the template sample image and other sample images under the defect category as the similarity threshold corresponding to the defect category .

[0074] When classifying defects of the image to be inspected corresponding to the diaphragm to be inspected, the defect thumbnail corresponding to the image to be inspected is input into the defect classification model to obtain the defect category of the defect thumbnail. and the feature vector of the linear layer ,like , then directly output the defect category information (unknown defect category); otherwise, according to the defect category information of the image Extract the pre-saved feature vector accordingly , calculate the similarity between the image feature vector and the template feature vector of the corresponding category according to the following formula.

[0075] ;

[0076] like , then the defect image is judged as the classification result of model reasoning ,like , then the defect image is judged as an unknown sample category .

[0077] That is to say, if the defect category information and feature vector information output by the defect classification model match, the defect category information is used as the defect classification result of the membrane to be detected; otherwise, the similarity between the feature vector information and the feature vector of the template sample image corresponding to each known defect category is calculated, and the defect classification result of the membrane to be detected is determined based on the relationship between the calculated similarity and the similarity threshold corresponding to each defect category; wherein the calculated similarity is greater than the similarity threshold corresponding to the defect category corresponding to the defect classification result of the membrane to be detected; if the similarity is less than the similarity threshold of all known defect categories, the defect classification result is determined to be an unknown defect category. For details, please refer to Figure 2 , a structural schematic diagram and a classification schematic diagram based on the above defect classification model are given.

[0078] Among them, the calculation of the similarity between feature vectors is to calculate their corresponding cosine values, which can make the classification feature space tend to the known defect category. The intra-class features are concentrated in the feature space, and the inter-class features are far away from each other in the feature space, so that the unknown samples have the greatest probability of falling in the feature space where the unknown defect category is located, thereby improving the accuracy of defect classification.

[0079] Furthermore, after a period of accumulation of diaphragm surface defect samples, samples classified into category N+1 are manually analyzed. If the defect is a new defect form of a known defect category, it is added to the category. If the defect is a new cause of machine failure, a category is added to the known defect category, and the defect classification model is updated again according to the above method.

[0080] See also Figure 3 , and also provides a training device for a defect classification model for diaphragm surface defects, the device comprising:

[0081] The first defect sample acquisition module 101 is used to acquire a plurality of diaphragm surface images, perform grayscale feature calculation on the diaphragm surface images to obtain grayscale features of the diaphragm surface images, and detect the grayscale features of the diaphragm surface images according to a preset feature threshold to determine a defect area in the diaphragm surface images as a first sample image;

[0082] The defect classification and labeling module 102 is used to classify the defects of the first sample images to obtain a defect category corresponding to each first sample image, wherein the defect category includes a plurality of known defect categories;

[0083] A second defect sample acquisition module 103 is used to acquire a second sample image, and the defect category of the second sample image is an unknown defect category, wherein the second sample image is a defect image of an industrial product similar to the diaphragm;

[0084] A model training module 104, configured to train a preset defect classification model based on the first sample image, the second sample image and their corresponding defect categories;

[0085] The iterative defect sample acquisition module 105 is used to select at least one sample image from the first sample images of the plurality of known defect categories; based on a preset generative adversarial network, generate a third sample image of the unknown defect category according to the selected at least one sample image;

[0086] The model iteration training module 106 is used to train a preset defect classification model based on the third sample image.

[0087] In an optional embodiment, the first defect sample acquisition module 101 is also used to calculate the grayscale features of the diaphragm surface image to obtain the grayscale features of the diaphragm surface image; detect the grayscale features of the diaphragm surface image according to a preset grayscale threshold, grayscale variance threshold, defect spacing threshold, roundness threshold, and flatness threshold to obtain the defect area in the diaphragm surface image; and crop the defect area according to a preset area size to obtain a first sample image corresponding to the defect area.

[0088] In an optional embodiment, the model training module 104 is further used to train a preset defect classification model based on the defect categories corresponding to the first sample image and the second sample image, and calculate the loss function under the training, wherein the defect classification model is a convolutional neural network model of DenseNet121;

[0089] The calculation formula of the loss function loss is:

[0090] ;

[0091] in, is the number of defect categories, and The value of is equal to the number of the plurality of known defect categories plus 1; A data set representing multiple known defect categories; A data set representing unknown defect categories; , Represent sample images respectively , The defect category; and is a preset function.

[0092] In an optional embodiment, the iterative defect sample acquisition module 105 is further configured to select at least one sample image from the first sample images of the plurality of known defect categories according to a preset ratio value.

[0093] In an optional embodiment, the model training module 104 is further used to calculate the loss function of the training, and when the loss function is lower than a preset value or the number of training times reaches a maximum number of training times, the training of the defect classification model is completed.

[0094] In an optional embodiment, if Figure 3As shown, the device also includes a defect detection module 107, which is used to: determine a sample image in the first sample image corresponding to each known defect category as a template sample image under the known defect category; input the template sample image into the defect classification model, obtain the corresponding feature vector, and determine the minimum value of the similarity between the template sample image and other sample images under the defect category as the similarity threshold corresponding to the defect category; obtain the image to be detected corresponding to the diaphragm to be detected, and input the image to be detected into the defect classification model that has been trained; obtain the defect category information and feature vector information output by the defect classification model, and output the defect classification result of the diaphragm to be detected according to the defect category information and feature vector information.

[0095] In an optional embodiment, the defect detection module 107 is also used to: if the defect category information and the feature vector information output by the defect classification model match, then the defect category information is used as the defect classification result of the membrane to be detected; otherwise, the similarity between the feature vector information and the feature vector of the template sample image corresponding to each known defect category is calculated, and the defect classification result of the membrane to be detected is determined based on the relationship between the calculated similarity and the similarity threshold corresponding to each defect category; wherein the calculated similarity is greater than the similarity threshold corresponding to the defect category corresponding to the defect classification result of the membrane to be detected; if the similarity is less than the similarity threshold of all known defect categories, the defect classification result is determined to be an unknown defect category.

[0096] In an optional embodiment, the model iteration training module 106 is further configured to calculate a cosine value between the feature vector information and a feature vector of a template sample image corresponding to a known defect category as a similarity.

[0097] Figure 4 The internal structure diagram of a computer device for implementing the above-mentioned tab folding defect classification model training method or tab folding defect classification method in one embodiment is shown. The computer device can be a terminal or a server. Figure 4 As shown, the computer device includes a processor, a memory and a network interface connected via a system bus. The memory includes a non-volatile storage medium and an internal memory. The non-volatile storage medium of the computer device stores an operating system and may also store a computer program. When the computer program is executed by the processor, the processor can implement the above method. The internal memory may also store a computer program. When the computer program is executed by the processor, the processor can implement the above method. Those skilled in the art can understand that Figure 4The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0098] After adopting the above-mentioned defect classification model training method, device, computer equipment and computer-readable storage medium for diaphragm surface defects, in the process of training the defect classification model for detecting diaphragm surface defects, the diaphragm surface image is collected and the defect area is cropped and annotated as a training sample of the known defect category; and the defect images of other industrial products similar to the diaphragm are used as training samples of unknown defect categories to train the defect classification model. Among them, the defect classification model is further trained by generating an adversarial network, attacking the classification boundary, so that the feature space of its known defect category is shrunk, and the accuracy of defect detection is improved.

[0099] Furthermore, in the present application, by optimizing the loss function of the model and adding the cosine similarity evaluation of the feature vector, when applied to the defect detection on the diaphragm surface, it can ensure the accurate classification rate of known defects on the diaphragm surface while also determining the new defect forms on the diaphragm surface into unknown categories, thereby improving the classification accuracy of the model, and also being able to generate timely alarms for new fault forms of the equipment, reminding on-site staff to repair the equipment, thereby reducing the generation cost caused by the fault.

[0100] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the program can be stored in a non-volatile computer-readable storage medium. When the program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).

[0101] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0102] The above-mentioned embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.

Claims

1. A method for training a defect classification model for diaphragm surface defects, characterized in that: The method comprises: Acquire a plurality of diaphragm surface images, calculate grayscale features of the diaphragm surface images to obtain grayscale features of the diaphragm surface images, and detect the grayscale features of the diaphragm surface images according to a preset feature threshold to determine a defective area in the diaphragm surface images as a first sample image; Performing defect classification on the first sample images to obtain a defect category corresponding to each first sample image, wherein the defect category includes a plurality of known defect categories; Acquire a second sample image, wherein the defect category of the second sample image is an unknown defect category, wherein the second sample image is a defect image of an industrial product similar to the diaphragm; The preset defect classification model is trained based on the first sample image, the second sample image and the corresponding defect categories; wherein the step of training the preset defect classification model based on the first sample image, the second sample image and the corresponding defect categories further includes: training the preset defect classification model based on the first sample image, the second sample image and the corresponding defect categories, and calculating the loss function under the training, wherein the defect classification model is a convolutional neural network model of DenseNet121; the calculation formula of the loss function loss is: Wherein, n is the number of defect categories, and the value of n is equal to the number of the plurality of known defect categories plus 1; X in Represents a data set of multiple known defect categories; X out A data set representing unknown defect categories; Represents the sample image x i 、x j The defect category; p() and q() are preset feature vector functions; Wherein, the method further comprises: Selecting at least one sample image from the plurality of first sample images of known defect categories; Based on a preset generative adversarial network, generating a third sample image of an unknown defect category according to the selected at least one sample image; A preset defect classification model is trained based on the third sample image.

2. The method for training a defect classification model for diaphragm surface defects according to claim 1, characterized in that: The step of calculating the grayscale features of the membrane surface image to obtain the grayscale features of the membrane surface image, and detecting the grayscale features of the membrane surface image according to a preset feature threshold to determine the defective area in the membrane surface image as the first sample image, further includes: Calculating the grayscale features of the membrane surface image to obtain the grayscale features of the membrane surface image; According to a preset grayscale threshold, grayscale variance threshold, defect spacing threshold, roundness threshold, and flatness threshold, the grayscale feature of the diaphragm surface image is detected to obtain a defect area in the diaphragm surface image; The defective area is cropped according to a preset area size to obtain a first sample image corresponding to the defective area.

3. The method for training a defect classification model for diaphragm surface defects according to claim 1, characterized in that: The step of selecting at least one sample image from the first sample images of the plurality of known defect categories further includes: At least one sample image is selected from the plurality of first sample images of known defect categories according to a preset ratio value.

4. The method for training a defect classification model for diaphragm surface defects according to claim 3, characterized in that: After the step of training the preset defect classification model based on the third sample image, the method further includes: The loss function under this training is calculated, and when the loss function is lower than a preset value or the number of training times reaches a maximum number of training times, the training of the defect classification model is completed.

5. The method for training a defect classification model for diaphragm surface defects according to claim 1, characterized in that: The method further comprises: Determine a sample image from the first sample images corresponding to each known defect category as a template sample image under the known defect category; Input the template sample image into the defect classification model, obtain the corresponding feature vector, and determine the minimum value of the similarity between the template sample image and other sample images under the defect category as the similarity threshold corresponding to the defect category; Acquire an image to be detected corresponding to the diaphragm to be detected, and input the image to be detected into the trained defect classification model; The defect category information and the feature vector information output by the defect classification model are obtained, and the defect classification result of the diaphragm to be inspected is output according to the defect category information and the feature vector information.

6. The method for training a defect classification model for diaphragm surface defects according to claim 5, characterized in that: The step of obtaining the defect category information and the feature vector information output by the defect classification model, and outputting the defect classification result of the diaphragm to be inspected according to the defect category information and the feature vector information, further includes: If the defect category information output by the defect classification model matches the feature vector information, the defect category information is used as the defect classification result of the diaphragm to be detected; On the contrary, the similarity between the feature vector information and the feature vector of the template sample image corresponding to each known defect category is calculated, and the defect classification result of the diaphragm to be detected is determined according to the size relationship between the calculated similarity and the similarity threshold corresponding to each defect category; wherein the calculated similarity is greater than the similarity threshold corresponding to the defect category corresponding to the defect classification result of the diaphragm to be detected; If the similarity is less than the similarity threshold of all known defect categories, it is determined that the defect classification result is an unknown defect category.

7. The method for training a defect classification model for diaphragm surface defects according to claim 6, characterized in that: The step of calculating the similarity between the feature vector information and the feature vector of the template sample image corresponding to each known defect category also includes: The cosine value between the feature vector information and the feature vector of the template sample image corresponding to the known defect category is calculated as the similarity.

8. A training device for a defect classification model for diaphragm surface defects, characterized in that: The device comprises: A first defect sample acquisition module is used to acquire a plurality of diaphragm surface images, perform grayscale feature calculation on the diaphragm surface images to obtain grayscale features of the diaphragm surface images, and detect the grayscale features of the diaphragm surface images according to a preset feature threshold to determine a defect area in the diaphragm surface image as a first sample image; A defect classification and labeling module, used to classify the defects of the first sample images to obtain a defect category corresponding to each first sample image, wherein the defect category includes a plurality of known defect categories; A second defect sample acquisition module, used for acquiring a second sample image, wherein the defect category of the second sample image is an unknown defect category, wherein the second sample image is a defect image of an industrial product similar to the diaphragm; A model training module is used to train a preset defect classification model based on the first sample image, the second sample image and their corresponding defect categories; wherein the preset defect classification model is trained based on the first sample image, the second sample image and their corresponding defect categories, and the loss function under this training is calculated, wherein the defect classification model is a convolutional neural network model of DenseNet121; the calculation formula of the loss function loss is: Wherein, n is the number of defect categories, and the value of n is equal to the number of the plurality of known defect categories plus 1; X in Represents a data set of multiple known defect categories; X out A data set representing unknown defect categories; Represents the sample image x i 、x j The defect category; p() and q() are preset feature vector functions; An iterative defect sample acquisition module is used to select at least one sample image from the first sample images of the plurality of known defect categories; based on a preset generative adversarial network, generate a third sample image of an unknown defect category according to the selected at least one sample image; The model iteration training module is used to train a preset defect classification model based on the third sample image.

9. The training device for the defect classification model for diaphragm surface defects according to claim 8, characterized in that: The device also includes a defect detection module, which is used to: Determine a sample image from the first sample images corresponding to each known defect category as a template sample image under the known defect category; Input the template sample image into the defect classification model, obtain the corresponding feature vector, and determine the minimum value of the similarity between the template sample image and other sample images under the defect category as the similarity threshold corresponding to the defect category; Acquire an image to be detected corresponding to the diaphragm to be detected, and input the image to be detected into the trained defect classification model; The defect category information and the feature vector information output by the defect classification model are obtained, and the defect classification result of the diaphragm to be inspected is output according to the defect category information and the feature vector information.