A lightweight photovoltaic cell defect detection method based on a cooperative attention mechanism

By introducing LPConv Block, Histogram attention, and Slim-neck network into the RT-DETR model, the problem of high model complexity in photovoltaic cell defect detection is solved, achieving efficient and lightweight defect detection suitable for embedded devices.

CN122115406APending Publication Date: 2026-05-29ANHUI UNIVERSITY OF TECHNOLOGY

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
ANHUI UNIVERSITY OF TECHNOLOGY
Filing Date
2026-03-13
Publication Date
2026-05-29

AI Technical Summary

Technical Problem

Existing deep learning models for detecting surface defects in photovoltaic cells suffer from problems such as large parameter scale, high computational complexity, and difficulty in real-time deployment on embedded and edge devices, especially in balancing the ability to perceive subtle defects with lightweight models.

Method used

We replace BasicBlock with LPConv Block, introduce the AIFI-HA module with Histogram attention mechanism, and construct a Slim-neck network including GSConv and VoVGSCSP modules to optimize feature extraction and fusion, reduce computational complexity, and improve multi-scale feature representation capabilities.

Benefits of technology

It achieves a significant reduction in model complexity while maintaining high detection accuracy, thus improving detection efficiency and making it suitable for real-time photovoltaic cell defect detection in resource-constrained environments.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122115406A_ABST
    Figure CN122115406A_ABST
Patent Text Reader

Abstract

The application discloses a photovoltaic cell defect lightweight detection method based on a cooperative attention mechanism and belongs to the technical field of photovoltaic cell surface defect detection, and comprises the following steps: data preprocessing, model construction, model training and defect detection. The application proposes a new LPConv Block, effectively fuses PConv and a residual structure, significantly improves the calculation efficiency while keeping the lightweight characteristics of the model, and enhances the expression ability of multi-scale features; an AIFI-HA module is constructed, a Histogram attention mechanism is introduced into an adaptive information fusion integration (AIFI) module, efficient fusion of local and global information is realized, the feature interaction process is further optimized, and thus the reasoning speed of the model is significantly improved; and a novel Slim-neck neck network is proposed. Through construction of lightweight GSConv and VoVGSCSP, the calculation amount and parameter amount of the model are reduced, and efficient fusion of multi-scale defect features is realized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of photovoltaic cell surface defect detection technology, specifically to a lightweight photovoltaic cell defect detection method based on a collaborative attention mechanism. Background Technology

[0002] Against the backdrop of the global low-carbon energy transition, photovoltaic (PV) power generation has become an important component of the renewable energy system. However, during the manufacturing, transportation, installation, and long-term service of PV modules, structural defects such as microcracks and hot spots are prone to occur on the surface of the cells. These defects are typically small in scale, irregular in shape, and easily affected by complex background interference. If they cannot be identified in a timely and accurate manner, they will lead to a decrease in power generation efficiency and accelerate module aging, seriously affecting the safe and stable operation of the PV system. Therefore, developing a high-precision and high-efficiency method for detecting surface defects in PV cells has significant engineering application value.

[0003] Early photovoltaic cell defect detection primarily relied on manual visual inspection, infrared thermal imaging (IRT), electroluminescence (EL) detection, and traditional computer vision methods. While these methods can identify defects under certain conditions, they generally suffer from problems such as dependence on human experience, sensitivity to the inspection environment, or difficulty in online detection. Especially in complex industrial scenarios with strong noise interference, diverse defect types, and significant scale differences, traditional methods based on human features struggle to reliably characterize subtle defect features, significantly limiting their robustness and generalization ability.

[0004] With the development of deep learning technology, object detection methods based on deep neural networks have gradually become the mainstream research direction for surface defect detection of photovoltaic cells. One-stage and two-stage object detection models (such as Faster R-CNN and YOLO) have shown significant advantages in complex backgrounds and multi-scale defect scenarios through end-to-end feature learning. However, due to limitations in network structure depth and multi-scale feature extraction mechanisms, existing deep learning models generally suffer from large parameter scale and high computational complexity, making it difficult to achieve real-time deployment on resource-constrained platforms such as embedded and edge devices. In practical engineering applications, achieving an effective balance between the ability to perceive subtle defects and model lightweighting remains a key challenge that urgently needs to be addressed.

[0005] To break through the traditional detection paradigm based on candidate boxes and non-maximum suppression (NMS), researchers proposed the Transformer-based end-to-end object detection framework DETR. By modeling object detection as an ensemble prediction problem, it achieves a unified detection process without NMS, demonstrating significant advantages in global feature modeling. Subsequently, Real-Time DETR (RT-DETR) alleviated the slow convergence speed and low inference efficiency of DETR to some extent through structural and training strategy optimization, and has been gradually introduced into real-time scenarios such as photovoltaic defect detection. However, due to the characteristics of photovoltaic cell surface defects—such as extremely small target size, complex morphological changes, and significant background interference—existing methods still struggle to balance fine-grained feature modeling and computational efficiency, and false positives and false negatives still exist in engineering applications.

