A glass defect detection algorithm based on multimodal teacher and student framework
Through the multi-modal teacher and student framework and CLIP model, combined with feature encoding and alignment training of glass sample images and text descriptions, the problem of insufficient generalization and transfer capabilities of existing glass defect detection algorithms is solved, and the problem of insufficient generalization and transfer capabilities of existing glass defect detection algorithms is achieved. Efficient defect detection across types and environments.
Patent Information
- Application Number
- CN202410919511.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-10
- Publication Date
- 2024-09-20
- Estimated Expiration
- 2044-07-10
AI Technical Summary
Existing glass defect detection algorithms have poor generalization capabilities, poor transfer capabilities, and poor defect location capabilities. In particular, algorithms based on supervised learning require a large amount of manual annotation and high-quality annotation, and cannot detect unseen defects. Unsupervised learning-based algorithms Although the algorithm has strong generalization ability, it has low accuracy and consumes more resources.
Using a multi-modal teacher-student framework, combined with the CLIP model and the unsupervised teacher-student framework, through feature encoding and alignment training of glass sample images and text descriptions, a model capable of detecting defects in different glass types and environments is generated, using Different layer features and global information are detected.
It improves the generalization and migration capabilities of glass defect detection, can detect defects in multiple types of glass, reduces dependence on annotation data, and improves the accuracy and efficiency of defect location.
Smart Images

