SCA-YOLOv8n: An Enhanced Approach for Solar Panel Defect Detection

In the context of the global energy structure accelerating its transition towards low-carbon development, solar photovoltaic power generation, as a key technology for the development and utilization of renewable energy, has seen its installed capacity continue to grow at a rapid pace. Solar panels, being the core components for photoelectric conversion, are often exposed to complex outdoor environments and are susceptible to various factors such as temperature, mechanical stress, and atmospheric corrosion. This leads to various defects like scratches, broken grid lines, and dirt. These defects not only cause a significant drop in photoelectric conversion efficiency but can also trigger local hot spot effects, accelerate the aging rate of solar panels, and even lead to serious safety accidents such as fires. Therefore, efficient and accurate detection of defects on solar panel surfaces is crucial for ensuring the stable operation of photovoltaic power stations. However, due to the material properties of solar panels and the complexity of the detection background, it is difficult to effectively identify subtle defects on their surfaces with the naked eye alone.

With the rapid development of computer vision and deep learning technology, object detection methods based on deep learning have shown great potential in the field of defect detection. Currently, deep learning-based object detection algorithms are mainly divided into two types: two-stage object detection algorithms, represented by Faster-RCNN, and single-stage object detection algorithms, centered around the YOLO series. In recent years, solar panel defect detection has become a research hotspot, and many researchers have proposed a series of improved algorithms for this task. For example, one study proposed an improved CNN method for solar cell defect identification, which combined a convolutional neural network with a random forest to improve detection accuracy and speed. Another study addressed photovoltaic fault detection by integrating a particle swarm optimization mechanism into YOLOv8 to adjust model parameters for better detection performance. A different approach introduced a method based on the YOLOv5 algorithm for solar cell defect detection, incorporating the SimAM-Ada mechanism and deformable convolution to improve detection accuracy. Furthermore, another study introduced the Shuffle Attention mechanism and the SwinTransformer module to YOLOv7 for high-precision identification of solar panel defects. However, in practical applications, using deep learning methods to detect defects on solar panels still faces numerous challenges, such as the complex background texture of solar panels leading to low contrast between tiny defects and the background, and the insufficient attention of existing models to subtle defects causing missed detections.

To address the aforementioned issues, our research team proposed an innovative SCA-YOLOv8n model. This model effectively captures the structural features of subtle defects by designing an interactive mechanism for spatial and channel features. Simultaneously, it constructs a coordinate attention mechanism based on position awareness, which dynamically suppresses background texture interference based on the spatial position characteristics of the defects, thereby strengthening the discriminative ability of target features. Furthermore, the model also features an adaptive downsampling architecture that employs a multi-branch fusion strategy to retain key details of defects during the downsampling process while reducing computational complexity. Through the synergistic optimization of feature extraction, attention modeling, and downsampling strategy, the improved model significantly enhances the accuracy and robustness of solar panel defect detection.

Related Theory and Model Improvement

SCA-YOLOv8n Algorithm

YOLOv8 is a single-stage object detection algorithm whose network structure mainly consists of a backbone network, a neck network, and a detection head. The backbone network is responsible for extracting multi-scale spatial features from the image and enhances feature reuse and gradient flow through the C2f module. The neck network combines the Feature Pyramid Network (FPN) and the Path Aggregation Network (PAN) to achieve efficient fusion of multi-scale features. The detection head adopts a decoupled design for classification and detection, optimizing classification accuracy and localization performance through independent branches. Considering the balance between computational resources and performance, we chose the YOLOv8n model for improvement.

First, we integrated the Spatial and Channel Reconstruction Convolution (SCConv) into the backbone network of the model. This module builds a deep spatial-channel interaction mechanism to enhance the network’s ability to perceive and extract multi-scale defect features. Second, we embedded the Coordinate Attention (CoordAtt) mechanism at key positions in the neck network. This mechanism uses position information to generate direction-aware attention maps, effectively improving the localization accuracy of defect regions while suppressing background noise interference. Finally, we replaced the standard convolutional layers with the lightweight Adaptive Downsampling (ADown) module. This module uses dynamic weight assignment and multi-path feature fusion to reduce computational complexity while avoiding detail loss during the downsampling process. By combining these optimizations, we constructed the SCA-YOLOv8n network.

Spatial and Channel Reconstruction Convolution