[0006] To address these challenges, scholars have conducted extensive research on small-scale defect perception, multi-scale feature fusion, and lightweight models. For example, some researchers have proposed cross-space-frequency hybrid (CSFH) feature extraction networks to enhance the feature representation capabilities of small targets. Others have improved local detail and global modeling capabilities by using synergistic multi-attention Transformer blocks (SMAFB) and convolutionally gated linear units (CGLU). Still others have introduced cross-stage partial networks (CSP) and residual attention blocks (RAB) into the YOLOv8 backbone network, achieving a balance between accuracy and lightweight design. Furthermore, some studies have further improved detection performance in complex scenes by introducing Vision Transformer (ViT), fused feature modules, and multi-scale feature pyramid structures. However, these methods often involve increased model complexity and computational overhead, limiting their practical application in real-time and resource-constrained scenarios.

[0007] Therefore, this invention proposes a lightweight method for detecting defects in photovoltaic cells based on a collaborative attention mechanism. Summary of the Invention

[0008] The technical problem to be solved by this invention is: how to achieve lightweight detection of surface defects in photovoltaic cells, and provides a lightweight detection method for photovoltaic cell defects based on a collaborative attention mechanism.

[0009] like Figure 14 As shown, the present invention solves the above-mentioned technical problems through the following technical solution, and the present invention includes the following steps:

[0010] S1: Data Preprocessing

[0011] Acquire images of photovoltaic cell defects and perform preprocessing;

[0012] S2: Model Building

[0013] A CA-DETR detection model based on RT-DETR-r18 was constructed. The CA-DETR detection model includes a feature extraction module based on LPConv Block, an AIFI-HA module, a Slim-neck, and the detection head of the benchmark model.

[0014] S3: Model Training

[0015] The training set images are input into the CA-DETR detection model for model training. The model performance is evaluated through the validation set, and the optimal model is selected as the photovoltaic cell defect detection model.

[0016] S4: Defect Detection

[0017] The test set images are input into the photovoltaic cell defect detection model, which outputs the category and location detection results of photovoltaic cell defects, thus achieving lightweight detection of photovoltaic cell defects.

[0018] Furthermore, in step S1, all photovoltaic cell defect images are uniformly adjusted to a size of 640×640 and divided into training set, validation set and test set according to a set ratio.

[0019] Furthermore, in step S2, the feature extraction module based on LPConv Block is obtained by replacing BasicBlock in the baseline model with LPConvBlock.

[0020] Furthermore, the LPConv Block integrates a partially convolutional PConv structure with a residual block structure, selecting only the input features. Figure 1 One-quarter of the continuous channels undergo a 3×3 PConv convolution operation, while the remaining three-quarters channels maintain an identity mapping. After the PConv convolution, a 1×1 PWConv convolution is used to complete feature channel fusion and linear reconstruction. When the number of input and output channels is the same, the computational cost of the PConv convolution is... ,in, and It is the size of the feature map. Indicates the size of the convolution kernel. This is the number of channels used in standard convolution; when At that time, PConv's computational cost was only 1 / 16 of that of ordinary convolution; PConv's memory access cost was... .

[0021] Furthermore, in step S2, the AIFI-HA module replaces the standard multi-head self-attention mechanism in the baseline model. By introducing Histogram attention, it more efficiently models long-distance dependencies between features, enhances feature representation by utilizing histogram statistical properties, and improves detection accuracy.

[0022] Furthermore, in step S2, the specific processing procedure of the AIFI-HA module is as follows:

[0023] S211: Divide the input feature map evenly into two parts along the channel dimension, denoted as... and , Used to preserve original feature information, Used to perform Histogram Attention operations;

[0024] S212: Feature map for which Histogram Attention operation is performed Sort along two orthogonal directions, horizontally and vertically, and construct a feature histogram representation;

[0025] S213: Compare the sorted features with the original features The concatenation process involves sequentially performing 1×1 convolutions to facilitate channel information exchange and 3×3 depthwise separable convolutions to extract spatial features.

[0026] S214: Divide the output features of depthwise separable convolutions into feature values ​​V and two sets of query-key pairs. , The eigenvalues ​​V are sorted according to their intensity values, and the corresponding location indices are recorded. ; by location index For two sets of query-key features , Perform the corresponding rearrangement operation to maintain the consistency between features;

[0027] S215: Calculate the corresponding attention weights using a two-path strategy of binned histogram attention (BHR) and full-range histogram attention (FHR). and ;

[0028] S216: Will and Feature fusion is achieved through element-wise multiplication, followed by channel-dimensional projection via 1×1 convolution to map back to the original feature map spatial location, and the fused feature map is output.

[0029] Furthermore, in step S214, the sorting process is described as follows:

[0030] ;

[0031] in, Indicates a sorting operation. Indicates the sorted position index;

[0032] The rearrangement process is as follows:

[0033] ;

[0034] in, This represents the output query vector sequence and key vector sequence. It is the output feature tensor.

[0035] Furthermore, in step S215, attention weights and The calculation formula is as follows:

[0036] ;

[0037] ;

[0038] in, and These are two different linear mapping functions. It is a scaling factor. It is a key vector The dimension; It is a matrix transpose operation.

[0039] Furthermore, in step S2, the Slim-neck includes a VoVGSCSP module, which integrates the single-pass aggregation strategy of GS Bottleneck and cross-stage partial network CSP to improve the model's ability to model and fuse multi-scale defect features. The GS Bottleneck module is obtained by replacing the standard convolution in the Bottleneck module with the GSConv module.

[0040] Furthermore, the calculation formula for the GSConv module is as follows:

[0041]

