Photovoltaic module defect detection method, system, medium, and apparatus based on small samples
By using a metric learning model based on a hybrid attention mechanism of features and examples, the problem of difficult data collection with small sample sizes in photovoltaic module defect detection is solved, and efficient defect classification and diagnosis is achieved with a small number of samples.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- CHINA THREE GORGES CORPORATION
- Filing Date
- 2024-07-12
- Publication Date
- 2026-05-22
AI Technical Summary
In the detection of defects in photovoltaic modules in open environments, it is difficult to collect sample data, which makes it difficult to accurately detect defects, especially with poor classification results when the sample size is small.
A metric learning model based on a hybrid attention mechanism of features and examples is adopted. The backbone network of the residual module is used to extract defect features from a small amount of sample data, and the inter-class distance of the embedding space is calculated through the attention mechanism of two dimensions of features and examples for classification and diagnosis.
It can maintain good classification results even with small sample sizes, reduce the impact of noise, and improve the accuracy and efficiency of defect detection.
Smart Images

Figure CN119006881B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of image recognition technology, and particularly relates to a method, system, storage medium and electronic device for detecting defects in photovoltaic modules based on small samples. Background Technology
[0002] Traditional photovoltaic (PV) mounting systems use fixed supports, offering advantages such as easy installation and high rigidity. However, these systems occupy significant ground space, consume large amounts of steel, and are economically inefficient. Furthermore, they are no longer suitable for various complex environments. Flexible PV systems, on the other hand, save land resources and have lower construction costs, leading to their widespread adoption. PV modules are secured using flexible solar panels. During operation, PV modules are exposed to the outdoor environment for extended periods, directly affected by various environmental factors such as wind, salt, snow, dust, and different aging mechanisms, which can cause mismatches. Visual inspection is a highly effective method for detecting module faults. Since visual inspection is performed using a drone inspection system equipped with a visible light camera, visible defects are those visible on the module's surface panel. Common defects on PV module surface panels include sealant delamination (ethyl vinyl acetate, EVA), dust shading, gridline corrosion, yellowing, and snail trails. Early detection of these faults enables early warning and monitoring, preventing the faults from worsening and avoiding unnecessary losses.
[0003] Currently, in open environments of real-world industrial applications, collecting sample data is often quite difficult. Furthermore, obtaining a sufficient volume of sample data is almost impossible in some situations, thus hindering accurate defect detection. To address these shortcomings, this invention provides an improvement. Summary of the Invention
[0004] To address the aforementioned issues, this invention provides a method, system, storage medium, and electronic device for detecting defects in photovoltaic modules based on small samples. It employs a metric learning model based on a hybrid attention mechanism of features and examples, which maintains a relatively good classification performance even when the number of samples is drastically reduced.
[0005] The technical solution adopted in this invention is: a photovoltaic module defect detection method based on small samples, comprising:
[0006] A preset metric learning model is used to construct a support set and a query set using defect data of photovoltaic modules. The metric learning model extracts defect features from a small amount of sample data in the support set and query set based on the backbone network of the residual module and maps them to the embedding space.
[0007] The metric learning model calculates the inter-class distance in the embedding space based on an attention mechanism that considers both features and examples, and then classifies and diagnoses defects in photovoltaic modules.
[0008] Furthermore,
[0009] The metric learning model includes a meta-training phase and a meta-testing phase;
[0010] The specific steps of the meta-training phase are as follows:
[0011] Step 1. From the task dataset Mid-sampling task and support sets and query set ,
[0012] Step 2. Given the training set Calculate specific tasks parameters : ),
[0013] Step 3. Use task-specific parameters and query set gradient of the loss function Update the meta-parameter θ.
[0014] Step 4. Repeat Step 2 to Step 3 using the gradient descent optimizer;
[0015] In the meta-testing phase, the new data category is the query set, and the trained model is used to predict the class distribution of the query set.
[0016] Furthermore,
[0017] The test data is compared with the training data using a similarity metric. The label of the training data that is most similar to the test data can be assigned to the test data.
[0018] The specific steps are as follows:
[0019] Step 1. From the task dataset Mid-sampling task and support sets and query set ,
[0020] Step 2. Predict the test label based on the similarity between the training data and the test data. : ,
[0021] in The types of defect sample data. This indicates the type of defect. , Indicates the first Class defect data contains A set of image samples ,
[0022] Step 3. Use the gradient of the loss function between the test data and the prediction data with respect to the prediction accuracy. Update the learning parameter θ.
[0023] Step 4. Repeat Step 2 through Step 3 using the gradient descent optimizer.
[0024] Furthermore,
[0025] The metric learning model uses a few-sample feature extraction backbone network for feature extraction, and the feature extraction is represented using the following notation:
[0026]
[0027] in These are the parameters that the feature extraction network needs to learn. The extracted feature information;
[0028] The relationships between classes are represented by feature centers obtained through a prototype network. These feature centers are called prototypes. The method for calculating prototypes is to average the embedding features of all instances in the support set for each relationship.
[0029]
[0030] in For the first The prototype of this defect In supporting the central Samples of defects It is its tag, in the support set The Middle Such defects include One sample,
[0031] Prototype network based on query samples The distances to other prototypes are normalized using softmax, resulting in a probability distribution for each category:
[0032]
[0033] in To predict query samples The tag, .
[0034] Furthermore,
[0035] The attention mechanism based on both features and examples includes an example-level attention mechanism and a feature-level attention mechanism. The example-level attention mechanism focuses more attention on the more similar parts of the support set, and includes:
[0036] Given a query sample Each type of sample contains weighted information. , The softmax function generates a probability distribution in the range [0, 1].
[0037]
[0038] in This is the activation function. Indicates to Perform a linear transformation. This represents a linear transformation of x followed by a dot product operation. , This represents summing over all elements of a vector, and so on. The calculation of the feature center is replaced by the following formula:
[0039]
[0040] Furthermore,
[0041] The feature-level attention mechanism focuses more on distance information between features, and includes:
[0042] Multiply the original Euclidean distance by a coefficient. This leads to a new distance metric that focuses more on distinctive features when calculating spatial distance.
[0043]
[0044] in It is a score vector related to the defect type, calculated by a feature-level attention extractor, and its structure consists of a 16-dimensional convolutional layer and a fully connected layer.
[0045] Furthermore,
[0046] When acquiring defect data of photovoltaic modules, data augmentation algorithms are used to perform data augmentation, including affine transformation, rotation transformation and Gaussian noise.
[0047] The present invention also provides a photovoltaic module defect detection system based on a small sample size, for implementing the aforementioned photovoltaic module defect detection method based on a small sample size, the system comprising:
[0048] The defect feature extraction module is used to extract defect features from a small amount of sample data in the support set and query set using a backbone network based on residual modules, and map them to the embedding space.
[0049] The inter-class distance calculation module is used to calculate the inter-class distance of the embedding space using an attention mechanism based on two dimensions: features and examples, to classify and diagnose defects in photovoltaic modules.
[0050] The present invention also provides a computer-readable storage medium storing one or more programs.
[0051] When one or more of these programs are executed, the aforementioned method for detecting defects in photovoltaic modules based on small samples can be implemented.
[0052] The present invention also provides an electronic device, including a processor, a communication interface, a computer-readable storage medium, and a communication bus; wherein the processor, the communication interface, and the computer-readable storage medium communicate with each other through the communication bus;
[0053] The processor is used to execute programs stored in a computer-readable storage medium.
[0054] Compared with the prior art, the present invention has the following advantages:
[0055] 1. The metric learning model based on the backbone network of residual modules can effectively extract defect features from a small amount of sample data in the support set and query set and map them to the embedding space.
[0056] 2. The attention mechanism based on two dimensions, features and examples, includes two modules: an example-level attention mechanism and a feature-level attention mechanism. The example-level attention mechanism focuses more on the more similar parts of the support set, which can appropriately reduce the impact of noise. The feature-level attention mechanism focuses more on the distance information between features. In this way, it can distinguish the degree of correlation of feature information from two dimensions, features and examples, calculate its class distance, exclude similar background feature information, and increase the distance between defective feature information.
[0057] 3. Compared with the diagnostic results of large samples, the classification effect of this invention is still at a good level when the number of samples is drastically reduced.
[0058] Other features and advantages of the invention will be set forth in the description which follows, and will be apparent in part from the description, or may be learned by practicing the invention. The objects and other advantages of the invention may be realized and obtained by means of the structures pointed out in the description, claims and drawings. Attached Figure Description
[0059] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0060] Figure 1 This is a flowchart illustrating an embodiment of the present invention;
[0061] Figure 2 This is a schematic diagram of the metric learning model structure based on a feature-sample hybrid attention mechanism according to an embodiment of the present invention;
[0062] Figure 3 This is a schematic diagram of the residual module according to an embodiment of the present invention;
[0063] Figure 4 This is a schematic diagram of a small sample feature extraction backbone network according to an embodiment of the present invention;
[0064] Figure 5 This is a schematic diagram of a residual feature extractor according to an embodiment of the present invention;
[0065] Figure 6 This is a schematic diagram of a confusion matrix according to an embodiment of the present invention;
[0066] Figure 7 This is a schematic diagram of t-SNE analysis of features learned by a metric learning model based on a hybrid attention mechanism according to an embodiment of the present invention.
[0067] Figure 8 This is a visual schematic diagram of class activation mapping in a small sample case according to an embodiment of the present invention;
[0068] Figure 9 This is a schematic diagram of the structure of an electronic device according to an embodiment of the present invention. Detailed Implementation
[0069] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0070] See Figure 1 One embodiment of the present invention proposes a method for detecting defects in photovoltaic modules based on small samples, comprising:
[0071] Step S1: Based on the backbone network of the residual module, extract defect features from a small number of sample data in the support set and query set of the defect data of photovoltaic modules, and map them to the embedding space;
[0072] In this step, a metric learning model is preset, and a support set and a query set are constructed using defect data of photovoltaic modules. The metric learning model extracts defect features from a small amount of sample data in the support set and query set based on the backbone network of the residual module, and maps them to the embedding space.
[0073] Step S2: Based on the attention mechanism of two dimensions, features and examples, calculate the inter-class distance of the embedding space to classify and diagnose defects in photovoltaic modules.
[0074] In this step, the metric learning model calculates the inter-class distance of the embedding space based on an attention mechanism that considers both features and examples, and then classifies and diagnoses defects in the photovoltaic module.
[0075] This invention investigates a defect diagnosis method for photovoltaic modules under small sample conditions and proposes a metric learning model based on a feature-sample hybrid attention mechanism. First, a backbone network based on residual modules extracts defect features from a small number of samples in the support and query sets and maps them to the embedding space. Then, an attention mechanism based on both features and samples is used to calculate the inter-class distance in the embedding space and classify and diagnose the faults, thus addressing the challenges of data acquisition and labeling in photovoltaic power plant environments. Compared to diagnostic results with large samples, this invention maintains a good classification performance even with a drastically reduced sample size, achieving optimal recognition results with minimal labeling cost even in situations of severe sample scarcity.
[0076] By recognizing a new object with a very small number of samples—for example, an object that has only been seen once or a few times in a picture or in person—the model can recognize the object and quickly store it in its knowledge structure. After learning data from a certain category, the model can quickly learn new categories with only a small number of samples.
[0077] 1. Small sample learning
[0078] Few-shot learning is a process where a computer learns the same model on different tasks based on a small dataset. It includes two phases: meta-training and meta-testing. In the meta-training phase, the dataset is... Decompose into different meta tasks. and from the dataset Randomly select N classes (N-way) and sample data from these classes that meet the task requirements. Support set and query sets For different tasks ,by To train the samples, learn a classification model that is accurate in all cases. The N-class prediction loss function is lowest for the samples in this model. Each training episode uses a sampling meta-task to learn the model's generalization ability under class variations. In other words, the training process includes different class combinations. This training mechanism allows the model to learn the commonalities across different tasks, such as feature extraction methods or sample similarity measurement methods, while forgetting task-specific parts of the meta-task, such as specific class feature information. Through this learning mechanism, the model can perform well in classifying new, unseen meta-tasks.
[0079] The specific steps of the meta-training phase are as follows:
[0080] Step 1. From the task dataset Mid-sampling task and support sets and query set .
[0081] Step 2. Given the training set Calculate specific tasks parameters : ).
[0082] Step 3. Use task-specific parameters and query set gradient of the loss function Update the meta-parameter θ.
[0083] Step 4. Repeat Step 2 through Step 3 using the gradient descent optimizer.
[0084] In the meta-testing phase, the new data category is the query set, and the trained model is used to predict the class distribution of the query set.
[0085] Few-shot learning is an application of meta-learning in the field of supervised learning, and its definition follows some established rules of meta-learning. It is used for samples with only a small number of labels. , , For the types of sample data, Indicates the first In class data A set of samples Samples to be classified Its sample category Learn the conditional probability distribution under different category labels based on the original data. The goal is to obtain a method that can accurately predict the samples to be classified. The model of the category.
[0086] Based on measurement methods
[0087] Nonparametric methods are highly effective for learning from small amounts of data (k-nearest neighbors, decision trees, support vector machines). In nonparametric learning, a similarity metric is used to compare the test data with the training data, and the label of the training data most similar to the test data is assigned to the test data. The specific calculation process basically follows these principles:
[0088] Step 1. From the task dataset Mid-sampling task and support sets and query set .
[0089] Step 2. Predict the test label based on the similarity between the training data and the test data. :
[0090] Step 3. Use the gradient of the loss function between the test data and the prediction data with respect to the prediction accuracy. Update the learning parameter θ.
[0091] Step 4. Repeat Step 2 through Step 3 using the gradient descent optimizer.
[0092] 2. Problem Definition and Model Architecture
[0093] To address the problem of small sample data, this invention proposes a metric learning model based on a hybrid attention mechanism. First, a backbone network based on residual modules is used to learn the embedding space vectors of a small number of samples. Then, a hybrid attention mechanism at the feature and sample levels is used to learn the inter-class distance, thereby determining the label type of an unknown sample.
[0094] 2.1 Problem Definition
[0095] Given a small sample dataset containing defect category information ,in The types of defect sample data. This indicates the type of defect. , Indicates the first Class defect data contains A set of image samples .
[0096] Samples to be classified Learn the conditional probability distributions for different categories based on the original data. Determine the sample category. The goal is to obtain a value that can accurately predict the classification of the sample. The model of the category.
[0097] 2.2 Model Architecture
[0098] Figure 2 This invention presents a feature-example hybrid attention-based metric learning model. Within the framework of a prototype network, the invention models the metric method and employs a hybrid attention mechanism to score relationships. First, a backbone network based on residual modules is used for feature extraction, obtaining its embedding space. Then, based on feature information of different categories, the correlation degree of feature information is distinguished from two dimensions: features and examples. The inter-class distance is calculated, similar background features are excluded, and the distance between defective features is increased. Finally, a relation module is used to measure the relationship between the query set and the category, thereby completing the classification.
[0099] Residual module-based backbone network
[0100] First, defect features will be extracted from the defect images. Since the feature information is relatively limited in the case of small samples, it is necessary to preserve the original information as much as possible. This invention adopts the feature extraction method of some modules in ResNet, but other deep models can also be used.
[0101] Neural networks are input The output after two convolutional layers is Residual networks are... Add network input ,Right now This process involves shortcut connections; therefore, only learning is required during this process. The residual module structure is as follows: Figure 3 As shown.
[0102] ResNet is a network composed of multiple residual modules and multiple paths. This invention uses a few-shot feature extraction backbone network module for feature extraction. The few-shot feature extraction backbone network is as follows: Figure 4 As shown, for ease of description, it is called a residual feature extractor.
[0103] For the sake of simplicity in the subsequent algorithm description, the feature extraction step will be represented using the following notation:
[0104]
[0105] in These are the parameters that the feature extraction network needs to learn. The extracted feature information.
[0106] Prototype Network
[0107] The purpose of prototype networks is to obtain feature centers (i.e., prototypes) to represent relationships between classes. An efficient method for computing prototypes is to average the embedding features of all instances in the support set for each relationship.
[0108]
[0109] in For the first The prototype of this defect In supporting the central Samples of defects It is its tag. In the support set The Middle Such defects include One sample.
[0110] In the original prototype network, the feature information of all samples was averaged.
[0111] In the prototype network based on a hybrid attention mechanism of this invention, the simple averaging mechanism is replaced by an attention mechanism, thereby further highlighting the types of samples that are more relevant to the support set. This will be described in detail in the next step.
[0112] The prototype network will be based on query samples The distances to other prototypes are normalized using softmax, resulting in a probability distribution for each category:
[0113]
[0114] in To predict query samples The tag, .
[0115] Euclidean distance is superior to other distance calculation methods, so the attention mechanism at the feature level will continue to use the Euclidean distance metric.
[0116] Hybrid attention mechanism
[0117] The hybrid attention mechanism consists of two modules: instance-level attention and feature-level attention. Instance-level attention focuses more on the more similar parts of the support set, while feature-level attention focuses more on the distance information between features.
[0118] Sample-level attention mechanism
[0119] Because in small sample sizes, feature representations of samples that are far removed from other samples can produce significant deviations, especially since the sample data in this experiment contained considerable noise and distortion during collection, a sample-level attention mechanism is proposed to enhance the prototype network's control over category information and appropriately mitigate the impact of noise. Given a query sample... Each type of sample contains weighted information. , The softmax function generates a probability distribution in the range [0, 1].
[0120]
[0121] in This is the activation function. Indicates to Perform a linear transformation. This represents a linear transformation of x followed by a dot product operation. , This represents the summation of all elements in a vector, and so on. The class center is replaced by the following formula:
[0122]
[0123] After using the sample-level attention mechanism, support set samples that have more similar features to the query sample will receive higher weights, and the resulting prototype will be closer to the prototype of the support set.
[0124] Feature-level attention mechanism
[0125] At the feature level, the Euclidean distance used in the original prototype network will be adopted. However, due to the sparse nature of features extracted from the support set under small sample conditions, the features need to be more distinct when classifying relationships between features in the feature space. Therefore, this invention proposes a feature-level attention mechanism that multiplies the original Euclidean distance by a coefficient. This leads to a new distance metric that focuses more on distinctive features when calculating spatial distance.
[0126]
[0127] in It is a score vector related to the defect type, calculated by a feature-level attention extractor, and its structure consists of a 16-dimensional convolutional layer and a fully connected layer.
[0128] The feature extractor separates high-dimensional defect features. The more useful the specific feature information is to the defect features, the higher the corresponding score will be. By multiplying the feature attention score by the squared difference of distance, it can better adapt the feature selection between the given relation and the support set examples.
[0129] The following section presents experimental verification and analysis of the model performance of this invention.
[0130] 1. Dataset and Experiment Setup
[0131] The defect sample types of this invention include six categories of defect types and image data of normal photovoltaic modules. Each category contains 110 samples. Affine transformation, rotation transformation, and Gaussian noise are used for data augmentation during data input; that is, data augmentation algorithms are employed when acquiring defect data from photovoltaic modules. In the backbone network, a series-parallel structure of residual modules is used for defect feature extraction. Specifically, the input image data is scaled to 224. 224 3. First, pass through a group of 16 sevens. 7 The convolutional layer has a 3x3 kernel, followed by two residual modules. Each residual module consists of two convolutional layers connected by a shortcut. The parameter settings within the same residual module are consistent. The two residual modules contain 16 and 32 convolutional layers respectively. 7 Convolutional layers with 3 convolutional kernels, such as Figure 5 As shown, after feature extraction, a global average pooling layer is used to obtain a 512-dimensional feature vector. Then, a dual attention mechanism network is used to calculate the prototypes of each class, and finally, prototype classification is performed.
[0132] All models used in the following experiments were trained using Adam's SGD with an initial learning rate of 0.001, which was halved every 100 epochs. Normalization was applied to each batch of samples. TensorFlow was used as the programming environment, and a high-performance computing platform (4 NVIDIA TITAN GPUs) was used for convolution operations to accelerate training.
[0133] Algorithm recognition effect
[0134] During the model training phase, the network was trained for a total of 2000 epochs, taking approximately 4 hours. When the loss function stopped decreasing, the model training was complete. The model with the lowest accuracy loss was selected as the candidate model. The candidate model achieved a defect detection accuracy of at least 92.6% on the random test dataset. This demonstrates that, with a limited number of iterations, a well-trained model can achieve relatively high accuracy even with small sample sizes.
[0135] After training, a new set of images was used for another test to verify the performance of the algorithm. The overall average accuracy for classifying defects in photovoltaic modules was 87.6%. Figure 6 It is a confusion matrix for defect detection of photovoltaic modules using the metric model based on the hybrid attention mechanism proposed in this invention. Each column represents the diagnosed defect type, and each row represents the actual defect type.
[0136] The confusion matrix shows that the lowest percentage of true positive classifications is for type #2 (glass breakage). This method performs well in classifying EVA detachment and normal components, with true positive percentages reaching 91% and 96%, respectively. Due to the extremely small sample size, snail trails and grid line corrosion are largely confused. Furthermore, because dust obstruction is similar to glass breakage, and dust obstruction is similar to yellowing, some data for these defect types are confused.
[0137] To verify the ability of the proposed deep learning model to automatically extract defect features of photovoltaic modules, t-SNE was also used for visualization. Figure 7 The features extracted from 7 different photovoltaic module states (including 6 types of module defects and normal states) show that this model can distinguish the various module states relatively well. Of course, there will also be a lot of confusion, but compared to the order of magnitude, the classification effect is already pleasing.
[0138] Finally, we observed the differences in feature learning and selection among the models. Using CAM, we took the feature map of the top convolutional layer and the defects of the photovoltaic module as input to generate a feature map. Then, we overlaid the heatmap onto the original image to obtain the parts that play a crucial role in image classification. For example... Figure 8 As shown in the second row, the brighter the color, the greater the proportion of that type of feature. Compared to feature extraction from large samples in Chapter 5, feature extraction for defects is relatively more refined in the case of small samples.
[0139] 3. Impact of backbone network on algorithm performance
[0140] This section analyzes the impact of different backbone networks extracting defect features on the overall model performance under small sample conditions. Different backbone architectures, network depths, numbers of convolutional kernels, and data augmentation techniques are compared, and the results are shown in Table 1.
[0141] (1) Impact of the backbone structure
[0142] This section compares the model architecture of the original prototype network with that of ResNet. First, we use the convolutional module-based network used in the original prototype network, which contains four convolutional modules, each consisting of a convolutional layer, a BatchNorm layer, a ReLU layer, and a max pooling layer. The same ResNet model uses the same number of layers (32-32-32-32). We observe that the ResNet architecture achieves higher classification accuracy than the convolutional module-based architecture.
[0143] (2) The impact of network depth
[0144] Then, different skeleton layer structures were adjusted, and the effects of different layer structures and network depths on them were analyzed. The results are shown in the table below. For the network architecture based on convolutional modules, the convolutional module network was compared with 2, 3, and 4 layers, as well as different layers with 16 or 32 convolutional kernels. The best classification effect was found to be the 64-kernel network composed of 4 convolutional modules, with the best accuracy of 0.876.
[0145] Table 1. Impact of backbone network on algorithm performance
[0146]
[0147] (3) The effect of the number of convolution kernels
[0148] An analysis of the number of convolutional kernels in the network structure was conducted, comparing networks with 16 and 32 convolutional kernels respectively. It was clearly observed that the network with 32 convolutional kernels performed better in classification than the network with 16 convolutional kernels.
[0149] (4) The impact of data augmentation
[0150] The study also compared the effects of data augmentation with and without, and it was clear that the network model using data augmentation techniques performed better than the one without.
[0151] This invention investigates a component defect diagnosis method under small sample conditions and proposes a metric learning model based on a feature-sample hybrid attention mechanism. Building upon the prototype network architecture, firstly, a backbone network based on residual modules extracts defect features from a small number of samples in the support and query sets and maps them to the embedding space. Then, an attention mechanism based on both feature and sample dimensions calculates the inter-class distance in the embedding space and performs fault classification and diagnosis to address the challenges of data acquisition and labeling in photovoltaic power plant environments. Compared to the diagnostic results of large samples in previous chapters, the classification performance remains at a relatively good level even with a drastically reduced sample size.
[0152] Reference Figure 2As shown, based on the same inventive concept, one embodiment of the present invention proposes an online defect detection system for photovoltaic modules, used to implement the aforementioned small-sample-based photovoltaic module defect detection method. The system includes:
[0153] The defect feature extraction module is used to extract defect features from a small amount of sample data in the support set and query set using a backbone network based on residual modules, and map them to the embedding space.
[0154] The inter-class distance calculation module is used to calculate the inter-class distance of the embedding space using an attention mechanism based on two dimensions: features and examples, to classify and diagnose defects in photovoltaic modules.
[0155] Based on the same inventive concept, the present invention also provides a computer-readable storage medium storing one or more programs, which, when executed, can realize the aforementioned method for detecting defects in photovoltaic modules based on small samples.
[0156] like Figure 9 As shown in the figure, this embodiment of the invention also provides an electronic device, including a processor, a communication interface, a memory, and a communication bus. The processor, communication interface, and memory communicate with each other via the communication bus.
[0157] The memory is a computer-readable storage medium used to store one or more programs.
[0158] The processor is configured to execute a program stored in a computer-readable storage medium.
[0159] The computer-readable storage medium may be included in the device / apparatus described in the above embodiments; or it may exist independently and not assembled into the device / apparatus.
[0160] Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for detecting defects in photovoltaic modules based on small samples, characterized in that, include: A preset metric learning model is used to construct a support set and a query set using defect data from photovoltaic modules. The metric learning model extracts defect features from a small amount of sample data in the support set and query set based on the backbone network of the residual module, and maps them to the embedding space; wherein, the defect data is an image. The metric learning model calculates the inter-class distance of the embedding space based on an attention mechanism that considers both features and examples, and then classifies and diagnoses defects in photovoltaic modules. The metric learning model uses a few-sample feature extraction backbone network for feature extraction, and the feature extraction is represented using the following notation: in These are the parameters that the feature extraction network needs to learn. The extracted feature information; The relationships between classes are represented by feature centers obtained through a prototype network. These feature centers are called prototypes. The method for calculating prototypes is to average the embedding features of all instances in the support set for each relationship. in For the first The prototype of this defect In supporting the central Samples of defects It is its tag, in the support set The Middle Such defects include One sample, Prototype network based on query samples The distances to other prototypes are normalized using softmax, resulting in a probability distribution for each category: in To predict query samples The tag, ; The attention mechanism based on both features and examples includes an example-level attention mechanism and a feature-level attention mechanism. The example-level attention mechanism focuses more attention on the more similar parts of the support set, and includes: Given a query sample Each type of sample contains weighted information. , The softmax function generates a probability distribution in the range [0, 1]. in This is the activation function. Indicates to Perform a linear transformation. This represents a linear transformation of x followed by a dot product operation. , This represents summing over all elements of a vector, and so on. The calculation of the feature center is replaced by the following formula: The feature-level attention mechanism focuses more on distance information between features, and includes: Multiply the original Euclidean distance by a coefficient. This leads to a new distance metric that focuses more on distinctive features when calculating spatial distance. in It is a score vector related to the defect type, calculated by a feature-level attention extractor, and its structure consists of a 16-dimensional convolutional layer and a fully connected layer.
2. The photovoltaic module defect detection method based on small samples according to claim 1, characterized in that, The metric learning model includes a meta-training phase and a meta-testing phase; The specific steps of the meta-training phase are as follows: Step 1. From the task dataset Mid-sampling task and support sets and query set , Step 2. Given the training set Calculate specific tasks parameters : ), Step 3. Use task-specific parameters and query set gradient of the loss function Update the meta-parameter θ. Step 4. Repeat Step 2 to Step 3 using the gradient descent optimizer; In the meta-testing phase, the new data category is the query set, and the trained model is used to predict the class distribution of the query set.
3. The photovoltaic module defect detection method based on small samples according to claim 2, characterized in that, The test data is compared with the training data using a similarity metric. The label of the training data that is most similar to the test data can be assigned to the test data. The specific steps are as follows: Step 1. From the task dataset Mid-sampling task and support sets and query set , Step 2. Predict the test label based on the similarity between the training data and the test data. : , in The types of defect sample data. This indicates the type of defect. , Indicates the first Class defect data contains A set of image samples , Step 3. Use the gradient of the loss function between the test data and the prediction data with respect to the prediction accuracy. Update the learning parameter θ. Step 4. Repeat Step 2 through Step 3 using the gradient descent optimizer.
4. The photovoltaic module defect detection method based on small samples according to any one of claims 1 to 3, characterized in that, When acquiring defect data of photovoltaic modules, data augmentation algorithms are used to perform data augmentation, including affine transformation, rotation transformation and Gaussian noise.
5. A photovoltaic module defect detection system based on small samples, used to implement the method according to any one of claims 1 to 4, characterized in that, The system includes: The defect feature extraction module is used to extract defect features from a small amount of sample data in the support set and query set using a backbone network based on residual modules, and map them to the embedding space. The inter-class distance calculation module is used to calculate the inter-class distance of the embedding space using an attention mechanism based on two dimensions: features and examples, to classify and diagnose defects in photovoltaic modules.
6. A computer-readable storage medium storing one or more programs, characterized in that, When one or more of these programs are executed, the photovoltaic module defect detection method based on small samples as described in any one of claims 1-4 can be implemented.
7. An electronic device, comprising a processor, a communication interface, a computer-readable storage medium as described in claim 6, and a communication bus; wherein, The processor, communication interface, and computer-readable storage medium communicate with each other via a communication bus; Its features are, The processor is used to execute programs stored in a computer-readable storage medium.