During the feature extraction process of the YOLOv8 network, due to the limitations of the receptive field and downsampling operations, features of smaller-sized defects are prone to insufficient capture and transmission attenuation, leading to missed detections. To enhance the detection capability for tiny defects, we constructed an efficient convolution module, SCConv, composed of a Spatial Reconstruction Unit (SRU) and a Channel Reconstruction Unit (CRU). The core processing flow of the SCConv module is as follows: the input defect feature X first enters the SRU. This unit employs a separation-reconstruction strategy, separating and reconstructing redundant features based on weight criteria, achieving spatial refinement of the input features. It then outputs the spatially reconstructed feature X_w. Subsequently, X_w enters the CRU, which uses a separation-transformation-fusion strategy to reduce channel redundancy, lower the channel dimension, and effectively reduce the computational cost and storage requirement of the algorithm. Finally, it outputs the channel-reconstructed feature Y with lower redundancy.

The SRU module leverages the spatial redundancy of features to perform separation and reconstruction operations, thereby achieving feature enhancement. The separation operation separates feature maps containing rich information from those with less information content. During this process, the SRU uses a learnable scaling factor in Group Normalization (GN) to evaluate the information content of the feature maps. Specifically, given a feature map X ∈ R^(N × C × H × W), where N is the batch size, C is the channel dimension, and H and W are the spatial height and width. First, group normalization is applied to standardize it, which normalizes the input feature X by subtracting its mean and dividing by its standard deviation, as shown in Equation (1):

$$ X_{out} = GN(X) = \gamma \frac{X – \mu}{\sqrt{\sigma^2 + \epsilon}} + \beta $$

where μ and σ are the mean and standard deviation of X, ε is a small constant added for numerical stability in division, and γ and β are the trainable parameters introduced in group normalization. The model measures the spatial variation of pixels within each batch and channel through the scaling factor γ. The spatial information richness of different batches and channels varies, and the trained γ values also differ. β reflects the positional offset of the feature map after normalization. To further quantify the information importance of each channel’s feature map, the trainable parameter γ learned by the model is normalized to obtain the channel weight w_γ, which represents the importance of different feature mappings. The calculation process is shown in Equation (2):

$$ w_\gamma = \{w_i\} = \frac{\gamma_i}{\sum_{j=1}^{C} \gamma_j}, \quad i, j = 1, 2, \cdots, C $$

where i and j are channel index constants, C is the total number of channels in the feature map, and w_i is the weight of the i-th channel. After obtaining the channel weights w_γ, they are element-wise multiplied with the normalized feature map to enhance the response of high-importance channels and suppress interference from low-importance channels. Subsequently, a Sigmoid function is used to map the result to the (0,1) interval to ensure numerical stability. Then, through a threshold gating operation, high-information weights W_more above the threshold and low-information weights W_less below the threshold are selected. The calculation of W is shown in Equation (3):

$$ W = \text{Threshold}(\text{Sigmoid}(w_\gamma \otimes GN(X))) $$

Finally, the feature X is multiplied by W_more and W_less, respectively, to obtain the high-information weighted feature X_w_more and the low-information weighted feature X_w_less. This achieves the separation of the input features into spatially rich and limited information contents. Subsequently, a cross-sum reconstruction strategy is used to merge the different information features to generate the output of the SRU module, enhancing information exchange between features of different weights. After SRU processing, the features are divided and reconstructed based on information content, thereby highlighting key features and suppressing redundant ones. However, even so, the spatially refined features still possess redundancy in the channel dimension.

To address the redundancy in the channel dimension, the CRU module is used, whose core strategy is the separation, transformation, and fusion of features. Specifically, the spatially refined feature X_w is first split according to a split ratio α into αC and (1-α)C. Then, 1×1 convolutions are used to compress the channels of the two feature groups to improve computational efficiency, resulting in split features X_up and X_low. X_up is assigned to the upper transformation channel, and after Group-wise Convolution (GWC) and Point-wise Convolution (PWC), feature Y1 is generated at a lower computational cost. X_low is assigned to the lower transformation channel, and after point-wise convolution processing, its output is fused with X_low to obtain feature Y2. These transformation processes can be represented by Equations (4) and (5):

$$ Y_1 = GWC(X_{up}) + PWC(X_{up}) $$
$$ Y_2 = \text{Cat}(PWC(X_{low}), X_{low}) $$

After transformation, a lightweight SKNet method is used to replace simple concatenation or summation operations to fuse the features Y1 and Y2 from the upper and lower stages. First, global average pooling is applied to extract spatial features and channel statistics, obtaining pooling vectors S1 and S2. These are then normalized using the SoftMax function to generate weight vectors β1 and β2. The calculation method is shown in Equation (6):

$$ \beta_1 = \frac{e^{S_1}}{e^{S_1} + e^{S_2}}, \quad \beta_2 = \frac{e^{S_2}}{e^{S_1} + e^{S_2}}, \quad \beta_1 + \beta_2 = 1 $$