[0042] in, As input features, Indicates channel splicing. This refers to channel rearrangement operations. Yes Perform depth-separable operations;

[0043] The calculation formula for the VoVGSCSP module is as follows:

[0044]

[0045] in, express number, Used for channel fusion and dimension restoration It means indivual Module stacking.

[0046] The present invention has the following advantages over the prior art:

[0047] 1. A novel LPConv Block is proposed. This module effectively integrates PConv with the residual structure, which significantly improves computational efficiency and enhances the ability to express multi-scale features while maintaining the lightweight nature of the model.

[0048] 2. An AIFI-HA module was constructed. The Histogram attention mechanism was introduced into the adaptive information fusion integration (AIFI) module. By achieving efficient fusion of local and global information, the feature interaction process was further optimized, thereby significantly improving the inference speed of the model.

[0049] 3. A novel Slim-neck network is proposed. By constructing lightweight GSConv and VoVGSCSP, the computational cost and parameter count of the model are reduced while achieving efficient fusion of multi-scale defect features.

[0050] 4. The proposed method was validated on a photovoltaic cell defect detection dataset. Experimental results show that the proposed method outperforms other state-of-the-art (SOTA) methods. Furthermore, generalization experiments were conducted on two other photovoltaic cell datasets, verifying that the proposed method has superior detection accuracy and generalization ability. Attached Figure Description

[0051] Figure 1 This is a diagram of the overall framework of the CA-DETR model proposed in this embodiment of the invention;

[0052] Figure 2 This is a schematic diagram of the LPConv Block module structure in an embodiment of the present invention;

[0053] Figure 3 This is a schematic diagram of the AIFI-HA module structure in an embodiment of the present invention;

[0054] Figure 4 This is a schematic diagram of the GSConv module structure in an embodiment of the present invention;

[0055] Figure 5 This is a schematic diagram of the relevant module structure in an embodiment of the present invention, wherein (a) is a standard Bottleneck, (b) is a GS Bottleneck, and (c) is a VoVGSCSP;

[0056] Figure 6 This is a distribution diagram of different categories of defects in the PV-ELAD dataset in an embodiment of the present invention;

[0057] Figure 7 This is a schematic diagram of the six categories of defects in the PV-ELAD dataset in this embodiment of the invention, where (a) is black_core, (b) is crack, (c) is finger, (d) is star_crack, (e) is short_circuit, and (f) is thick_line;

[0058] Figure 8 This is a schematic diagram of the defect categories in the PV-DF dataset in an embodiment of the present invention, wherein (a) is Crack, (b) is Grid, and (c) is Spot;

[0059] Figure 9 These are the confusion matrix results of CA-DETR and RTDETR-r18 in the embodiments of the present invention, where (a) is RTDETR-r18 and (b) is CA-DETR;

[0060] Figure 10 These are the precision-recall curves of RTDETR-r18 and CA-DETR in the embodiments of the present invention, wherein (a) is RTDETR-r18 and (b) is CA-DETR;

[0061] Figure 11 These are the detection results of CA-DETR across datasets in this embodiment of the invention. (a) is the PV-DF dataset, and (b) is the PV-OD dataset.

[0062] Figure 12 This is a visualization comparison chart of the PV-ELAD dataset in an embodiment of the present invention;

[0063] Figure 13 These are the visualization results of the RTDETR-r18 and CA-DETR heatmaps in the embodiments of this invention;

[0064] Figure 14 This is a flowchart illustrating the lightweight defect detection method for photovoltaic cells based on the collaborative attention mechanism of this invention. Detailed Implementation

[0065] The embodiments of the present invention are described in detail below. These embodiments are implemented based on the technical solution of the present invention, and provide detailed implementation methods and specific operation processes. However, the scope of protection of the present invention is not limited to the following embodiments.

[0066] Example 1

[0067] Real-time Detection Transformer v2 (RT-DETRv2) is an advanced end-to-end object detector. It achieves a balance between speed and robustness by co-designing the backbone network, hybrid encoder, and Transformer decoder equipped with an auxiliary prediction head. The core advantage of this model lies in optimizing the initial object query using Intersection over Union (IoU) perceptual query selection and supporting variable inference speed. This breaks through the limitations of traditional real-time detectors in terms of speed and accuracy. However, when facing photovoltaic cell defect detection tasks, target defect detection typically presents challenges such as small size, multiple scales, irregular shapes, and complex backgrounds. This makes it difficult for existing models to simultaneously meet the requirements of high accuracy, real-time inference, and lightweight deployment.

[0068] To address the aforementioned challenges, this invention proposes the CA-DETR method, based on the RT-DETR-r18 benchmark model, for lightweight detection of surface defects in photovoltaic cells. Figure 1 The proposed CA-DETR framework is illustrated below. First, it reconstructs the traditional BasicBlock using Partial Convolution (PConv) blocks from FasterNet, significantly reducing computational complexity and parameter count while maintaining the model's feature extraction capabilities. Second, it employs a Histogram attention mechanism in the feature encoding stage, adaptively capturing local details and global context information to achieve efficient fusion of local and global information. Finally, a lightweight neck network, Slim-neck, is designed, combining GSConv and VoVGSCSP structures to effectively improve the model's ability to extract multi-scale defect features. The proposed model provides good scalability and adaptability for PV battery surface defect detection systems.

