Improved SSD Algorithm for Solar Panel Contamination Detection

In this work, we address the practical challenge of detecting surface contamination on solar panels using unmanned aerial vehicles (UAVs) equipped with embedded devices. Given the limited computational resources on these platforms and the heavy computational burden of existing defect detection models, we propose a lightweight deep learning approach based on the Single Shot MultiBox Detector (SSD) framework. Our method employs MobileNetV3 as the backbone network to substantially reduce the parameter count and computational complexity. We further introduce a coordinate attention mechanism to enhance feature extraction and improve detection accuracy. Additionally, we apply Mosaic data augmentation to enrich our self-constructed dataset and boost the generalization capability of the model. Extensive experiments on a custom dataset demonstrate that our improved algorithm reduces the computational cost by 68.9% compared to the original SSD, increases the mean average precision by 4.3%, and achieves a detection speed of 45.6 frames per second (FPS). The proposed model can quickly and accurately detect various contaminations on solar panel surfaces, thereby contributing to the operational efficiency of photovoltaic power stations.

1. Introduction

The distributed photovoltaic power generation capacity has reached an enormous scale, making the maintenance and monitoring of solar panels a critical task. During long-term outdoor operation, solar panel surfaces are prone to contamination such as bird droppings, dust accumulation, cracks, and snow cover. These contaminants can significantly reduce the power conversion efficiency of photovoltaic modules. Therefore, timely and accurate detection of surface defects is essential for optimizing energy output and preventing permanent damage.

Existing detection techniques can be broadly classified into electrical characteristic methods and visual inspection methods. Electrical characteristic methods often rely on analyzing the current-voltage (I-V) curve of photovoltaic modules. While these approaches can provide quantitative diagnostics, they typically require multiple sensors and complex measurement setups, which are not always convenient for rapid aerial inspection. In contrast, visual inspection methods offer a more intuitive and direct solution. Traditional image processing techniques, such as morphological edge detection, have been applied to identify thermal hotspots and other anomalies. However, these hand-crafted feature-based methods often fail to meet the dual requirements of accuracy and speed in the context of large-scale distributed solar farms.

With the rapid development of deep learning, convolutional neural network (CNN) based object detectors have become the dominant paradigm for visual inspection. Two-stage detectors such as Faster R-CNN achieve high accuracy by generating region proposals and then classifying them, but they tend to be slow and memory-intensive. Single-stage detectors, including YOLO and SSD, offer much faster inference speeds while maintaining competitive accuracy. Among them, SSD provides a good balance between speed and accuracy, especially for multi-scale detection. Many researchers have improved SSD by incorporating feature pyramid networks, attention mechanisms, or contrastive learning to enhance feature representation. However, most of these improved models still suffer from excessive parameter counts and computational overhead, making them unsuitable for deployment on UAV embedded platforms with limited processing power.

To address these limitations, we propose an improved SSD architecture that is both lightweight and accurate. Our key contributions are summarized as follows:

  • We replace the original VGG-style backbone of SSD with MobileNetV3, which dramatically reduces model parameters and floating-point operations while preserving powerful feature extraction capabilities.
  • We integrate a coordinate attention mechanism into the feature extraction pipeline. This mechanism encodes position information in both the width and height directions, allowing the model to focus on relevant spatial regions and improve detection precision.
  • We adopt Mosaic data augmentation to increase the diversity of our training dataset. This technique combines four images into one training sample, enabling the model to better handle small objects, occlusions, and varying lighting conditions.
  • We construct a dedicated dataset of visible light solar panel images containing six categories: clean panels, bird droppings, dirt, electrical damage, physical damage, and snow cover. We evaluate our model against multiple baseline detectors and report detailed ablation studies.

The remainder of this paper is organized as follows. Section 2 reviews related work on solar panel defect detection and lightweight object detection. Section 3 presents the proposed method, including the network architecture, attention module, and data augmentation strategy. Section 4 describes the experimental setup, dataset, and evaluation metrics. Section 5 reports and discusses the experimental results, including ablation studies and comparisons with other detectors. Finally, Section 6 concludes the paper and outlines future directions.