Finally, guided by the importance vectors β1 and β2, the features Y1 and Y2 are summed along the channel dimension to obtain the reconstructed output feature Y, as shown in Equation (7):

$$ Y = \beta_1 Y_1 + \beta_2 Y_2 $$

In summary, by jointly applying the spatial reconstruction module and the channel reconstruction module, the input feature X achieves a more refined feature representation. This module effectively enhances the extraction and expression capability of detail features for small targets while reducing the computational load, thereby lowering the missed detection rate.

Coordinate Attention Mechanism

Some defects on solar panels have low distinguishability from the background and can be easily overlooked by the model. To enable the network to focus precisely on the defective regions, we constructed a Coordinate Attention (CoordAtt) mechanism. This mechanism effectively captures the positional and channel information of the feature map, helping the network better perceive defect-related information during the feature learning process, thereby improving the overall detection efficiency.

The core principle of the CoordAtt mechanism is to embed positional information into channel attention, allowing the network to simultaneously attend to channel dependencies and spatial positional information. The specific calculation process is as follows: Given an input feature x, pooling kernels of size (H, 1) and (1, W) are used to encode features along the horizontal and vertical directions for each channel. For the c-th channel, its output at height h can be represented as:

$$ z_h^c(h) = \frac{1}{W} \sum_{0 \le i \lt W} x_c(h, i) $$

Similarly, the feature output for the c-th channel at width w can be represented as:

$$ z_w^c(w) = \frac{1}{H} \sum_{0 \le j \lt H} x_c(j, w) $$

After the feature maps are aggregated in different spatial directions using the above equations, a pair of direction-aware feature maps is obtained. These aggregated feature maps are then concatenated and passed through a shared 1×1 convolution transformation F1 for dimensionality reduction, yielding:

$$ f = \delta(F_1([z_h, z_w])) $$

In this context, δ is a non-linear activation function, [z_h, z_w] represents the concatenation result along the spatial dimension, and f ∈ R^(C/r × (H+W)) is an intermediate feature map encoding spatial information from different directions. Then, f is split along the spatial dimension into f_h ∈ R^(C/r × H) and f_w ∈ R^(C/r × W). By applying 1×1 convolution operations to f_h and f_w, their channel numbers are unified to match the input x, yielding:

$$ g_h = \sigma(F_h(f_h)) $$
$$ g_w = \sigma(F_w(f_w)) $$

Finally, the resulting feature vectors g_h and g_w are element-wise multiplied with the input feature map x to redistribute the weights:

$$ y_c(i, j) = x_c(i, j) \times g_h^c(i) \times g_w^c(j) $$

This results in the weighted feature map y. Through the above calculations, the weights of defect-related regions are enhanced, while the weights of background regions are relatively weakened. This guides the network to focus on defective areas, effectively suppressing background texture interference and reducing the probability of false detection for subtle defects.

Adaptive Downsampling Module

In deep convolutional neural networks, downsampling is crucial for controlling computational complexity and expanding the receptive field. However, traditional downsampling strategies tend to lose a significant amount of spatial information when compressing the feature map, especially high-frequency details and local structures, which is detrimental to defect detection in complex backgrounds. To address this, we constructed an Adaptive Downsampling (ADown) module to replace the original convolutional downsampling module, aiming to balance information fidelity and computational efficiency.

The ADown module first applies average pooling to smooth features and aggregate receptive field information. Then, by adjusting the dimension structure of the feature map, it reduces the computational complexity and resource consumption of each branch while ensuring feature integrity. One branch uses a 3×3 convolution to mine local spatial features, enhancing sensitivity to defective regions. The other branch combines max pooling with a 1×1 convolution, focusing on the spatial distribution and intensity of prominent defects. After merging the two branches along the channel dimension, not only is the feature diversity and information content improved, but effective compression of the spatial scale of the feature map is also achieved. This multi-branch structure preserves information to the greatest extent during the downsampling process by enhancing feature combination and information interchange. Furthermore, it uses small-sized convolution kernels, which, while maintaining strong feature expressiveness, significantly reduces the parameter count and computational complexity, thereby improving training and inference efficiency.

Experimental Design and Result Analysis

Experimental Dataset

The solar panel defect dataset used in our experiments was sourced from the Baidu PaddlePaddle public resource pool, covering three types of defects: scratches, broken grid lines, and dirt, with a total of 2,400 images. The Labelimg tool was used to annotate the defect categories and location information, generating the dataset in YOLO format. To ensure the generalization ability and evaluation accuracy of the model, the defect images were divided into training, validation, and test sets at an 8:1:1 ratio.