[0069] The key modules will be explained in more detail below:

[0070] 1. LPConv Block

[0071] The BasicBlock feature extraction module used in RT-DETR suffers from computational redundancy during multi-scale feature modeling, especially in performing full convolution operations on all feature maps along the channel dimension. This inevitably increases the model parameter size and computational overhead, thus limiting the model's deployment efficiency in real-time and resource-constrained scenarios. To address this issue, this invention introduces the PConv mechanism proposed in FasterNet to improve the BasicBlock of RT-DETR. A lightweight feature extraction module, LPConv Block, is designed to achieve efficient and low-redundancy feature representation learning. By introducing LPConv Block into the feature extraction network, not only can the number of model parameters and computational cost be significantly reduced, but overall inference efficiency can also be improved while maintaining or even improving detection accuracy. The LPConv Block is integrated with the residual block through PConv, and its structure is illustrated in the diagram below. Figure 2 As shown.

[0072] Specifically, PConv performs spatial convolution operations only on a subset of channels of the input feature map, while maintaining the identity mapping for the remaining channels. This significantly reduces computational cost while preserving the original feature information. In this design, only 1 / 4 of the input channels undergo 3x3 convolution, while the remaining 3 / 4 channels skip convolution. To ensure efficient memory access and implementation friendliness, consecutive channels at the beginning or end are used to represent all feature maps participating in the PConv operation. After PConv, a 1x1 pointwise convolution (PWConv) operation is introduced to perform channel fusion and linear recombination on some of the convolutional features, enhancing cross-channel information interaction and compensating for the potential feature representation deficiencies caused by some channels not participating in spatial convolution. Through the collaborative design of PConv and PWConv, the LPConv Block effectively improves the integrity and discriminative power of feature representation while maintaining lightweight characteristics. To maintain efficient memory access, consecutive channels at the beginning or end are used. Each channel represents all feature maps. When the number of input and output channels is the same, the computational cost of PConv convolution is... .in, and It is the size of the feature map. Indicates the size of the convolution kernel. This is the number of channels used in standard convolution. When... At that time, PConv's computational cost is only 1 / 16 of that of standard convolution. PConv's memory access cost is... Furthermore, because spatial convolution operations are performed only on a subset of channels, PConv also has a significant advantage in terms of memory access cost (MAC), which helps improve the hardware friendliness and execution efficiency of the model during actual inference. Overall, the LPConv Block achieves a good balance between lightweight design and feature representation capabilities by effectively reducing redundant channel computations, providing strong support for the real-time and efficient operation of subsequent networks.

[0073] 2. AIFI-HA module

[0074] In photovoltaic cell defect detection, the multi-head self-attention (MSA) mechanism used in the RT-DETR model suffers from insufficient feature modeling efficiency and high computational overhead when handling subtle defects and complex backgrounds. This limits further improvement in model performance and detection efficiency. To address these issues, this invention innovatively introduces the Histogram attention mechanism into the AIFI module, constructing the AIFI-HA module. While maintaining an end-to-end detection framework and high inference efficiency, it achieves efficient fusion of local structural information and global contextual features, thereby enhancing the model's ability to perceive subtle defects in complex backgrounds.

[0075] The AIFI-HA module structure diagram is as follows: Figure 3 As shown. First, input feature map. It is evenly divided into two parts along the channel dimension, denoted as... and .in, Used to preserve original feature information, while This is then used to perform Histogram Attention operations to enhance structure awareness. Specifically, for Sort the features along both the horizontal and vertical directions to construct feature histogram representations in two orthogonal spatial dimensions. This bidirectional sorting strategy effectively captures the distribution relationship of features in spatial structure, enhancing the model's ability to model local structural patterns. Since photovoltaic cell images typically exhibit regularly arranged cell structures, this operation can more fully exploit their potential prior structural information, which is beneficial for suppressing background redundancy and highlighting defect areas.

[0076] Then, the sorted features are compared with the original features. The concatenation process is performed, followed by sequential 1×1 convolution and 3×3 depthwise separable convolution. The 1×1 convolution is primarily used for information exchange between feature channels, while the 3×3 depthwise separable convolution focuses on spatial feature extraction. This combined structure significantly improves detection speed while ensuring a sufficient receptive field. During feature extraction, the output of the dynamic convolution is divided into three parts: feature value V and two sets of query-key pairs. , The eigenvalues ​​V are sorted according to their intensity values, and the corresponding position indices are recorded. This sorting process can be represented as:

[0077]

[0078] in, This refers to performing a sorting operation. This represents the sorted position index information. This index is further used to perform corresponding rearrangement operations on the two sets of query-key features to maintain consistency between features, and can be represented as:

[0079]

[0080] in, This represents the output query vector sequence and key vector sequence. It is the output feature tensor.

[0081] Subsequently, the Histogram attention mechanism employs a dual-path strategy. Specifically, the attention weights for the two sets of query-key features are calculated using two different strategies: Binned Histogram Attention (BHR) and Full-range Histogram Attention (FHR). The BHR strategy divides the feature values ​​into several intervals and calculates the attention weight independently within each interval. This method is more effective at capturing local features. The FHR strategy, on the other hand, calculates the attention weight globally, making it more suitable for handling long-distance dependencies. The two attention weights are as follows: and Its formula is expressed as:

[0082]

[0083]