2. Related Work

2.1 Solar Panel Defect Detection

Visual inspection of solar panels has been extensively studied in recent years. Early approaches relied on hand-crafted features and classical image processing techniques. For example, morphological operations were used to extract edge information from photovoltaic cell images, enabling the identification of thermal hotspots. However, these methods are sensitive to illumination changes and background clutter, limiting their applicability in real-world UAV imagery.

With the advent of deep learning, various CNN-based detectors have been applied to solar panel defect detection. Faster R-CNN was modified with customized anchor boxes for thermal spot detection, achieving high accuracy but at a relatively low frame rate. YOLO variants have been used for defect detection in infrared and visible light images, offering faster inference. SSD, with its multi-scale feature maps, has also been adapted for this task. Several studies introduced feature pyramid structures or contrastive learning to improve SSD’s feature representation. While these methods improve accuracy, they often increase model complexity, making them less suitable for embedded deployment.

2.2 Lightweight Object Detection

To enable real-time detection on resource-constrained devices, lightweight network architectures have been developed. MobileNetV1 introduced depthwise separable convolutions as a building block for efficient models. MobileNetV2 added the inverted residual structure with linear bottlenecks, further improving efficiency. MobileNetV3 combines neural architecture search, squeeze-and-excitation modules, and hard-swish activation to achieve state-of-the-art performance for mobile devices. Using MobileNetV3 as a backbone for SSD not only reduces parameters but also maintains strong feature extraction capability due to its optimized design.

2.3 Attention Mechanisms

Attention mechanisms have become a powerful tool for improving deep neural networks. The squeeze-and-excitation (SE) block adaptively recalibrates channel-wise feature responses, but it ignores spatial position information. The convolutional block attention module (CBAM) combines channel and spatial attention. However, both methods have limitations in capturing long-range dependencies with orientation information. The coordinate attention (CA) mechanism, introduced by Hou et al. (2021), encodes positional information into channel attention by decomposing spatial attention into two 1D feature encoding processes. This is particularly beneficial for object detection tasks where precise localization is crucial.

3. Proposed Method

3.1 Overview of the Improved SSD-MobileNetV3 Architecture

Our improved detection framework is built upon the SSD architecture. The overall structure is illustrated in Figure 1. We adopt MobileNetV3 (large version) as the backbone network, replacing the original VGG-16 base. The backbone is responsible for extracting hierarchical features from an input image. A series of extra convolutional layers are appended to the backbone to generate feature maps at multiple scales. The output feature maps have spatial sizes of 19×19, 10×10, 5×5, 3×3, 2×2, and 1×1. Each feature map cell predicts a set of default bounding boxes with class probabilities and offsets. The final detection results are obtained by applying non-maximum suppression with a threshold of 0.5 to eliminate duplicate predictions.

This figure shows a typical solar panel installation that is the target scenario of our detection system. The input image is resized to 300×300 pixels before being fed into the network. The multi-scale design enables the detection of objects with different sizes, such as small bird droppings and large snow-covered panels.

3.2 MobileNetV3 Backbone

MobileNetV3 is a modern lightweight architecture that combines several advanced techniques. The core building block is the inverted residual bottleneck structure, as depicted in Figure 2. This structure first expands the number of channels using a 1×1 convolution, then applies a 3×3 depthwise convolution, and finally projects the features back to a lower dimension using another 1×1 convolution. The expansion ratio is typically set to 4 or 6. This bottleneck design reduces both parameters and computation compared to traditional convolutions.

There is an important design choice in the bottleneck block: the use of linear activation functions in the final projection layer. In MobileNetV3, the last 1×1 convolution of each block is followed by a linear activation (no nonlinearity), whereas the intermediate layers use either ReLU or hard-swish activation. This linear bottleneck preserves information that might otherwise be lost by a nonlinear activation, improving the representational capacity of the network.

