A photovoltaic cell defect detection method based on Transformer
By combining multi-teacher knowledge distillation and feature recalibration modules with QuadMix data augmentation technology, the problem of overfitting in the ViT model in photovoltaic cell defect detection is solved, achieving a more efficient defect detection effect.
Patent Information
- Application Number
- CN202411525609.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-30
- Publication Date
- 2025-01-07
- Estimated Expiration
- 2044-10-30
AI Technical Summary
Existing ViT models are prone to overfitting in photovoltaic cell defect detection, leading to performance degradation, especially when the sample size is limited, making it difficult to effectively detect photovoltaic cell defects.
A multi-teacher knowledge distillation strategy is adopted, combining CNN and ViT teacher networks for knowledge distillation. The accuracy of photovoltaic cell defect detection is improved through feature recalibration module and QuadMix data augmentation technology.
It significantly improves the performance of photovoltaic cell defect detection, making the detection results more accurate, especially performing well on small-scale datasets, and solves the problem of overfitting in the ViT model.
Smart Images

Figure CN119048501B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of photovoltaic cell defect detection, and in particular to a photovoltaic cell defect detection method based on Transformer. Background Art
[0002] Photovoltaic cells, as key components for converting solar energy into electrical energy, play a central role in promoting sustainable energy. Their quality is directly related to power generation efficiency and the long-term durability of equipment, highlighting the critical importance of ensuring the quality of photovoltaic cell products in large-scale production. Therefore, strengthening automated inspection technology has become the cornerstone for maintaining excellent quality in mass production. In recent years, ViT (Vision Transformer) technology has demonstrated outstanding results in a variety of visual recognition applications and ushered in a new era of intelligent inspection. However, faced with the realistic constraints of limited sample size, the ViT model is prone to overfitting, which greatly reduces its performance. Summary of the invention
[0003] Based on this, it is necessary to provide a photovoltaic cell defect detection method based on Transformer, which includes:
[0004] S1: Obtain the photovoltaic cell surface image, stitch four different photovoltaic cell surface images into a single input image, and provide a unique hot label for it;
[0005] S2: Divide the input image into multiple small blocks, and perform layer normalization on the divided input image;
[0006] S3: stacking N Transformer blocks to form a first feature extraction module, and subjecting the first feature extraction module to multi-teacher knowledge distillation; the normalized features are subjected to knowledge distillation to output low-level features of the first feature extraction module;
[0007] S4: passing the low-level features through a feature recalibration module to calculate binary classification scores, and reweighting the low-level features based on the binary classification scores to obtain recalibrated features;
[0008] S5: stack M Transformer blocks to form a second feature extraction module, and subject the second feature extraction module to multi-teacher knowledge distillation; the normalized recalibrated features are subjected to knowledge distillation by the second feature extraction module to output defect detection results.
[0009] Preferably, the image stitching formula is:
[0010] ;
[0011] in, represents the input image; Represents a splicing operation; Indicates i An image of the photovoltaic cell surface; Indicates j An image of the photovoltaic cell surface; Indicates k An image of the photovoltaic cell surface; Indicates l An image of the photovoltaic cell surface;
[0012] The unique hot label calculation formula is:
[0013] ;
[0014] in, Represents the unique hot label of the input image, 1 means defective, 0 means no defect; Indicates i A label carried by an image of the photovoltaic cell surface; Indicates j A label carried by an image of the photovoltaic cell surface; Indicates k A label carried by an image of the photovoltaic cell surface; Indicates l An image of the surface of a photovoltaic cell carrying a label.
[0015] Preferably, the multi-teacher knowledge distillation includes using a ViT teacher network and a CNN teacher network to perform combined knowledge distillation;
[0016] Setting a ViT distillation tag and a CNN distillation tag, and setting a feature adaptation module between the teacher network and the student network; the feature adaptation module includes an upsampling and a convolution layer, which is used to eliminate the feature gap between the teacher network and the student network;
[0017] The input image is passed through the CNN teacher network, and the distillation loss of the CNN teacher network is calculated using the following formula:
[0018] ;
[0019] in, represents the distillation loss of the CNN teacher network; L represents the number of layers contained in the CNN teacher network or the ViT teacher network; N represents the number of distillation tags; Indicates the first i The first feature adaptation module j CNN distillation tags; Represents the CNN teacher network i Layer j CNN distillation tags;
[0020] The normalized features are passed through the ViT teacher network to calculate the distillation loss of the ViT teacher network. The calculation formula is:
[0021] ;
[0022] in, represents the distillation loss of the ViT teacher network; represents the first i The second feature adaptation module j ViT distillation markers; Indicates the ViT teacher network i Layer j ViT distillation markers;
[0023] The normalized features are passed through any student network to calculate the logical value loss of the student network and the teacher network. The calculation formula is:
[0024] ;
[0025] in, Indicates logical value loss; represents the cross entropy loss; A logical value representing any kind of student network; represents the softmax function; represents the hard target of the CNN teacher network; represents the hard target of the ViT teacher network;
[0026] The student network includes a first feature extraction module and a second feature extraction module;
[0027] Based on the distillation loss of the CNN teacher network, the distillation loss of the ViT teacher network, and the logical value loss, the overall optimization goal of multi-teacher knowledge distillation is calculated, and any student network is trained through the overall optimization goal until the overall optimization goal converges;
[0028] The total optimization target calculation formula is:
[0029] ;
[0030] in, represents the overall optimization objective; represents the first balance weight coefficient; Represents the second balancing weight coefficient.
[0031] Preferably, N+M Transformer blocks are stacked in the ViT teacher network; and the CNN teacher network adopts ResNet-50.
[0032] Preferably, in any Transformer block, the normalized data is input into the multi-head self-attention layer in the Transformer block to obtain the attention output; the attention output is residually connected with the normalized data to obtain the feature representation with attention; the feature representation with attention is layer-normalized again and input into the feedforward network layer in the Transformer block to obtain the nonlinear feature; the nonlinear feature is residually connected with the feature representation with attention to obtain the feature output of the Transformer block.
[0033] Preferably, the process of obtaining the recalibration feature comprises:
[0034] Step 1: Pass the low-level features through the classification linear layer in the feature recalibration module to obtain the binary classification score, which is calculated as follows:
[0035] ;
[0036] in, represents the binary classification score; represents a classification linear layer; Represents low-level features; Represents the weight matrix of the classification linear layer; Represents the bias of the classification linear layer;
[0037] The binary scores include positive and negative scores;
[0038] Step 2: Calculate positive features and negative features based on positive and negative scores and low-level features. The calculation formula is:
[0039] ;
[0040] ;
[0041] in, Indicates positive features; Indicates negative features; indicates a positive score; indicates a negative score; represents element-wise multiplication;
[0042] Step 3: Convolve the positive features and negative features respectively, and fuse them with the low-level features to obtain the recalibrated features; the calculation formula is:
[0043] ;
[0044] in, represents the recalibration feature; represents the first convolutional layer; Represents the second convolutional layer.
[0045] Preferably, the classification linear layer is trained by a classification loss, and the classification loss is calculated by the hard target and the binary classification score of the CNN teacher network, and the calculation formula is:
[0046] ;
[0047] in, represents the classification loss; represents the cross entropy loss; represents the binary classification score; represents the hard target of the CNN teacher network.
[0048] Preferably, the total loss function is calculated based on the total optimization target, the classification loss and the original classification loss, and the overall process of photovoltaic cell defect detection is trained by the total loss function; the total loss function expression is:
[0049] ;
[0050] ;
[0051] in, represents the total loss function; represents the original classification loss; represents the third balance weight coefficient; represents the classification loss; represents the overall optimization objective; represents the cross entropy loss; A logical value representing any kind of student network; represents the softmax function; Represents the true value of the label.
[0052] Beneficial effects: This method significantly improves the detection performance of photovoltaic cell defects through the designed multi-teacher knowledge distillation strategy and recalibration module, making the defect detection results more accurate. BRIEF DESCRIPTION OF THE DRAWINGS
[0053] In order to more clearly illustrate the embodiments of the present application 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 application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0054] Figure 1This is a flow chart of a photovoltaic cell defect detection method based on Transformer according to an embodiment of the present application.
[0055] Figure 2 Schematic diagram of the architecture of the defect detection model according to an embodiment of the present application.
[0056] Figure 3 Flowchart of multi-teacher knowledge distillation according to an embodiment of the present application.
[0057] Figure 4 Flow chart of feature recalibration according to an embodiment of the present application.
[0058] Figure 5 This is a schematic diagram of the structure of the Transformer block of an embodiment of the present application. DETAILED DESCRIPTION
[0059] In order to make the above-mentioned purposes, features and advantages of the present application more obvious and easy to understand, the specific implementation methods of the present application are described in detail below in conjunction with the accompanying drawings. In the following description, many specific details are set forth to facilitate a full understanding of the present application. However, the present application can be implemented in many other ways different from those described herein, and those skilled in the art can make similar improvements without violating the connotation of the present application, so the present application is not limited by the specific embodiments disclosed below.
[0060] In addition, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Therefore, the features defined as "first" and "second" may explicitly or implicitly include at least one of the features. In the description of this application, the meaning of "plurality" is at least two, such as two, three, etc., unless otherwise clearly and specifically defined.
[0061] like Figure 1 As shown, this embodiment provides a photovoltaic cell defect detection method based on Transformer, such as Figure 2 As shown in the figure, this implementation proposes a defect detection model, which is a novel and efficient Transformer architecture optimized for photovoltaic cell defect detection. This model adopts a carefully designed three-layer improvement strategy: the supervision layer adopts multi-teacher knowledge distillation MTD, the architecture layer adds a feature recalibration module FRM, and the data layer applies QuadMix data augmentation technology.
[0062] A photovoltaic cell defect detection method based on Transformer includes:
[0063] S1: Obtain the photovoltaic cell surface image, stitch four different photovoltaic cell surface images into a single input image, and provide it with a unique hot label.
[0064] This embodiment proposes QuadMix data augmentation technology, an image mixing technology that splices four images into a single input image and provides consistent one-hot labels for defect detection tasks. QuadMix is easy to train and introduces minimal computational overhead. Similar to mosaic enhancement, QuadMix randomly mixes four training images into one input image. However, in addition to simple random cropping and horizontal flipping, QuadMix does not apply other enhancements such as scale jittering, random perspective, and color jittering. Unlike Mixup, which randomly weights and mixes target labels, QuadMix only generates single-hot labels for binary classification tasks to prevent the network from being misled.
[0065] Specifically, the image stitching formula is:
[0066] ;
[0067] in, represents the input image; Represents a splicing operation; Indicates i An image of the photovoltaic cell surface; Indicates j An image of the photovoltaic cell surface; Indicates k An image of the photovoltaic cell surface; Indicates l An image of the photovoltaic cell surface;
[0068] The unique hot label calculation formula is:
[0069] ;
[0070] in, Represents the unique hot label of the input image, 1 means defective, 0 means no defect; Indicates i A label carried by an image of the photovoltaic cell surface; Indicates j A label carried by an image of the photovoltaic cell surface; Indicates k A label carried by an image of the photovoltaic cell surface; Indicates l An image of the surface of a photovoltaic cell carrying a label.
[0071] S2: Divide the input image into multiple small blocks, and perform layer normalization on the divided input image.
[0072] Specifically, the input image will be divided into There are small blocks of the same size and no overlap,H represents the height of the input image, W represents the width of the input image, p 2 Indicates the size of the divided image block. The width and height of the image block are p ,and H and W Both greater than p Before entering the multi-head self-attention layer (MSA) layer or the feed-forward network layer (FFN), layer normalization is performed on the input to keep the input of each layer in the network with stable statistical characteristics, thereby accelerating training and improving performance.
[0073] S3: N Transformer blocks are stacked to form a first feature extraction module, and the first feature extraction module is subjected to multi-teacher knowledge distillation; the normalized features are output as low-level features by the first feature extraction module after knowledge distillation.
[0074] In this embodiment, in order to make full use of the knowledge contained in the teacher network, a dense knowledge distillation strategy is designed to transfer knowledge in the output layer and the intermediate layer. In addition, when the training data is small, CNN generally performs better than Transformer. In order to extract the inductive bias of CNN into Transformer, another CNN teacher network ResNet-50 is used. Drawing on the setting of DeiT, two independent distillation tokens are introduced in the defect detection model proposed in the present invention for double logits distillation, which helps the student model to learn the hard predictions of the CNN teacher network and the ViT teacher network at the same time, thereby inheriting the knowledge of the teacher network more comprehensively. Taking advantage of the inductive bias of CNN and the global attention mechanism of ViT, knowledge is provided complementary to enhance the representation ability of the student model.
[0075] like Figure 3 As shown, the multi-teacher knowledge distillation includes using a ViT teacher network and a CNN teacher network for combined knowledge distillation; N+M Transformer blocks are stacked in the ViT teacher network.
[0076] A ViT distillation marker and a CNN distillation marker are set, and a feature adaptation module is set between the teacher network and the student network; the feature adaptation module includes upsampling and convolution layers, which are used to eliminate the feature gap between the teacher network and the student network; the features of the CNN teacher network and the ViT teacher network are upsampled using nearest neighbor interpolation to make them consistent in size, and then the local information is further enhanced through a 3x3 convolution kernel.
[0077] The input image is passed through the CNN teacher network, and the distillation loss of the CNN teacher network is calculated using the following formula:
[0078] ;
[0079] in, represents the distillation loss of the CNN teacher network; L represents the number of layers contained in the CNN teacher network or the ViT teacher network; N represents the number of distillation tags; Indicates the first i The first feature adaptation module j CNN distillation tags; Represents the CNN teacher network i Layer j CNN distillation tags;
[0080] The normalized features are passed through the ViT teacher network to calculate the distillation loss of the ViT teacher network. The calculation formula is:
[0081] ;
[0082] in, represents the distillation loss of the ViT teacher network; represents the first i The second feature adaptation module j ViT distillation markers; Indicates the ViT teacher network i Layer j ViT distillation markers;
[0083] The normalized features are passed through any student network to calculate the logical value loss of the student network and the teacher network. The calculation formula is:
[0084] ;
[0085] in, Indicates logical value loss; represents the cross entropy loss; A logical value representing any kind of student network; represents the softmax function; represents the hard target of the CNN teacher network; represents the hard target of the ViT teacher network;
[0086] The student network includes a first feature extraction module and a second feature extraction module;
[0087] Based on the distillation loss of the CNN teacher network, the distillation loss of the ViT teacher network, and the logical value loss, the overall optimization goal of multi-teacher knowledge distillation is calculated, and any student network is trained through the overall optimization goal until the overall optimization goal converges;
[0088] The total optimization target calculation formula is:
[0089] ;
[0090] in, represents the overall optimization objective; represents the first balance weight coefficient; Represents the second balancing weight coefficient.
[0091] In order to eliminate the differences in features between teacher networks (CNN and ViT) with different architectures and the student network, the defect detection model introduces a feature adaptation module (FA). This module adjusts the size of features and enhances local information through upsampling and convolutional layers to ensure that the student network can effectively absorb multi-level knowledge from different teachers. Inspired by DeiT, the defect detection model introduces two independent distillation markers in the student network for double logits distillation. This strategy helps the student network learn the hard predictions of CNN and ViT teacher networks at the same time, thereby inheriting the knowledge of the teacher network more comprehensively. By adjusting the coefficients of the balanced distillation loss, such as setting , , to optimize the effect of knowledge transfer and ensure that the student model can effectively learn and integrate knowledge from different teachers.
[0092] Through the multi-teacher knowledge distillation strategy, the high-level and low-level knowledge from the teacher networks of different architectures (CNN and ViT) are effectively integrated, improving the performance of the student network on the photovoltaic cell defect detection task. This strategy not only promotes the alignment and optimization of features, but also enhances the feature extraction ability of the model through multi-stage knowledge transfer, and ultimately enables the defect detection model to achieve significantly better results than the baseline and other competitive methods on the photovoltaic defect detection task, enabling the defect detection model to show significant performance improvements on the photovoltaic cell defect detection task, especially for small-scale data sets, effectively solving the problem of the ViT model's easy overfitting.
[0093] And knowledge distillation does not only occur at the output layer, but throughout multiple levels of the entire network. By performing knowledge distillation at different levels, the student model is able to receive supervision signals from each layer of the teacher network, which helps with feature alignment and optimization, as well as the extraction of deeper features. Multi-stage knowledge transfer enhances the model's feature extraction capabilities, and the student model is able to learn richer and more refined feature representations, which is crucial for identifying subtle defects in photovoltaic cells. By fusing the knowledge of teachers with different architectures, the robustness of the student model is enhanced, and it can more stably process photovoltaic cell images under various lighting, angles, and background conditions. With the introduction of the feature adaptation module, the defect detection model can more effectively utilize computing resources, reduce redundant calculations caused by feature size mismatch, and improve overall training efficiency.
[0094] S4: Pass the low-level features through a feature recalibration module to calculate binary classification scores, and reweight the low-level features based on the binary classification scores to obtain recalibrated features.
[0095] In this embodiment, the defect detection model introduces an attention-based feature recalibrating module (FRM), which helps ViT to more effectively utilize the underlying feature information in photovoltaic defect detection tasks and improve the detection performance of the model. By combining the underlying feature information with the classification confidence score, FRM can fine-tune the features, making the model more accurate in photovoltaic cell defect detection.
[0096] Specifically, Figure 4 As shown, the process of obtaining the recalibration characteristics includes:
[0097] Step 1: Pass the low-level features through the classification linear layer in the feature recalibration module to obtain the binary classification score, which is calculated as follows:
[0098] ;
[0099] in, represents the binary classification score; represents a classification linear layer; Represents low-level features; Represents the weight matrix of the classification linear layer; Represents the bias of the classification linear layer;
[0100] The binary scores include positive and negative scores;
[0101] Step 2: Calculate positive features and negative features based on positive and negative scores and low-level features. The calculation formula is:
[0102] ;
[0103] ;
[0104] in, Indicates positive features; Indicates negative features; indicates a positive score; indicates a negative score; represents element-wise multiplication;
[0105] Step 3: Convolve the positive features and negative features respectively, and fuse them with the low-level features to obtain the recalibrated features; the calculation formula is:
[0106] ;
[0107] in, represents the recalibration feature; represents the first convolutional layer; Represents the second convolutional layer.
[0108] In this embodiment, the classification linear layer is further trained by classification loss, and the classification loss is calculated by hard targets and binary classification scores of the CNN teacher network, and the calculation formula is:
[0109] ;
[0110] in, represents the classification loss; represents the cross entropy loss; represents the binary classification score; represents the hard target of the CNN teacher network.
[0111] The role of FRM is that it re-weights the underlying features through the classification confidence scores generated by the early classification strategy to better utilize the information in these features. This helps ViT to more effectively utilize the underlying feature information in the photovoltaic defect detection task and improve the detection performance of the model. By combining the underlying feature information with the classification confidence scores, FRM is able to fine-tune the features, making the model more accurate in photovoltaic cell defect detection. In addition, by using the final predictions of the CNN teacher network to guide the training of the classification linear layer, the classification ability of the model can be further enhanced, ultimately improving the overall detection performance.
[0112] S5: stack M Transformer blocks to form a second feature extraction module, and subject the second feature extraction module to multi-teacher knowledge distillation; the normalized recalibrated features are subjected to knowledge distillation by the second feature extraction module to output defect detection results.
[0113] In this embodiment, if Figure 5As shown in Figure 1, for any Transformer block, the normalized data is input into the multi-head self-attention layer in the Transformer block to obtain the attention output; the calculation formula is:
[0114] ;
[0115] ;
[0116] ;
[0117] ;
[0118] in, represents a multi-head self-attention layer; , and Represents query, key, and value respectively, and their sizes are , H represents the height of the input image, W represents the width of the input image, p 2 Indicates the size of the divided image block. The width and height of the image block are p ,and H and W Both greater than p , is the channel dimension of the feature, , and They are the fully connected layer query weight matrix, the fully connected layer key weight matrix, and the fully connected layer value weight matrix, which are used to convert the input into query, key, and value; represents the softmax function; x represents normalized data;
[0119] The attention output is residually connected with the normalized data to obtain the feature representation with attention; the calculation formula is:
[0120] ;
[0121] in, Indicates l - Feature representation with attention in 1 Transformer block; Representation layer normalization; Indicates l - Output of 1 Transformer block;
[0122] The feature representation with attention is layer normalized again and input into the feedforward network layer in the Transformer block to obtain nonlinear features; the feedforward network layer mainly performs MLP calculations, which are applied to each small image block and consist of two linear layers and nonlinear activations in between. The nonlinear features are residually connected with the feature representation with attention to obtain the features output by the Transformer block. This jump connection helps alleviate the gradient vanishing problem and enables the model to train deeper networks; the calculation formula is:
[0123] ;
[0124] ;
[0125] in, Indicates l The output of a Transformer block; represents a feed-forward network layer; Represents a nonlinear activation function, and GELU (Gaussian Error Linear Unit) is usually used in Transformer; Represents the weight matrix of the first linear layer; Represents the weight matrix of the second linear layer; represents the bias term of the first linear layer; Represents the bias term of the second linear layer.
[0126] The Transformer block proposed in this embodiment realizes feature learning and information transfer in deep learning by alternating the self-attention mechanism and feedforward neural network, combined with layer normalization and residual connection. This design allows the model to capture long-distance dependencies and improves training efficiency through parallel computing. It can effectively extract the features of image block sequences and enhance the expressiveness of the model. Especially in the scenario of processing limited sample size, through the multi-head self-attention mechanism, the model can focus on the information of different subspaces in the image and improve the detection accuracy.
[0127] Furthermore, the total loss function is calculated based on the total optimization target, classification loss and original classification loss, and the overall process of photovoltaic cell defect detection is trained through the total loss function; the total loss function expression is:
[0128] ;
[0129] ;
[0130] in, represents the total loss function; represents the original classification loss; represents the third balance weight coefficient; represents the classification loss; represents the overall optimization objective; represents the cross entropy loss; A logical value representing any kind of student network; represents the softmax function; Represents the true value of the label.
[0131] The method provided in this embodiment effectively overcomes the problem of overfitting through supervision strategy enhancement, architectural innovation adjustment and data augmentation technology, significantly improves the practical effectiveness of ViT in the field of photovoltaic quality control, and marks another solid step towards smart manufacturing and a green future. Specifically, a mixed image enhancement method called QuadMix enhancement is first proposed to randomly mix positive and negative samples for binary classification tasks. Finally, ViT and CNN are used as a composite teacher network to perform combined knowledge distillation on Transformer students. In addition, a new attention-based module is developed to reweight deep features through intermediate classification scores. Thanks to the overall efficient design, the defect detection model significantly improves the detection performance of the ViT model on the dataset.
[0132] The technical features of the above-described embodiments may be arbitrarily combined. To make the description concise, not all possible combinations of the technical features in the above-described 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.
[0133] The above-described 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 photovoltaic cell defect detection method based on Transformer, characterized in that: include: S1: Obtain the photovoltaic cell surface image, stitch four different photovoltaic cell surface images into a single input image, and provide a unique hot label for it; S2: Divide the input image into multiple small blocks, and perform layer normalization on the divided input image; S3: stacking N Transformer blocks to form a first feature extraction module, and subjecting the first feature extraction module to multi-teacher knowledge distillation; the normalized features are subjected to knowledge distillation to output low-level features of the first feature extraction module; S4: passing the low-level features through a feature recalibration module to calculate binary classification scores, and reweighting the low-level features based on the binary classification scores to obtain recalibrated features; The process of obtaining the recalibration characteristics includes: Step 1: Pass the low-level features through the classification linear layer in the feature recalibration module to obtain the binary classification score, which is calculated as follows: ; in, represents the binary classification score; represents a classification linear layer; Represents low-level features; Represents the weight matrix of the classification linear layer; Represents the bias of the classification linear layer; The binary scores include positive and negative scores; Step 2: Calculate positive features and negative features based on positive and negative scores and low-level features. The calculation formula is: ; ; in, Indicates positive features; Indicates negative features; indicates a positive score; indicates a negative score; represents element-wise multiplication; Step 3: Convolve the positive features and negative features respectively, and fuse them with the low-level features to obtain the recalibrated features; the calculation formula is: ; in, represents the recalibration feature; represents the first convolutional layer; represents the second convolutional layer; S5: stacking M Transformer blocks to form a second feature extraction module, and subjecting the second feature extraction module to multi-teacher knowledge distillation; the normalized recalibrated features are subjected to knowledge distillation, and the second feature extraction module outputs a defect detection result; The multi-teacher knowledge distillation includes using a ViT teacher network and a CNN teacher network to perform combined knowledge distillation; Setting a ViT distillation tag and a CNN distillation tag, and setting a feature adaptation module between the teacher network and the student network; the feature adaptation module includes an upsampling and a convolution layer, which is used to eliminate the feature gap between the teacher network and the student network; The input image is passed through the CNN teacher network, and the distillation loss of the CNN teacher network is calculated using the following formula: ; in, represents the distillation loss of the CNN teacher network; L represents the number of layers contained in the CNN teacher network or the ViT teacher network; N represents the number of distillation tags; Indicates the first i The first feature adaptation module j CNN distillation tags; Represents the CNN teacher network i Layer j CNN distillation tags; The normalized features are passed through the ViT teacher network to calculate the distillation loss of the ViT teacher network. The calculation formula is: ; in, represents the distillation loss of the ViT teacher network; represents the first i The second feature adaptation module j ViT distillation markers; Indicates the ViT teacher network i Layer j ViT distillation markers; The normalized features are passed through any student network to calculate the logical value loss of the student network and the teacher network. The calculation formula is: ; in, Indicates logical value loss; represents the cross entropy loss; A logical value representing any kind of student network; represents the softmax function; represents the hard target of the CNN teacher network; represents the hard target of the ViT teacher network; The student network includes a first feature extraction module and a second feature extraction module; Based on the distillation loss of the CNN teacher network, the distillation loss of the ViT teacher network, and the logical value loss, the overall optimization goal of multi-teacher knowledge distillation is calculated, and any student network is trained through the overall optimization goal until the overall optimization goal converges; The total optimization target calculation formula is: ; in, represents the overall optimization objective; represents the first balance weight coefficient; Represents the second balancing weight coefficient.
2. The photovoltaic cell defect detection method based on Transformer according to claim 1, characterized in that: The image stitching formula is: ; in, represents the input image; Represents a splicing operation; Indicates i An image of the photovoltaic cell surface; Indicates j An image of the photovoltaic cell surface; Indicates k An image of the photovoltaic cell surface; Indicates l An image of the photovoltaic cell surface; The unique hot label calculation formula is: ; in, Represents the unique hot label of the input image, 1 means defective, 0 means no defect; Indicates i A label carried by an image of the photovoltaic cell surface; Indicates j A label carried by an image of the photovoltaic cell surface; Indicates k A label carried by an image of the photovoltaic cell surface; Indicates l An image of the surface of a photovoltaic cell carrying a label.
3. The photovoltaic cell defect detection method based on Transformer according to claim 1, characterized in that: The ViT teacher network has N+M Transformer blocks stacked in it; the CNN teacher network uses ResNet-50.
4. The photovoltaic cell defect detection method based on Transformer according to claim 3 is characterized in that: In any Transformer block, the normalized data is input into the multi-head self-attention layer in the Transformer block to obtain the attention output; the attention output is residually connected with the normalized data to obtain the feature representation with attention; the feature representation with attention is layer-normalized again and input into the feedforward network layer in the Transformer block to obtain the nonlinear feature; the nonlinear feature is residually connected with the feature representation with attention to obtain the feature output of the Transformer block.
5. The photovoltaic cell defect detection method based on Transformer according to claim 1, characterized in that: The classification linear layer is trained by the classification loss, which is calculated by the hard target and binary classification scores of the CNN teacher network, and the calculation formula is: ; in, represents the classification loss; represents the cross entropy loss; represents the binary classification score; represents the hard target of the CNN teacher network.
6. The photovoltaic cell defect detection method based on Transformer according to claim 5, characterized in that: The total loss function is calculated based on the total optimization target, classification loss and original classification loss, and the overall process of photovoltaic cell defect detection is trained through the total loss function; the total loss function expression is: ; ; in, represents the total loss function; represents the original classification loss; represents the third balance weight coefficient; represents the classification loss; represents the overall optimization objective; represents the cross entropy loss; A logical value representing any kind of student network; represents the softmax function; Represents the true value of the label.
Citation Information
Patent Citations
Knowledge distillation method and electronic device
CN117636457A
Lightweight defect detection method based on mixed multi-scale knowledge distillation
CN118154607A