[0084] in, and These are two different linear mapping functions. It is a scaling factor. yes The dimension of the key vector; It is a matrix transpose operation, used to perform a dot product with the query vector.

[0085] After obtaining the attention maps generated under two different strategies, feature fusion is performed through element-wise multiplication. This fusion method effectively combines the local sensitivity of BHR with the global perception capability of FHR, enhancing the model's ability to discriminate photovoltaic cell defect features. The element-wise multiplication calculation can be expressed as:

[0086]

[0087] Finally, the fused attention map is projected onto the channel dimension through a 1×1 convolution, and the result is remapped back to the spatial location of the original feature map, thereby maintaining the spatial structure consistency of the feature map.

[0088] 3. Slim-neck

[0089] In photovoltaic cell defect detection, the detection model needs to efficiently extract and fuse multi-scale features to accurately capture defects of different sizes and shapes. However, traditional convolutional operations often suffer from information redundancy and loss of effective information during feature extraction and fusion, while also incurring high computational and storage overhead, making it difficult to meet the deployment requirements of embedded and edge devices with limited computing resources. To address these issues, this invention designs a novel lightweight neck network, Slim-neck, based on the RT-DETR framework, to significantly reduce model complexity while maintaining detection accuracy. Slim-neck mainly consists of two key modules: GSConv and VoVGSCSP. The overall structure of GSConv is as follows: Figure 4 As shown.

[0090] The GSConv module concatenates the output features of different types of convolutions and introduces a channel shuffle mechanism to achieve full interaction of cross-channel information, thereby enhancing feature representation capabilities with lower computational overhead. Compared to standard convolutions, GSConv effectively alleviates the information loss problem during feature extraction while reducing redundant computation, making it particularly suitable for lightweight network architecture design. The expression for GSConv can be represented as:

[0091]

[0092] Among them, input features , Perform feature expansion. Used for channel splicing, Shuffle facilitates cross-channel interaction, allowing features to be fully blended.

[0093] To further optimize the network structure and reduce computational costs, this invention replaces the standard convolutional operation in the traditional Bottleneck module with GSConv, constructing the GS Bottleneck module. This module, while maintaining the network depth and receptive field, improves the non-linear expressive power of features and information reuse efficiency through lightweight convolutional operators, thus achieving a good balance between performance and computational efficiency.

[0094] On the other hand, drawing on the design principles of Cross-Stage Partial (CSP) networks, this invention further constructs the VoVGSCSP module. This module employs a one-time aggregation strategy to efficiently integrate features from different stages, avoiding redundant feature computation and information redundancy. By combining GSBottleneck with the CSP structure, VoVGSCSP can significantly reduce the number of parameters and computational overhead while effectively improving the model's ability to model and fuse multi-scale defect features. The relevant module structure is as follows: Figure 5 As shown. In the overall design of Slim-neck, the redundancy of the input feature map in the channel dimension is effectively reduced by improving the convolution operation form and feature fusion method. Specifically, Slim-neck compresses the number of channels through lightweight convolution operators and convolution kernels, reducing the number of parameters and memory access overhead while maintaining the integrity of feature representation and discriminative ability. The expression for VoVGSCSP can be represented as:

[0095]

[0096] in, Used for channel fusion and dimension restoration It means indivual A stack of modules.

[0097] Example 2

[0098] This embodiment verifies the performance of the model proposed in Embodiment 1 through the following experiments.

[0099] 1. Dataset Description

[0100] This invention uses a photovoltaic cell defect dataset jointly constructed by Hebei University of Technology and Beijing University of Aeronautics and Astronautics, called the Photovoltaic Electroluminescence Anomaly Detection (PV-ELAD) dataset. Due to the imbalanced class distribution in the PV-ELAD dataset, this invention performs data class filtering, identifying six types of defects: black core, crack, finger-like structures, star-shaped cracks, short circuits, and thick lines. Figure 6 The statistical distribution of defects in the six categories in the PV-ELAD dataset. Figure 7 The defects in the PV-ELAD dataset are shown in six categories.

[0101] To comprehensively evaluate the generalization performance of the proposed method for surface defect detection, this invention additionally used the PV cell defect fault (PV-DF) dataset and the distributed PV cell object defect (PV-OD) dataset for validation. The PV-DF dataset contains 2400 images for PV cell anomaly detection, including three types of defects: scratches, broken meshes, and dirt. Figure 8 As shown, the PV-OD dataset contains 4007 drone aerial images and can be used for defect detection tasks in small-sized photovoltaic cells.

[0102] 2. Experimental setup and evaluation indicators

[0103] This invention uses three publicly available datasets—PV-ELAD, PV-DF, and PV-OD—for experimental validation, and divides the datasets according to a fixed ratio. Specifically, the PV-ELAD dataset contains 3327 images, divided into training, validation, and test sets in an 8:1:1 ratio, containing 2661, 333, and 333 images respectively. The PV-DF dataset is divided into training and test sets in an 8:2 ratio, containing 1920 and 480 images respectively. The PV-OD dataset is divided in a 7:2:1 ratio, with 2701, 883, and 423 images in the training, validation, and test sets respectively. The experiment uses RT-DETR-r18 as the baseline model, with 150 training epochs and a batch size of 4. The optimizer uses stochastic gradient descent (SGD), with an initial learning rate of 0.0001, a momentum parameter of 0.9, an IoU threshold of 0.7, and the input image size uniformly adjusted to 640×640. All experiments were conducted on an NVIDIA GeForce RTX 4080 GPU, with Python 3.10 as the development environment.