Depthwise separable convolutions consist of a depthwise convolution followed by a pointwise convolution. The computational cost of a standard convolution is \(O(H \cdot W \cdot C_{in} \cdot C_{out} \cdot K^2)\), while the cost of a depthwise separable convolution is \(O(H \cdot W \cdot C_{in} \cdot K^2) + O(H \cdot W \cdot C_{in} \cdot C_{out})\). For a 3×3 kernel, this reduces the computation by a factor of nearly \(C_{out}/9\), assuming \(C_{out}\) is large. This efficiency is crucial for embedded deployment.

In our implementation, we use the MobileNetV3-large configuration. The final layer of the backbone serves as the input to the first extra feature layer. We remove the classification head of MobileNetV3 and keep only the feature extraction layers to serve as the SSD base.

3.3 Coordinate Attention Mechanism

Traditional channel attention mechanisms, such as the squeeze-and-excitation block, use global average pooling to compress spatial dimensions into a single channel descriptor. This operation discards positional information, which is important for precise localization in object detection. The coordinate attention (CA) mechanism addresses this issue by encoding both spatial coordinates and channel-wise information. Figure 3 illustrates the structure of the CA module.

Given an input feature tensor \(X \in \mathbb{R}^{H \times W \times C}\), where \(H\), \(W\), and \(C\) denote height, width, and number of channels respectively, the CA mechanism first applies two separate average pooling operations along the horizontal and vertical directions. This results in two feature maps:

$$ z_h(h) = \frac{1}{W} \sum_{i=0}^{W-1} X(h, i) $$
$$ z_w(w) = \frac{1}{H} \sum_{j=0}^{H-1} X(j, w) $$

where \(z_h \in \mathbb{R}^{H \times 1 \times C}\) and \(z_w \in \mathbb{R}^{1 \times W \times C}\). These two feature maps are then concatenated along the spatial dimension and passed through a shared 1×1 convolution followed by a non-linear activation function:

$$ f = \delta( F_{1\times1}( [z_h, z_w] ) ) $$

Here, \([\cdot, \cdot]\) denotes concatenation along the spatial dimension, \(F_{1\times1}\) is a 1×1 convolutional layer that reduces the channel dimension, and \(\delta\) is a non-linear activation such as ReLU. The resulting feature map \(f\) is then split back into two separate tensors \(f_h \in \mathbb{R}^{H \times 1 \times C/r}\) and \(f_w \in \mathbb{R}^{1 \times W \times C/r}\), where \(r\) is the reduction ratio. These tensors are transformed back to the original channel dimension using two independent 1×1 convolutions:

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

where \(F_h\) and \(F_w\) are 1×1 convolutions, and \(\sigma\) is the sigmoid activation function. The final output of the CA module is computed by multiplying the input with the two attention weights:

$$ Y = X \cdot g_h \cdot g_w $$

This decomposition allows the network to capture long-range dependencies in one direction while encoding precise positional information in the other. As a result, the CA module significantly improves the model’s ability to locate objects of interest, especially in cluttered or complex backgrounds.

We integrate the CA module into the MobileNetV3 backbone at several stages. Specifically, we insert CA after certain bottleneck blocks to enhance the feature maps before they are passed to the SSD prediction layers. This insertion adds only a small number of parameters, but the performance gain is substantial.

3.4 Mosaic Data Augmentation

To improve the generalization of our model and to address the scarcity of defect samples, we employ Mosaic data augmentation. This technique was originally introduced in YOLOv4 and has proven effective for improving detection performance on small objects. The process works as follows:

  1. Randomly select four images from the training dataset.
  2. Apply random scaling, cropping, and rotation to each image.
  3. Concatenate the four processed images to form a single mosaic image.
  4. Adjust the bounding boxes accordingly.

By mixing four different images in one training sample, the model is exposed to a wider variety of object scales, aspect ratios, and background patterns. This reduces overfitting and increases robustness to different lighting conditions and viewpoints. In our implementation, we also apply random color jittering to further diversify the training data. The effect of Mosaic augmentation is shown in Figure 4, where four distinct solar panel images are combined into one training sample.