Experimental Environment

In our experiments, the training and testing image size was set to 640×640, the number of training epochs was 100, and the training batch size was 16. The training optimizer used was Stochastic Gradient Descent (SGD). The experiment was conducted on the Windows 10 platform, with hardware configuration consisting of a 10-core Intel Xeon Gold 6152 CPU, 30 GB of RAM, and a 24 GB NVIDIA GeForce RTX 3090 GPU. The model was developed using Python 3.10 and PyTorch 2.2, with GPU acceleration enabled via CUDA 12.1.

Ablation Study

To verify the actual contribution of each module to the model’s performance, we designed and conducted 6 sets of ablation experiments. The specific results are shown in Table 1.

Models mAP@0.5 (%) Precision (%) Recall (%) Parameters (M) GFLOPs (G)
YOLOv8n 92.4 87.5 88.4 3.01 8.1
S-YOLOv8n 92.8 87.7 89.5 3.12 8.2
C-YOLOv8n 93.1 88.1 89.0 3.02 8.1
A-YOLOv8n 93.2 89.9 89.5 2.72 7.6
SC-YOLOv8n 93.4 88.8 89.2 3.14 8.2
SCA-YOLOv8n 94.4 90.7 90.0 2.86 7.7
Table 1: Ablation experiment results. Bold numbers represent the best values.

From Table 1, it can be observed that compared to the baseline network, S-YOLOv8n, which introduced the SCConv module, achieved a 0.4% improvement in mAP@0.5, a 0.2% increase in Precision, and a 1.1% increase in Recall. This indicates that the SCConv module facilitates refined modeling of defect representations through feature map reconstruction. Furthermore, C-YOLOv8n, by integrating the CoordAtt mechanism, showed a 0.7% improvement in mAP@0.5 and a 0.6% increase in Precision. This demonstrates the advantage of the position and channel collaborative weighting strategy in enhancing the feature response of critical defect regions. To optimize computational efficiency while improving detection accuracy, A-YOLOv8n introduced the lightweight ADown module, resulting in a mAP@0.5 of 93.2%, an 0.8% increase in Precision, and a simultaneous reduction in parameters by 9.6% and GFLOPs by 6.2%. This showcases its excellent balance between compressing computational redundancy and preserving discriminative information. SC-YOLOv8n, which combined the advantages of SCConv and CoordAtt, further improved mAP@0.5 by 1.0%, validating the complementary gains of these two modules in the feature optimization pathway. Finally, by adding the ADown module to SCA-YOLOv8n, we observed a significant improvement of 2.0% in mAP@0.5, with Precision and Recall increasing by 3.2% and 1.6%, respectively. Concurrently, the number of parameters decreased by 5.0% and GFLOPs decreased by 4.9%. This confirms the significant enhancement of the multi-module collaborative strategy on the performance of solar panel defect detection.

Comparative Experiment

To comprehensively evaluate the performance of the SCA-YOLOv8n model in solar panel defect detection, we selected mainstream models including the YOLO series, RT-DETR, Hyper-YOLO, and Mamba-YOLO for comparison. The experimental results are shown in Table 2.

Models mAP@0.5 (%) Precision (%) Recall (%)
YOLOv8n 92.4 87.5 88.4
YOLOv9s 91.3 88.7 87.2
YOLOv11n 91.6 88.2 87.8
YOLOv12n 88.9 85.1 85.5
YOLOv13n 92.7 86.6 88.6
RT-DETR 92.0 88.9 89.4
Hyper-YOLO 90.1 89.2 84.3
Mamba-YOLO 87.3 84.4 85.1
SCA-YOLOv8n 94.4 90.7 90.0
Table 2: Experimental results for different models. Bold numbers represent the best values.

The data in Table 2 show that SCA-YOLOv8n achieved the best performance across all metrics on the solar panel defect dataset. Its mAP@0.5 reached 94.4%, with Precision and Recall at 90.7% and 90.0%, respectively, significantly outperforming other compared models. While YOLOv8n, YOLOv13n, and RT-DETR also performed well in overall performance, their detection results were still inferior compared to SCA-YOLOv8n. YOLOv9s and YOLOv11n showed balanced performance in Precision and Recall, but did not demonstrate a significant performance advantage. The mAP@0.5 of YOLOv12n and Mamba-YOLO were only 88.9% and 87.3%, respectively, indicating limitations in their adaptability to photovoltaic defect features. Furthermore, although Hyper-YOLO had relatively high detection Precision, its Recall was only 84.3%, making it difficult to guarantee comprehensive defect detection in complex environments. In summary, SCA-YOLOv8n performed best among all compared models, fully verifying its advantage in identifying subtle defects under complex backgrounds.