[0104] This invention conducts a comprehensive performance evaluation of the proposed method and the comparison methods under the same training conditions. To measure model performance, commonly used evaluation metrics in the field of object detection are employed, including floating-point operations (FLOPs), parameter size (Param), precision, recall, mean average precision (mAP), model size, and frame rate (FR). Precision and recall reflect the false positive rate and false negative rate of the model, respectively, while mAP is used to comprehensively evaluate the overall detection performance of the model. Given that photovoltaic cell surface defects typically have small scale and blurred boundaries, this invention uses mAP@50 as the main evaluation metric. It represents the mean of the average precision for each category under an IoU threshold of 0.5. The formulas for calculating Precision, Recall, and mAP@50 can be expressed as follows:

[0105]

[0106]

[0107]

[0108] In surface defect detection tasks, targets with actual defects are typically defined as positive samples, while normal areas without defects are defined as negative samples. Based on this, True Positives (TP) represent the number of positive samples correctly identified as defects by the model, False Positives (FP) represent the number of negative samples misidentified as defects by the model, and False Negatives (FN) represent the number of positive samples that the model failed to detect.

[0109] Speed ​​metrics are primarily used to evaluate the computational efficiency and performance of a model during the training and inference phases, reflecting the model's computational cost and processing speed under specific hardware conditions. These metrics comprehensively measure the model's consumption of computing resources and its real-time detection capabilities, and mainly include FLOPS, parameter size, model size, and FR (Functional Rate). The formula for calculating FR can be expressed as:

[0110]

[0111] Here, the inference time per frame is the time required for the model to process a single frame. FR is the reciprocal of the inference time per frame, representing the number of frames the model can process per second, measured in fps.

[0112] 3. Experimental Research

[0113] 3.1 Performance Analysis of the Proposed Method

[0114] To evaluate the effectiveness and accuracy of the proposed CA-DETR model in photovoltaic cell surface defect detection under complex environments, this invention selected RT-DETR-r18 as the benchmark model and conducted comparative experiments with the proposed method. Table 1 shows the performance comparison results of the two methods. The results in the table show that CA-DETR outperforms the benchmark model in overall performance. Specifically, CA-DETR has 13.6M parameters, 39.5 GFLOPs of computation, a model size of 26.6 MB, and an inference speed of 187.1 FPS, demonstrating significant advantages in both model size and computational efficiency, and possessing good real-time detection capabilities. Furthermore, in terms of detection performance, CA-DETR improves upon RT-DETR-r18 in precision, recall, and mAP by 2.0%, 1.9%, and 0.8%, respectively, indicating that the method further improves detection accuracy while maintaining a lightweight model. In summary, the proposed CA-DETR can effectively balance detection accuracy and real-time performance in complex photovoltaic application scenarios, and has high engineering application potential.

[0115] The confusion matrix is ​​an important analytical tool for evaluating the performance of detection models. By comparing the model's predictions with the actual annotations, it can intuitively reflect the identification accuracy and misclassification distribution of each defect category. The confusion matrix results of the baseline model RTDETR-r18 and the proposed CA-DETR are shown below. Figure 9 As shown in the figure, the diagonal elements represent the number of correctly identified samples, and the off-diagonal elements represent misclassified samples. As can be seen from the figure, CA-DETR significantly outperforms RTDETR-r18 in the four defect categories of black core, crack, short circuit, and coarse line, improving by 2%, 4%, 14%, and 6%, respectively. These results demonstrate that the proposed CA-DETR has stronger discrimination ability in key defect categories and can effectively reduce false positives and false negatives.

[0116] Figure 10The comparison results of CA-DETR and the benchmark model RTDETR-r18 on the precision-recall curves are presented. It can be seen that the proposed method achieves superior detection performance across multiple defect categories, with the most significant improvements in mAP for short-circuit and star-shaped cracks, increasing by 2.1% and 10.0% respectively. Simultaneously, the overall mAP for all categories is improved by 0.9%. These results further validate that CA-DETR can comprehensively improve the detection accuracy and robustness for different defect types while maintaining model stability.

[0117] Table 1 Comparison of CA-DETR and RTDETR-r18 proposed experimental results

[0118]

[0119] 3.2 Comparison of detection performance of different methods

[0120] To systematically evaluate the overall performance of the proposed method in object detection, this invention conducted comparative experiments on the PV-ELAD dataset, comparing CA-DETR with several representative state-of-the-art object detection algorithms and their lightweight improvements. This invention uses RT-DETR-r18 as the baseline model, and the comparison methods include Faster R-CNN, YOLOv8m, YOLOv10m, YOLOv11m, YOLOv12m, YOLOv13l, Gold-YOLO-m, and the RETETR series models (REDETR-l, RETETR-x, and RETETR-r34). The performance comparison results of each method are shown in Table 2. Experimental results show that CA-DETR achieves the best performance in detection accuracy, with an mAP@50 of 88.3%, significantly outperforming all the compared methods. Simultaneously, CA-DETR's precision and recall reach 89.6% and 82.2%, respectively, demonstrating significant advantages in controlling both false positives and false negatives.