We use a standard implementation with a grid size of 2×2. Each image occupies one quadrant of the final mosaic. The bounding boxes that fall outside the boundaries are discarded, and those that are partially outside are clipped. This augmentation is applied on the fly during training with a certain probability (set to 0.5 in our experiments).

4. Experimental Setup

4.1 Dataset

Since there is no publicly available visible light solar panel contamination dataset, we constructed our own dataset following the PASCAL VOC format. The dataset includes images of clean solar panels as well as panels with various types of contamination: bird droppings, dirt, electrical damage, physical damage, and snow cover. We collected images from multiple solar farms using aerial drones and ground-level cameras. All images were annotated manually using the LabelImg tool. The dataset was randomly split into training, validation, and test sets with a ratio of 8:1:1.

Table 1 summarizes the number of images in each category for the three subsets. It is important to note that a single image may contain multiple objects of different categories, so the total count of annotations is larger than the number of images.

Table 1: Distribution of images in the self-constructed dataset
Subset Ratio (%) Total Images Bird Droppings Clean Dirt Electrical Damage Physical Damage Snow
Training 80 6136 1459 1241 1703 374 297 1179
Validation 10 638 167 119 105 34 24 189
Test 10 638 180 135 83 35 33 172

4.2 Implementation Details

We implemented our model using PyTorch 1.10 and trained it on an NVIDIA GeForce RTX 3060 GPU with 12 GB memory. The input image size was fixed to 300×300 pixels. The batch size was set to 32, and the total number of training epochs was 300. We used stochastic gradient descent (SGD) with momentum 0.9 and weight decay 0.0005. The initial learning rate was 0.01, and a cosine annealing schedule was applied to gradually reduce the learning rate over time. This helps the model converge to a better optimum and improves generalization.

The anchor boxes for each feature map were predefined based on the original SSD configuration. We used six feature maps with anchor scales [21, 45, 99, 153, 207, 261] pixels and aspect ratios [1, 2, 0.5, 3, 0.333]. The matching threshold for positive and negative samples was set to 0.5, and hard negative mining with a ratio of 3:1 was used to balance positives and negatives.

4.3 Evaluation Metrics

We used multiple metrics to evaluate our model from different perspectives.

  • Mean Average Precision (mAP): Computed on the validation set. The mAP is the average of the average precision (AP) over all categories. AP is calculated as the area under the precision-recall curve.
  • Accuracy: The overall classification accuracy on the test set, defined as the percentage of correctly detected objects over the total number of ground truth objects.
  • Parameter Count: The total number of learnable parameters in the model, including weights and biases.
  • Computational Cost: Measured in GFLOPs (giga floating-point operations per second) for a single 300×300 input.
  • Model Size: The size of the saved model file in MB.
  • Inference Speed: Measured in FPS on the test set using the same GPU.

5. Results and Discussion

5.1 Ablation Study

To validate the contribution of each component in our proposed method, we conducted a series of ablation experiments. The results are summarized in Table 2. We compare the following configurations:

  • A: Original SSD with ResNet50 backbone.
  • B: SSD with MobileNetV3 backbone, no attention mechanism, with Mosaic augmentation.
  • C: SSD with MobileNetV3 backbone, with CA attention, but without Mosaic augmentation.
  • D: Our full model (MobileNetV3 + CA + Mosaic).
Table 2: Ablation study results
Exp. Backbone CA Mosaic mAP (%) Accuracy (%) Parameters GFLOPs
A ResNet50 No Yes 72.68 78.43 44,553,636 30.0
B MobileNetV3 No Yes 77.50 81.03 14,114,584 13.7
C MobileNetV3 Yes No 78.41 84.11 14,114,890 13.7
D MobileNetV3 Yes Yes 82.71 92.28 14,114,890 13.7

By comparing experiments A and B, we observe that replacing ResNet50 with MobileNetV3 improves the mAP by 4.82% and accuracy by 2.6%, while reducing the parameter count from 44.55M to 14.11M and the computational cost from 30.0 to 13.7 GFLOPs. This demonstrates that MobileNetV3 not only makes the model much lighter but also provides better feature representations for this task. The reason is that MobileNetV3’s architecture, designed via neural architecture search, is more efficient in capturing relevant features for natural images.