Figure CN118468230B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of artificial intelligence multimodal technology, and more specifically, to a glass defect detection algorithm based on a multimodal teacher and student framework. Background Art
[0002] Glass is one of the indispensable industrial products in real life. Its surface defects such as scratches, holes, and wear are the main factors affecting product yield. Previous deep learning-based glass defect detection algorithms mostly adopted a supervised learning paradigm, which requires a large amount of precise manual annotation, which greatly increases labor costs. In addition, the supervised method has weak generalization ability, and the model cannot detect defects that have not been seen (not labeled). In this invention, we combine the multimodal large model CLIP with the unsupervised teacher-student framework to deal with the problems existing in glass defects.
[0003] A multimodal large model refers to a large neural network model trained with information from multiple modalities (such as text, images, and voice). This type of model has the ability to simultaneously process and understand data from different modalities, thereby achieving a more comprehensive automated industrial quality inspection task processing capability. Currently, CLIP, a multimodal model pre-trained with massive amounts of text and images, has been widely used in actual industrial production. The CLIP model has rich prior knowledge and strong generalization capabilities, and can be fine-tuned on various tasks without the need for a large amount of labeled data, making it possible to use CLIP to solve unsupervised defect detection.
[0004] The teacher-student framework was first used to solve the knowledge distillation task and has now become a classic method for unsupervised defect detection tasks. The teacher network is pre-trained on a large-scale data set and therefore has rich prior knowledge. The student network generally uses a lightweight network with smaller parameters to distill the teacher's knowledge. In the unsupervised industrial defect detection task, only normal samples are provided in the training phase, and the learning goal is to make the features reconstructed by the student consistent with the features extracted by the teacher. In the inference phase, the teacher network extracts good features of the test sample (with defects), while the student network cannot reconstruct good features because it has not learned to extract defective samples. The difference between the two features will be used as a reference for defect detection.
[0005] At present, the mainstream algorithms for glass defect detection are:
[0006] Supervised learning algorithm based on target detection: In the early stage of deploying this algorithm, it is necessary to manually annotate defects, and then deploy target detection models such as YOLO to train the data. This algorithm has high requirements for the quality of manual annotation and often encounters serious overfitting problems, that is, the algorithm cannot identify anomalies that have not been collected.
[0007] Unsupervised learning algorithm based on feature matching: This type of algorithm determines the defect area by matching the features of good products with the features of test samples. It has strong generalization ability, but lacks high accuracy compared to supervised algorithms. In addition, this algorithm consumes a lot of storage space and has a slow reasoning speed.
[0008] At present, the algorithms that can be deployed in actual glass quality inspection all face the difficulties of poor algorithm generalization ability, poor migration ability, and poor defect localization ability. The poor generalization ability is mainly reflected in the fact that the model can only detect annotated defects under supervised learning, but cannot detect newly emerging defects. Poor migration ability means that a model can only complete the inspection task of a single type of glass, but cannot process other types of glass data. The poor defect localization ability is determined by factors such as overfitting and underfitting during training, poor quality of model supervision information, and inappropriate model selection. Summary of the invention
[0009] In order to solve at least one of the above technical problems, the present invention proposes a glass defect detection algorithm based on a multimodal teacher and student framework.
[0010] The first aspect of the present invention provides a glass defect detection algorithm based on a multimodal teacher and student framework, comprising the following steps:
[0011] A large number of defect-free samples and a small number of samples with various defects are collected from the glass production line, and cleaned to obtain different modal information, including glass sample images and text description samples;
[0012] Generate training and test sets based on glass sample images and text description samples;
[0013] The model is trained based on the training set to obtain a multimodal teacher and student network training model;
[0014] The multimodal teacher and student network training model is tested based on the test set, and the model parameters are dynamically adjusted based on the test results to obtain the final multimodal teacher and student network training model;
[0015] The glass defect detection results are generated based on the final multimodal teacher and student network training model.
[0016] In a preferred embodiment of the present invention, a large number of defect-free samples and a small number of samples with various defects are collected from a glass production line, and cleaned to obtain different modal information, which includes glass sample images and text description samples; specifically, the following includes:
[0017] Obtain glass samples, clean the glass samples, remove dust from the glass surface, illuminate the collected samples based on optical technology, take photos, and obtain high-quality glass sample images after secondary calibration;
[0018] Classify the glass sample images to obtain normal images and pseudo-abnormal images;
[0019] Templates are designed for normal images and pseudo-abnormal images respectively, normal text and defect text are generated, and text description samples are obtained.
[0020] In a preferred embodiment of the present invention, the training set is obtained by screening a large number of normal images from glass sample images as the training set, the test set includes normal images and defect images, and the size ratio of the training set to the test set is 7:3.
[0021] In a preferred embodiment of the present invention, the model is trained based on the training set to obtain a multimodal teacher and student network training model, which specifically includes:
[0022] Obtain normal sample images and text description samples, create pseudo abnormal images based on the normal sample images, and pre-process the pseudo abnormal images;
[0023] Extract image features, encode image features based on the encoder, decode the encoded image features based on the student encoder, obtain patch features and global features, and perform multi-layer feature reconstruction training based on patch features;
[0024] Extracting features of text description samples, encoding the features of text description samples based on the encoder to obtain normal text encoding and abnormal text encoding;
[0025] Based on global features, normal text encoding and abnormal text encoding, multimodal information is aligned and trained to obtain a multimodal teacher and student network training model.
[0026] In a preferred embodiment of the present invention, multi-layer feature reconstruction training is performed based on patch features, specifically including:
[0027] Using the student network to distill the teacher network to extract normal sample features, the optimization goal is:
[0028] ;
[0029] ;
[0030] in, and Respectively represent The layer feature map is The feature vector of the position, represents the transpose operation of the matrix, where Represents the characteristics of the i-th layer of the teacher network and the student network and Cosine similarity score, Represents the multi-layer feature reconstruction loss.
[0031] In a preferred embodiment of the present invention, the multimodal information alignment training specifically includes: generating journey text features and abnormal text features based on normal text encoding and abnormal text encoding, respectively, and the normal text features are recorded as , the abnormal text feature is recorded as , where the dimensions of both are , size and student network output category global features Keeping it consistent, the optimization goal related to multimodal information is:
[0032] ;
[0033] in, represents the multimodal alignment loss, represents exponential operation, represents the temperature coefficient, Represents the category global feature (class-token) of the feature attention map of the normal sample image under Transformer encoding, Represents the category global features (class-token) of the feature attention map of artificial pseudo-abnormal sample images under Transformer encoding;
[0034] The overall optimization goal of the training phase is:
[0035] ;
[0036] in is a hyperparameter.
[0037] In a preferred embodiment of the present invention, the multimodal teacher and student network training model is tested based on the test set, specifically including:
[0038] Acquire a test sample image, and preprocess the test sample image;
[0039] Encoding the preprocessed test sample image based on the encoder;
[0040] Decode the encoded test sample image according to the student decoder to obtain patch features and global features;
[0041] Generate feature reconstruction scores based on patch features and text matching scores based on global features;
[0042] The training results are obtained based on the feature reconstruction score and the text matching score.
[0043] In a preferred embodiment of the present invention, the multimodal teacher-student network includes a teacher network and a student network. The multimodal model CLIP-ViT-16B pre-trained on massive data is used. The backbone network of the model uses the ViT model with 12 layers of multi-head attention modules. A three-layer multi-head attention module is used; during the training phase, the training sample images of size 256×256×3 Input the teacher network and extract the features of its 3, 6, and 9 layers respectively, recorded as , , , size is After concatenating the three layers of features, they are aggregated through a linear network, and then the aggregated features are input into the student network. The features output by each layer of the student network are recorded as , , , size is .
[0044] In a preferred embodiment of the present invention, a pseudo-abnormal sample is generated based on a pseudo-abnormal image, and the pseudo-abnormal sample generation method is as follows: using image processing technology to synthesize a pseudo-abnormal with a normal sample in a training set as a template, collecting noise that matches the size of the original image from Perlin noise, and generating a mask after binarization;
[0045] The mask is intersected with the texture image prepared in advance to obtain a pseudo defect morphology map, and the obtained pseudo defect morphology map is pasted onto the original normal sample image to obtain the final pseudo abnormal sample image.
[0046] The above technical solution of the present invention has the following advantages compared with the prior art:
[0047] The multimodal unsupervised framework of this application has stronger generalization, that is, it can detect many abnormal samples that have not been collected. The CLIP model with rich prior knowledge increases the migration ability of the model, allowing it to adapt to different types of glass quality inspection environments. It uses the feature information and global information of different layers of the ViT model to jointly detect anomalies, greatly improving the defect location capability. In addition, the injection of text information will further enhance the detection capability. BRIEF DESCRIPTION OF THE DRAWINGS
[0048] In order to more clearly illustrate the specific implementation methods of the present invention or the technical solutions in the prior art, the drawings required for use in the specific implementation methods or the description of the prior art will be briefly introduced below. Obviously, some of the drawings described below are some implementation methods of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0049] Figure 1These are the training steps and testing steps of the multimodal teacher and student network model of the embodiment of the present invention;
[0050] Figure 2 is the first set of test results of the test data set of the embodiment of the present invention;
[0051] Figure 3 is a second set of test results of the test data set of an embodiment of the present invention;
[0052] Figure 4 is the third set of test results of the test data set of the embodiment of the present invention;
[0053] Figure 5 This is the fourth set of test results of the test data set of the embodiment of the present invention. DETAILED DESCRIPTION
[0054] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present application.
[0055] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequential order. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present application described here. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0056] In the present application, the terms "upper", "lower", "left", "right", "front", "back", "top", "bottom", "inner", "outer", "middle", "vertical", "horizontal", "lateral", "longitudinal" and the like indicate positions or positional relationships based on the positions or positional relationships shown in the drawings. These terms are mainly used to better describe the present invention and its embodiments, and are not used to limit the indicated devices, elements or components to have a specific orientation, or to be constructed and operated in a specific orientation.
[0057] In addition, some of the above terms may be used to express other meanings in addition to indicating orientation or positional relationship. For example, the term "on" may also be used to express a certain dependency or connection relationship in some cases. For those skilled in the art, the specific meanings of these terms in the present invention can be understood according to specific circumstances.
[0058] In addition, the terms "installed", "set", "provided with", "connected", "connected", and "socketed" should be understood in a broad sense. For example, it can be a fixed connection, a detachable connection, or an integral structure; it can be a mechanical connection or an electrical connection; it can be a direct connection, or an indirect connection through an intermediate medium, or it can be an internal connection between two devices, elements, or components. For those of ordinary skill in the art, the specific meanings of the above terms in the present invention can be understood according to specific circumstances.
[0059] It should be noted that, in the absence of conflict, the embodiments and features in the embodiments of the present application can be combined with each other. The present application will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.
[0060] Embodiment 1
[0061] See also Figure 1 As shown, the present invention proposes a glass defect detection algorithm based on a multimodal teacher and student framework, comprising the following steps:
[0062] A large number of defect-free samples and a small number of samples with various defects are collected from the glass production line, and cleaned to obtain different modal information, including glass sample images and text description samples;
[0063] Generate training and test sets based on glass sample images and text description samples;
[0064] The model is trained based on the training set to obtain a multimodal teacher and student network training model;
[0065] The multimodal teacher and student network training model is tested based on the test set, and the model parameters are dynamically adjusted based on the test results to obtain the final multimodal teacher and student network training model;
[0066] The glass defect detection results are generated based on the final multimodal teacher and student network training model.
[0067] According to an embodiment of the present invention, a large number of defect-free samples and a small number of samples with various defects are collected from a glass production line, and are cleaned to obtain different modal information, which includes glass sample images and text description samples; specifically, the following:
[0068] Obtain glass samples, clean the glass samples, remove dust from the glass surface, illuminate the collected samples based on optical technology, take photos, and obtain high-quality glass sample images after secondary calibration;
[0069] Classify the glass sample images to obtain normal images and pseudo-abnormal images;
[0070] Templates are designed for normal images and pseudo-abnormal images respectively, normal text and defect text are generated, and text description samples are obtained.
[0071] According to an embodiment of the present invention, a large number of normal images are selected from glass sample images as the training set, and the test set includes normal images and defect images. The size ratio of the training set to the test set is 7:3.
[0072] According to an embodiment of the present invention, the model is trained based on the training set to obtain a multimodal teacher and student network training model, which specifically includes:
[0073] Obtain normal sample images and text description samples, create pseudo abnormal images based on the normal sample images, and pre-process the pseudo abnormal images;
[0074] Extract image features, encode image features based on the encoder, decode the encoded image features based on the student encoder, obtain patch features and global features, and perform multi-layer feature reconstruction training based on patch features;
[0075] Extracting features of text description samples, encoding the features of text description samples based on the encoder to obtain normal text encoding and abnormal text encoding;
[0076] Based on global features, normal text encoding and abnormal text encoding, multimodal information is aligned and trained to obtain a multimodal teacher and student network training model.
[0077] It should be noted that in the process of generating pseudo-abnormal images, it is necessary to produce test data mask labels. In unsupervised defect detection, since the training set only contains normal samples, the labelers only need to perform fine pixel-level labeling on the defect samples in the test set to obtain the defect sample mask labeling.
[0078] According to an embodiment of the present invention, multi-layer feature reconstruction training is performed based on patch features, specifically including:
[0079] Using the student network to distill the teacher network to extract normal sample features, the optimization goal is:
[0080] ;
[0081] ;
[0082] in, and Respectively represent The layer feature map is The feature vector of the position, represents the transpose operation of the matrix, express Figure 1 Mid-layer feature reconstruction loss.
[0083] According to an embodiment of the present invention, the multimodal information alignment training specifically includes: generating journey text features and abnormal text features based on normal text encoding and abnormal text encoding, respectively, and the normal text features are recorded as , the abnormal text feature is recorded as , where the dimensions of both are , size and student network output category global features Keeping it consistent, the optimization goal related to multimodal information is:
[0084] ;
[0085] in, represents the multimodal alignment loss, represents exponential operation, represents the temperature coefficient, Represents the category global feature (class-token) of the feature attention map of the normal sample image under Transformer encoding, Represents the category global feature (class-token) of the feature attention map of the artificial pseudo-anomaly sample image under Transformer encoding.
[0086] Specifically, the multimodal alignment loss The specific explanation is as follows: Represents the category global feature (class-token) of the feature attention map of a normal sample image under Transformer encoding. The category global feature integrates the global information of an image. It is the language feature of the designed language template "a photo of normal glass-bottle" under Transformer encoding. Both represent normal information in their respective modes, so by performing matrix multiplication on the two, the two are made close enough, that is, the left part of the formula. On the other hand, we perform Transformer encoding on the abnormal sample to obtain the abnormal global feature , abnormal global features and designed abnormal language template: characteristics of "aphoto of abnormal glass-bottle with defect" Perform matrix multiplication to make the two close enough so that pictures with different attributes can be aligned with their corresponding language templates.
[0087] Specifically, the advantages of the multimodal alignment loss of this application are:
[0088] (1) Improving the performance of unsupervised defect detection. In the unsupervised distillation detection framework, the core goal is to train the student network to extract positive sample features similar to those extracted by the teacher network. The core purpose of the loss is to make the features encoded by the teacher network and the features decoded by the student consistent in the language feature space, which is equivalent to adding an extra layer of constraints to the distillation, making the detection effect better.
[0089] (2) Negative alignment (i.e., the second part of the formula) is introduced to enhance the alignment effect. In addition to aligning normal sample images with normal text, abnormal sample images with abnormal text are also aligned.
[0090] It needs to be explained that the abnormal sample images are obtained by performing some image processing operations on normal images. Through optimization, the normal samples will be kept away from the abnormal text, thus being closer to the normal text.
[0091] The overall optimization goal of the training phase is:
[0092] ;
[0093] in is a hyperparameter.
[0094] It should be noted that, when using the trained multimodal model for reasoning, we first calculate As one of the anomaly scores, we calculate the category global feature and abnormal text feature of the test sample and record it as The similarity is taken as the second anomaly score, and the two are added together as the final anomaly score.
[0095] According to an embodiment of the present invention, the multimodal teacher and student network training model is tested based on a test set, specifically including:
[0096] Acquire a test sample image, and preprocess the test sample image;
[0097] Encoding the preprocessed test sample image based on the encoder;
[0098] Decode the encoded test sample image according to the student decoder to obtain patch features and global features;
[0099] Generate feature reconstruction scores based on patch features and text matching scores based on global features;
[0100] The training results are obtained based on the feature reconstruction score and the text matching score.
[0101] According to an embodiment of the present invention, the multimodal teacher-student network includes a teacher network and a student network. The multimodal model CLIP-ViT-16B pre-trained on massive data is used. The backbone network of the model uses the ViT model with 12 layers of multi-head attention modules. A three-layer multi-head attention module is used; during the training phase, the training sample images of size 256×256×3 Input the teacher network and extract the features of its 3, 6, and 9 layers respectively, recorded as , , , size is After concatenating the three layers of features, they are aggregated through a linear network, and then the aggregated features are input into the student network. The features output by each layer of the student network are recorded as , , , size is .
[0102] According to an embodiment of the present invention, a pseudo-abnormal sample is generated based on a pseudo-abnormal image, and the pseudo-abnormal sample generation method is as follows: a pseudo-abnormal sample is synthesized using an image processing technique with a normal sample in a training set as a template, noise matching the size of the original image is collected from Perlin noise, and a mask is generated after binarization; the mask is intersected with a texture image prepared in advance to obtain a pseudo-defect morphology image, and the obtained pseudo-defect morphology image is pasted onto the original normal sample image to obtain a final pseudo-abnormal sample image.
[0103] like Figure 1 As shown in the figure, the training and testing processes of the defect detection framework are as follows: In the training phase, the preprocessed normal samples and the pseudo-anomalies are jointly input into the encoding network for encoding, and then the encoded features are input into the student decoder for decoding to obtain patch-level features for the above-mentioned feature reconstruction training. The obtained category normal global features 1 and abnormal global features 2 are respectively trained with the normal encoding and abnormal encoding described in this article for multimodal alignment. In the testing phase, the test samples are input into the encoder and decoder, and the obtained patch features and global features are used to calculate the defect detection performance indicators by calculating the same reconstruction loss and alignment loss as in the training phase as the feature reconstruction score and text matching score.
[0104] Experimental results:
[0105] In order to verify the effectiveness of the algorithm in this application, the glass bottles in the public dataset MVTech AD were selected as the test dataset and randomly divided into 5 parts. The performance and visualization results were obtained using cross-validation, as shown in Table 1.
[0106] Table 1
[0107]
[0108] The ROC score in Table 1 is called the receiver operating characteristic curve, which is widely used in binary classification tasks such as defect detection.
[0109] Table 1 includes testing the glass bottle dataset in the public dataset MVtech, and divides the training set and the test set into 5 parts on average, combining them into 5 sub-datasets. The training data of the 5 sub-datasets in Table 1 are used for their corresponding test sets, and finally the performance of 5 evaluation indicators is obtained.
[0110] All data in Table 1 are experimental results of the algorithm proposed in the present invention. It can be seen from Table 1 that the present invention has a very high defect detection capability. Subtest set 4 and subtest set 5 both achieve 100% image-level detection performance. On all subtest sets, the pixel-level ROC scores of the present invention exceed 90%.
[0111] like Figure 2-Figure 5 These are the visualization results obtained after testing the test data set in Table 1. The first column is the test sample (glass bottle), the second column is the test data mask label, and the third column is the detection heat map (visualization result), that is, the test result.
[0112] In summary, the multimodal unsupervised framework of the present application has stronger generalization, that is, it can detect many abnormal samples that have not been collected. The CLIP model with rich prior knowledge increases the migration ability of the model, allowing it to adapt to different types of glass quality inspection environments. It utilizes the feature information and global information of different layers of the ViT model to jointly detect anomalies, greatly improving the defect location capability. In addition, the injection of text information will further enhance the detection capability.
[0113] The above description of the disclosed embodiments enables one skilled in the art to implement or use the present invention. Various modifications to the above embodiments will be apparent to one skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention will not be limited to the above embodiments shown herein, but rather to the widest scope consistent with the principles and novel features disclosed herein.
[0114] The above are only specific embodiments of the present invention, but the protection scope of the present invention is not limited thereto. Any person skilled in the art who is familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed by the present invention, which should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention should be based on the protection scope of the claims.
Claims
1. A glass defect detection method based on a multimodal teacher and student framework, characterized in that: The steps include: A large number of defect-free samples and a small number of samples with various defects are collected from the glass production line, and cleaned to obtain different modal information, including glass sample images and text description samples; Generate training and test sets based on glass sample images and text description samples; The model is trained based on the training set to obtain a multimodal teacher and student network training model; The multimodal teacher and student network training model is tested based on the test set, and the model parameters are dynamically adjusted based on the test results to obtain the final multimodal teacher and student network training model; Generate glass defect detection results based on the final multimodal teacher and student network training model; A large number of defect-free samples and a small number of samples with various defects are collected from the glass production line and cleaned to obtain different modal information. The different modal information includes glass sample images and text description samples; specifically, they include: Obtain glass samples, clean the glass samples, remove dust from the glass surface, illuminate the collected samples based on optical technology, take photos, and obtain high-quality glass sample images after secondary calibration; Classify the glass sample images to obtain normal sample images and defective sample images; Design templates for normal sample images and defect sample images respectively, generate normal text and defect text, and obtain text description samples; The model is trained based on the training set to obtain a multimodal teacher and student network training model, which specifically includes: Obtain a normal sample image and a text description sample, create a pseudo abnormal sample image based on the normal sample image, and pre-process the pseudo abnormal sample image; Extract image features, encode image features based on the encoder, decode the encoded image features based on the student encoder, obtain patch features and global features, and perform multi-layer feature reconstruction training based on patch features; Extracting features of text description samples, encoding the features of text description samples based on the encoder to obtain normal text encoding and abnormal text encoding; Based on global features, normal text encoding and abnormal text encoding, multimodal information is aligned and trained to obtain a multimodal teacher and student network training model; The multimodal teacher and student network includes the teacher network and the student network. The multimodal model CLIP-ViT-16B pre-trained on massive data is used. The backbone network of the model uses the ViT model with 12 layers of multi-head attention modules. A three-layer multi-head attention module is used; during the training phase, the training sample images of size 256×256×3 Input the teacher network and extract the features of its 3, 6, and 9 layers respectively, recorded as , , , size is After concatenating the three layers of features, they are aggregated through a linear network, and then the aggregated features are input into the student network. The output features of each layer of the student network are recorded as , , , size is .
2. A glass defect detection method based on a multimodal teacher and student framework according to claim 1, characterized in that: The training set is obtained by screening a large number of normal sample images from glass sample images as the training set, and the test set includes normal sample images and defect sample images, and the size ratio of the training set to the test set is 7:
3.
3. The glass defect detection method based on a multimodal teacher and student framework according to claim 1, characterized in that: Multi-layer feature reconstruction training is performed based on patch features, specifically including: Using the student network to distill the teacher network to extract normal sample features, the optimization goal is: ; ; in, and Respectively represent The layer feature map is The feature vector of the position, represents the transpose operation of the matrix, where Represents the characteristics of the i-th layer of the teacher network and the student network and Cosine similarity score, Represents the multi-layer feature reconstruction loss.
4. The glass defect detection method based on a multimodal teacher and student framework according to claim 3 is characterized in that: The multimodal information alignment training specifically includes: generating normal text features and abnormal text features based on normal text encoding and abnormal text encoding respectively, and the normal text features are recorded as , the abnormal text feature is recorded as , where the dimensions of both are , size and student network output category global Keeping it consistent, the optimization goal related to multimodal information is: ; in, represents the multimodal alignment loss, represents exponential operation, represents the temperature coefficient, Represents the category global features of the feature attention map of the normal sample image under Transformer encoding, Represents the category global features of the feature attention map of artificial pseudo-abnormal sample images under Transformer encoding; The overall optimization goal of the training phase for: ; in is a hyperparameter.
5. The glass defect detection method based on a multimodal teacher and student framework according to claim 1, characterized in that: The multimodal teacher and student network training model is tested based on the test set, including: Acquire a test sample image, and preprocess the test sample image; Encoding the preprocessed test sample image based on the encoder; Decode the encoded test sample image according to the student decoder to obtain patch features and global features; Generate feature reconstruction scores based on patch features and text matching scores based on global features; The final anomaly score is obtained by the weighted sum of the feature reconstruction score and the text matching score, and then the AUROC index of the anomaly score and the true label is calculated to obtain the final detection performance.
6. The glass defect detection method based on a multimodal teacher and student framework according to claim 1, characterized in that: The pseudo abnormal sample image is produced based on the normal sample image. The pseudo abnormal sample image production method is as follows: using image processing technology to synthesize a pseudo abnormality with a normal sample in the training set as a template, collecting noise that matches the size of the original image from Perlin noise, and generating a mask after binarization; The mask is intersected with the texture image prepared in advance to obtain a pseudo defect morphology map, and the obtained pseudo defect morphology map is pasted onto the original normal sample image to obtain the final pseudo abnormal sample image.