[0121] The improvement in detection accuracy of CA-DETR is mainly attributed to the lightweight feature modeling strategy that combines partial convolution and group convolution, enabling the model to more effectively represent the surface defect features of photovoltaic cells of different scales and irregular shapes. Furthermore, the RT-DETR framework itself possesses end-to-end real-time detection advantages, providing a solid technical foundation for large-scale online inspection of photovoltaic cells.

[0122] From the perspective of detection efficiency, CA-DETR achieves the highest inference speed among all compared methods, while significantly reducing model complexity while maintaining high detection accuracy. Compared with the benchmark model RT-DETR-r18, its parameter count and computational cost are reduced by 46.2% and 44.3%, respectively, and the model size is reduced by 46.8%. Compared with the traditional Faster R-CNN, although the latter has certain advantages in detection accuracy, its large parameter scale, high computational complexity, and inference speed of only 33.5 FPS make it difficult to meet the requirements of real-time detection. Compared with advanced methods such as YOLOv8m, YOLOv10m, YOLOv11m, YOLOv12m, YOLOv13l, and Gold-YOLO-m, CA-DETR achieves a better overall balance between detection accuracy and computational efficiency. In summary, the proposed CA-DETR significantly improves real-time performance and resource utilization efficiency while ensuring high detection accuracy, fully demonstrating its engineering practical value in large-scale photovoltaic cell online monitoring and industrial application scenarios.

[0123] Table 2 Comparative experiments on the PV-ELAD dataset

[0124]

[0125] 4. Generalization experiment on public datasets

[0126] To further evaluate the generalization ability of the proposed CA-DETR model, cross-dataset validation experiments were conducted on two publicly available photovoltaic cell defect datasets, PV-DF and PV-OD. The experimental results are shown in Table 3. Compared with the benchmark model RT-DETR-r18, CA-DETR achieved varying degrees of improvement in all detection metrics on both datasets. On the PV-DF dataset, the model's recall and mAP@50 improved by 0.8% and 0.7%, respectively. On the PV-OD dataset, the corresponding metrics improved by 1.4% and 0.3%, respectively. These results demonstrate that the proposed method can steadily improve detection performance while maintaining the model's lightweight advantage, exhibiting good cross-dataset generalization ability.

[0127] Furthermore, Figure 11 Visualizations of some detection results of CA-DETR on the PV-DF and PV-OD datasets are presented, covering various typical photovoltaic cell defect types. It can be observed that the model can still achieve accurate localization and identification in scenarios with complex backgrounds and diverse defect morphologies. This demonstrates its strong adaptability and robustness to different data distributions, verifying the stability and engineering feasibility of CA-DETR in practical photovoltaic cell defect detection applications.

[0128] Table 3 Generalization experiments on PV-DF and PV-OD datasets

[0129]

[0130] 5. Visualization of experimental results

[0131] To more intuitively evaluate the detection performance of the proposed method, this invention provides a visual comparison of the detection results of CA-DETR and the benchmark model on the PV-ELAD dataset. The relevant results are as follows: Figure 12 As shown, compared to the baseline model, CA-DETR exhibits stronger perception capabilities in multi-scale defect target detection, especially in small-scale, irregularly shaped, and blurred-boundary defect scenarios, achieving more complete and accurate detection. Even under complex background interference, CA-DETR effectively suppresses false detections and achieves superior performance in defect localization accuracy and category discrimination accuracy, demonstrating its robustness in practical applications.

[0132] Furthermore, to deeply analyze the advantages of the proposed method in feature learning and representation, this invention introduces the interpretability analysis tool Grad-CAM to perform feature response visualization analysis on the baseline model and the optimized CA-DETR. The results are as follows: Figure 13 As shown, the response area of ​​the baseline model is relatively dispersed, making it difficult to effectively focus on key defect areas. In contrast, the activation response of CA-DETR in the defect area is more concentrated and continuous, significantly enhancing its ability to focus on defect edges, detailed textures, and local discriminative features. This indicates that the proposed model has stronger discriminative capabilities in multi-scale feature modeling and key information extraction, effectively compensating for the shortcomings of the baseline model in representing complex defect features. In summary, the visualization of the detection results and Grad-CAM analysis intuitively verify the significant advantages of CA-DETR in multi-scale defect perception, feature focusing ability, and detection robustness, further supporting its effectiveness and practical value in high-precision photovoltaic cell defect detection tasks.

[0133] In summary, the lightweight photovoltaic cell defect detection method based on the collaborative attention mechanism described in the above embodiments proposes a collaborative attention detection Transformer (CA-DETR) model for lightweight surface defect detection in photovoltaic cells. This model mainly consists of a lightweight partial convolutional block (LPConv block), an adaptive information fusion integration-based histogram attention (AIFI-HA) module, and a Slim-neck network. The LPConv block integrates with the residual block via PConv, enhancing the model's multi-scale feature representation capability. Secondly, AIFI-HA achieves efficient fusion of local and global information by enhancing important features and suppressing unimportant features. Finally, the Slim-neck network combines a lightweight shuffled-grouped convolution (GSConv) and a variety of VoV with group standard cross-stage partial (VoVGSCSP) network to achieve efficient fusion of multi-scale defect features.

[0134] Although embodiments of the present invention have been shown and described above, it is understood that the above embodiments are exemplary and should not be construed as limiting the present invention. Those skilled in the art can make changes, modifications, substitutions and variations to the above embodiments within the scope of the present invention.