Comparing experiments B and D, the addition of the CA mechanism improves the mAP by 5.21% and accuracy by 11.25%. This substantial improvement indicates that position-sensitive attention is particularly beneficial for detecting small contamination on solar panels, where object boundaries are often subtle and background interference is high. The CA mechanism helps the network focus on discriminative regions, leading to more precise localization.

Comparing experiments C and D, Mosaic augmentation contributes a further 4.3% mAP improvement and 8.1% accuracy improvement. Mosaic augmentation provides diverse contexts by mixing multiple images, which helps the model generalize better to unseen scenes. It also increases the number of objects per training sample, improving the learning of small objects.

The full model achieves the best performance with a mAP of 82.71% and an accuracy of 92.28%, while maintaining a low parameter count of 14.11M and GFLOPs of 13.7. This confirms that all our proposed components are complementary and collectively contribute to an effective lightweight detector.

5.2 Comparison with Other Object Detection Frameworks

We also compared our improved model with several state-of-the-art detectors under the same experimental conditions. We selected Faster R-CNN as a representative two-stage detector, YOLOv3 as a representative single-stage detector, and SSD-ResNet50 as a strong baseline of the SSD family. Table 3 presents the comparison results.

Table 3: Performance comparison of different detectors
Model mAP (%) Accuracy (%) Parameters Model Size (MB) GFLOPs FPS
Faster R-CNN 80.39 89.6 191,385,860 157.5 240.0 3.2
YOLOv3 72.63 82.9 61,524,355 100.6 20.6 21.1
SSD-ResNet50 72.68 78.4 44,553,636 52.4 30.5 23.9
Improved SSD (Ours) 82.71 94.2 14,148,790 18.3 13.8 45.6

Our improved SSD achieves the highest mAP (82.71%) and accuracy (94.2%) among all compared methods. Compared to Faster R-CNN, our model improves mAP by 2.3% and accuracy by 4.6%, while reducing parameters by more than 92% and computation by 94%. The inference speed is 45.6 FPS, which is over 14 times faster than Faster R-CNN (3.2 FPS). This makes our model extremely suitable for real-time UAV-based inspection.

When compared to YOLOv3, our model improves mAP by 10.08% and accuracy by 11.3%. Despite YOLOv3 being a relatively efficient single-stage detector, it still has a parameter count of 61.5M and a model size of 100.6 MB, which is more than five times larger than our 18.3 MB model. Our inference speed is more than double that of YOLOv3, demonstrating the advantage of the MobileNetV3 backbone with the attention mechanism.

Against the SSD-ResNet50 baseline, our model improves accuracy by 15.8% while reducing the model size from 52.4 MB to 18.3 MB and increasing the speed from 23.9 FPS to 45.6 FPS. The mAP improvement is exactly 10.03%. This is a clear indication that the combination of MobileNetV3 and CA is much more effective than the heavier ResNet50 backbone for this task.

5.3 Qualitative Results

To visually assess the performance of our improved algorithm, we compared the detection results on several representative test images. Figure 5 shows the detection result using the original SSD-ResNet50, while Figure 6 shows the result from our improved model. In the original model output, the detector successfully identifies the solar panel and bird droppings, but fails to recognize snow cover correctly and in some cases misclassifies it as a clean panel. Moreover, the original model often misses multiple instances of electrical or physical damage in the same image.

In contrast, our improved model correctly detects all instances of contamination with higher confidence scores. It precisely localizes every defective region, including multiple damaged areas on the same panel. This visual improvement is consistent with the quantitative results, confirming the superiority of our method in both accuracy and robustness.

5.4 Computational Efficiency

The primary motivation for our work is to enable real-time detection on embedded devices carried by UAVs. Table 4 summarizes the computational efficiency of different models in terms of parameter count, model size, GFLOPs, and FPS.