Visualization Analysis

To intuitively compare the differences in defect region localization between the YOLOv8n and SCA-YOLOv8n models, we selected representative samples from the solar panel defect dataset and used heatmaps for visualization. The heatmap comparison demonstrates the effectiveness of the improved model. In samples with scratches, SCA-YOLOv8n was able to focus more precisely on the defect body, ensuring the completeness and stability of target localization. In contrast, YOLOv8n failed to fully cover the defect area, with edge missed detections and a more dispersed heatmap response region. For samples with broken grid lines, while YOLOv8n could locate the defect position, its feature response was relatively weak. The improved model, however, exhibited higher target consistency and regional alignment. Similarly, in samples with dirt, SCA-YOLOv8n demonstrated stronger background suppression capabilities, with a more concentrated heatmap distribution and significantly fewer false activation areas. These visualization results validate the effectiveness of the improved algorithm in enhancing spatial perception and fine-grained feature capture, providing more reliable technical support for the efficient identification of solar panel defects.

Generalization Experiment

To further verify the generalization ability of the SCA-YOLOv8n model under different data distributions, we selected the public PVEL-AD dataset for comparative experiments. This dataset covers five typical types of solar cell defects: line cracks, broken grid lines, black cores, thick lines, and star cracks, making it highly representative and challenging. The experiment used 2,589 defect images, divided into training, validation, and test sets at an 8:1:1 ratio. The comparative models selected for this experiment were consistent with those used in the previous comparative experiment. The results are shown in Table 3.

Models mAP@0.5 (%) Precision (%) Recall (%)
YOLOv8n 85.2 82.0 81.6
YOLOv9s 84.4 82.7 79.0
YOLOv11n 84.7 82.5 80.4
YOLOv12n 83.6 81.9 80.1
YOLOv13n 85.7 82.3 80.6
RT-DETR 85.4 82.4 81.1
Mamba-YOLO 82.4 81.3 75.8
Hyper-YOLO 84.9 82.1 81.9
SCA-YOLOv8n 86.8 82.8 82.6
Table 3: Generalization experiment results. Bold numbers represent the best values.

The experimental results indicate that SCA-YOLOv8n achieved the best overall performance on the PVEL-AD dataset, with an mAP@0.5 of 86.8%, and Precision and Recall of 82.8% and 82.6%, respectively. These values are all higher than those of the other compared models. In comparison, while YOLOv8n, YOLOv13n, and RT-DETR showed certain competitiveness, they still trailed behind the improved model. YOLOv9s, YOLOv11n, and Hyper-YOLO performed relatively averagely, while Mamba-YOLO and YOLOv12n exhibited notable shortcomings. A comparison of the visual results demonstrated the improved model’s effectiveness on the PVEL-AD dataset. The original YOLOv8n model showed significant missed detections for star cracks and black core defects, failing to generate effective detection boxes. In contrast, the improved model successfully identified these defects. Additionally, the improved model showed higher confidence for line crack defects that were already detected by the original model, reflecting superior accuracy.

The above results show that SCA-YOLOv8n not only possesses good detection capability on the original task but also demonstrates excellent generalization ability on a more complex, multi-class solar cell defect dataset.

Conclusion

Addressing the challenges of difficult defect identification and complex background interference in solar panel defect detection, we proposed an improved SCA-YOLOv8n model. By designing the SCConv module, which combines a synergistic perception mechanism of spatial and channel features, the model significantly enhanced its ability to capture subtle defects. Simultaneously, the introduction of the CoordAtt mechanism strengthened the response to defective regions and effectively suppressed background noise, improving the discriminative ability of target features. Furthermore, the adoption of the ADown adaptive downsampling structure, combined with a multi-branch fusion strategy, achieved a significant improvement in detection accuracy while maintaining a low computational cost. The experimental results showed that on the solar panel defect dataset, the mAP@0.5 metric for SCA-YOLOv8n improved by 2.0%, reaching 94.4%, validating the model’s advantage in improving detection accuracy. At the same time, the model made significant progress in reducing computational complexity, with a 5.0% reduction in the number of parameters and a 4.9% reduction in GFLOPs. This effectively lightens the computational burden, ensuring its efficiency in practical applications. Furthermore, the generalization experiment based on the PVEL-AD panel defect dataset further verified that SCA-YOLOv8n possesses strong cross-scenario adaptability and robustness. In summary, while maintaining a lightweight model, SCA-YOLOv8n significantly improved the accuracy and generalization ability of solar panel defect detection, fully demonstrating its great potential in practical engineering applications.

Scroll to Top