Claims

1. A lightweight method for detecting defects in photovoltaic cells based on a collaborative attention mechanism, characterized in that, Includes the following steps: S1: Data Preprocessing Acquire images of photovoltaic cell defects and perform preprocessing; S2: Model Building A CA-DETR detection model based on RT-DETR-r18 was constructed. The CA-DETR detection model includes a feature extraction module based on LPConv Block, an AIFI-HA module, a Slim-neck, and the detection head of the benchmark model. S3: Model Training The training set images are input into the CA-DETR detection model for model training. The model performance is evaluated through the validation set, and the optimal model is selected as the photovoltaic cell defect detection model. S4: Defect Detection The test set images are input into the photovoltaic cell defect detection model, which outputs the category and location detection results of photovoltaic cell defects, thus achieving lightweight detection of photovoltaic cell defects.

2. The lightweight photovoltaic cell defect detection method based on collaborative attention mechanism according to claim 1, characterized in that, In step S1, all photovoltaic cell defect images are uniformly adjusted to a size of 640×640 and divided into training set, validation set and test set according to a set ratio.

3. The lightweight photovoltaic cell defect detection method based on collaborative attention mechanism according to claim 1, characterized in that, In step S2, the feature extraction module based on LPConv Block is obtained by replacing the BasicBlock in the baseline model with LPConv Block.

4. The lightweight photovoltaic cell defect detection method based on collaborative attention mechanism according to claim 3, characterized in that, The LPConv Block integrates a partial convolutional PConv and residual block structure. It selects only 1 / 4 of the continuous channels of the input feature map to perform a 3×3 PConv convolution operation, while maintaining the identity mapping for the remaining 3 / 4 channels. After the PConv convolution, a 1×1 PWConv convolution is used to complete feature channel fusion and linear reconstruction. When the number of input and output channels is the same, the computational cost of the PConv convolution is... ,in, and It is the size of the feature map. Indicates the size of the convolution kernel. This is the number of channels used in standard convolution; when At that time, PConv's computational cost was only 1 / 16 of that of ordinary convolution; PConv's memory access cost was... .

5. A lightweight method for detecting defects in photovoltaic cells based on a collaborative attention mechanism according to claim 4, characterized in that, In step S2, the AIFI-HA module replaces the standard multi-head self-attention mechanism in the baseline model. By introducing Histogram attention, it more efficiently models long-distance dependencies between features, enhances feature representation by utilizing histogram statistical properties, and improves detection accuracy.

6. A lightweight method for detecting defects in photovoltaic cells based on a collaborative attention mechanism according to claim 5, characterized in that, In step S2, the specific processing procedure of the AIFI-HA module is as follows: S211: Divide the input feature map evenly into two parts along the channel dimension, denoted as... and , Used to preserve original feature information, Used to perform Histogram Attention operations; S212: Feature map for which Histogram Attention operation is performed Sort along two orthogonal directions, horizontally and vertically, and construct a feature histogram representation; S213: Compare the sorted features with the original features The concatenation process involves sequentially performing 1×1 convolutions to facilitate channel information exchange and 3×3 depthwise separable convolutions to extract spatial features. S214: Divide the output features of depthwise separable convolutions into feature values ​​V and two sets of query-key pairs. , The eigenvalues ​​V are sorted according to their intensity values, and the corresponding location indices are recorded. ; By location index For two sets of query-key features , Perform the corresponding rearrangement operation to maintain the consistency between features; S215: Calculate the corresponding attention weights using a two-path strategy of binned histogram attention (BHR) and full-range histogram attention (FHR). and ; S216: Will and Feature fusion is achieved through element-wise multiplication, followed by channel-dimensional projection via 1×1 convolution to map back to the original feature map spatial location, and the fused feature map is output.

7. A lightweight method for detecting defects in photovoltaic cells based on a collaborative attention mechanism according to claim 6, characterized in that, In step S214, the sorting process is described as follows: ; in, Indicates a sorting operation. Indicates the sorted position index; The rearrangement process is as follows: ; in, This represents the output query vector sequence and key vector sequence. It is the output feature tensor.

8. A lightweight method for detecting defects in photovoltaic cells based on a collaborative attention mechanism according to claim 7, characterized in that, In step S215, attention weights and The calculation formula is as follows: ; ; in, and These are two different linear mapping functions. It is a scaling factor. It is a key vector The dimension; It is a matrix transpose operation.

9. A lightweight method for detecting defects in photovoltaic cells based on a collaborative attention mechanism according to claim 7, characterized in that, In step S2, the Slim-neck includes the VoVGSCSP module, which integrates the single-pass aggregation strategy of GS Bottleneck and cross-stage partial network CSP to improve the model's ability to model and fuse multi-scale defect features. The GS Bottleneck module is obtained by replacing the standard convolution in the Bottleneck module with the GSConv module.

10. A lightweight method for detecting defects in photovoltaic cells based on a collaborative attention mechanism according to claim 9, characterized in that, The calculation formula for the GSConv module is as follows: ; in, As input features, Indicates channel splicing. This refers to channel rearrangement operations. Yes Perform depth-separable operations; The calculation formula for the VoVGSCSP module is as follows: ; in, express number, Used for channel fusion and dimension restoration It means indivual Module stacking.