Table 4: Computational efficiency comparison
Model Parameters (M) Model Size (MB) GFLOPs FPS
Faster R-CNN 191.39 157.5 240.0 3.2
YOLOv3 61.52 100.6 20.6 21.1
SSD-ResNet50 44.55 52.4 30.5 23.9
Improved SSD (Ours) 14.15 18.3 13.8 45.6

Our model has the smallest parameter count (14.15M) and the smallest file size (18.3 MB). The computational cost is only 13.8 GFLOPs, which is 68.9% lower than the original SSD-ResNet50 (30.5 GFLOPs). This reduction is achieved without any loss in accuracy; indeed, the accuracy is significantly higher. The inference speed of 45.6 FPS easily meets the real-time requirement of 30 FPS for video processing. On a typical embedded GPU such as an NVIDIA Jetson Xavier NX, our model would be able to run at near real-time speeds with suitable optimization, making it ideal for onboard UAV inspection.

To further understand the efficiency of our model, let us denote the computational complexity of a standard convolution as \(O(H \times W \times C_{in} \times C_{out} \times K^2)\). For depthwise separable convolution, the complexity is:

$$ O(H \times W \times C_{in} \times K^2) + O(H \times W \times C_{in} \times C_{out}) $$

The ratio of standard to depthwise separable convolution is approximately:

$$ \frac{C_{in} \times C_{out} \times K^2}{C_{in} \times K^2 + C_{in} \times C_{out}} = \frac{C_{out} \times K^2}{K^2 + C_{out}} $$

For large output channels \(C_{out}\), this ratio approaches \(K^2\). Thus, using 3×3 depthwise separable convolutions reduces the computation by a factor of about 9 compared to standard 3×3 convolutions. This is the fundamental reason why MobileNetV3 is so efficient.

5.5 Discussion on Limitations and Future Work

While our method achieves impressive results on the self-constructed dataset, there are certain limitations that we acknowledge. First, our dataset is relatively small and collected from a limited number of locations. To further improve generalization, we plan to collect more diverse images from different geographic regions, weather conditions, and solar panel types. Second, we trained our model using only visible light images. Some defects, such as hot spots, are more visible in infrared images. Future work could explore multi-spectral fusion to enhance detection capability. Third, the current model processes each image independently. For video streams, temporal information could be leveraged to improve detection stability and reduce false positives. We intend to incorporate lightweight recurrent units or temporal smoothing in a future study.

Another direction is to deploy our model on an actual UAV embedded system and measure real-world performance. We also plan to apply model quantization (e.g., INT8) to further reduce model size and inference latency, making the detection pipeline even more suitable for edge devices. Finally, we would like to extend the detection framework to handle other photovoltaic defects, such as delamination, micro-cracks, and snail trails, which require finer-grained recognition.

6. Conclusion

In this paper, we have presented a lightweight and accurate object detection method for solar panel contamination based on an improved SSD architecture. Our contributions are threefold. First, we replaced the original SSD backbone with MobileNetV3, significantly reducing the parameter count and computational complexity while maintaining powerful feature extraction. Second, we incorporated a coordinate attention mechanism into the network, which encodes positional information and substantially improves the detection accuracy, especially for small and subtle defects. Third, we adopted Mosaic data augmentation to enhance the diversity of the training data and improve the model’s generalization ability.

Extensive experiments on our custom dataset demonstrated that the proposed method achieves a mAP of 82.71% and an accuracy of 92.28% on the test set, with a computational cost of only 13.8 GFLOPs and a model size of 18.3 MB. The inference speed reaches 45.6 FPS, which is more than sufficient for real-time aerial inspection. Compared to the original SSD, our improved algorithm reduces the computational cost by 68.9%, increases the mean average precision by 4.3%, and nearly doubles the frame rate. Our model also outperforms Faster R-CNN and YOLOv3 in both accuracy and speed while being significantly lighter.

We believe that our lightweight detector can be readily deployed on UAVs for routine inspection of distributed photovoltaic power stations, enabling prompt maintenance and thereby improving overall power generation efficiency. In future work, we plan to extend this approach to multi-spectral imaging and to optimize the model further through quantization and pruning.

Scroll to Top