Improved SSD Algorithm for Lightweight Solar Panel Contamination Detection

In the rapidly expanding field of photovoltaic energy, the efficiency of solar panels is critically dependent on their surface cleanliness. Contaminants such as bird droppings, dust, snow, and physical defects can significantly reduce power output. Unmanned aerial vehicles (UAVs) equipped with visible-light cameras are increasingly used for routine inspection of large-scale solar farms. However, the limited computational power of onboard embedded systems imposes strict constraints on the complexity of deep learning models. Existing defect detection architectures, such as the original SSD with ResNet50 backbone, are often too heavy and slow for real-time deployment. To address this, I propose a lightweight detection framework based on an improved SSD algorithm, specifically designed for detecting various contaminations on solar panels. The core innovations include replacing the backbone with MobileNetV3 to drastically reduce parameters, integrating a coordinate attention (CA) mechanism to enhance feature extraction, and applying Mosaic data augmentation to improve generalization. Experimental results demonstrate that the proposed method achieves a superior balance between accuracy and speed, making it highly suitable for UAV-based inspection of solar panels.

Figure 1: Example of a solar panel array with surface contamination. The image illustrates typical defects that require automated detection.

This work focuses on developing a practical solution for real-world photovoltaic stations. The primary challenges are threefold: (1) the need for high detection accuracy across diverse defect types, (2) the requirement for extremely low computational cost to run on embedded devices, and (3) the demand for real-time processing speeds above 30 FPS. The original SSD algorithm, while efficient, still suffers from high parameter counts when using conventional backbones. By employing MobileNetV3 as the feature extractor, the model size and FLOPs are significantly reduced without sacrificing representational power. Furthermore, the introduction of the CA mechanism allows the network to focus on discriminative regions of the feature maps, compensating for the reduced capacity of the lightweight backbone. Mosaic data augmentation, which randomly combines four training images into one, effectively expands the limited dataset and improves robustness against variations in lighting, scale, and orientation of contaminants on solar panels.

Related Work and Theoretical Foundations

SSD Object Detection Framework

The Single Shot MultiBox Detector (SSD) is a one-stage detector that predicts object categories and bounding box offsets directly from feature maps of different scales. The loss function consists of a localization loss (smooth L1) and a confidence loss (softmax cross-entropy):

$$
L = \frac{1}{N} \left( L_{conf} + \alpha L_{loc} \right)
$$

$$
L_{loc} = \sum_{i \in Pos} \sum_{m \in \{cx,cy,w,h\}} \text{smooth}_{L1}(l_i^m – \hat{g}_j^m)
$$

$$
L_{conf} = -\sum_{i \in Pos} \hat{c}_i^p \log(c_i^p) – \sum_{i \in Neg} \log(c_i^0)
$$

where \(N\) is the number of matched default boxes, \(\alpha\) is a weight (default 1), \(Pos\) and \(Neg\) denote positive and negative samples, \(l_i\) and \(\hat{g}_j\) are predicted and ground-truth offsets respectively, and \(c_i^p\) is the predicted probability for class \(p\).

In our improved version, the original VGG-16 backbone is replaced by MobileNetV3-Large. The extra convolutional layers are designed to produce feature maps of sizes 19×19, 10×10, 5×5, 3×3, 2×2, and 1×1, enabling multi-scale detection of contaminations on solar panels such as tiny bird droppings or large snow patches.

MobileNetV3 Backbone

MobileNetV3 combines depthwise separable convolutions with a hardware-aware network architecture search. The core building block is the inverted residual bottleneck with linear bottlenecks, as illustrated in Figure 2 of the original paper. The structure expands the channels using a 1×1 convolution, applies a 3×3 depthwise convolution, and then projects back to a lower dimension. This design significantly reduces parameters. The activation functions include h-swish and ReLU6, which are efficient on mobile devices. The total number of parameters for MobileNetV3-Large is only about 5.4 million, compared to over 44 million for ResNet50.

Coordinate Attention Mechanism

The Coordinate Attention (CA) mechanism enhances the representation of feature maps by encoding positional information into channel attention weights. Unlike SENet which uses global average pooling to squeeze spatial dimensions into a single vector, CA decomposes global pooling into two separate 1D feature encoding operations: one along the horizontal direction and one along the vertical direction. Given an input feature tensor \(X \in \mathbb{R}^{H \times W \times C}\), the CA module computes two attention maps:

$$
A_h = \sigma( W_h [E_h, X]^T )
$$

$$
A_w = \sigma( W_w [E_w, X]^T )
$$

where \(E_h\) and \(E_w\) are coordinate embeddings, \(W_h\) and \(W_w\) are learned weights, and \(\sigma\) denotes the sigmoid function. The final output is \(Y = X \cdot A_h \cdot A_w\). This mechanism allows the network to capture long-range spatial dependencies with minimal computational overhead, which is crucial for accurately localizing defects on solar panels that may appear at various positions.

Mosaic Data Augmentation

To improve generalization and address the limited size of our self-collected dataset, we adopt Mosaic augmentation. This technique randomly selects four images from the training set, applies random scaling, rotations, cropping, and color jitter to each, and then combines them into a single composite image of size 300×300. The label information is preserved by adjusting bounding boxes accordingly. This approach exposes the model to a wider variety of backgrounds, object scales, and partial occlusions, making it more robust when inspecting solar panels under diverse field conditions.

Proposed Method: Improved SSD with MobileNetV3 and CA

The overall architecture of the proposed model is shown in Figure 1 (in the original paper, but here we describe it textually). The input image is first resized to 300×300 pixels. It then passes through the MobileNetV3-Large backbone, which outputs feature maps at multiple stages. We select the last layer of the backbone as the starting point for additional convolutional layers. Six feature maps with sizes 19×19, 10×10, 5×5, 3×3, 2×2, and 1×1 are used for prediction. Each feature map is processed by two parallel 3×3 convolutional branches: one for class scores (number of classes + background) and one for bounding box offsets (4 per default box). The CA module is inserted after the last convolutional layer of each prediction branch to refine the attention before classification and regression. Non-maximum suppression (NMS) with an IoU threshold of 0.5 is applied to eliminate duplicate detections.

The key modifications compared to the standard SSD are:

Component Standard SSD Proposed Improvement
Backbone VGG-16 or ResNet50 MobileNetV3-Large
Attention None Coordinate Attention (CA)
Data Augmentation Random crop, flip Mosaic + Random flip, color jitter
Input size 300×300 300×300 (same)

These changes lead to a dramatic reduction in model complexity. The number of parameters drops from 44.6 million (ResNet50) to 14.1 million (ours), and the floating-point operations (GFLOPS) decrease from 30.5 to 13.7. This makes the model suitable for GPU-constrained embedded systems like NVIDIA Jetson or even some edge AI accelerators.

Experiments and Results

Dataset Preparation

Since there is no publicly available visible-light solar panel contamination dataset with annotations, I constructed my own dataset following the Pascal VOC format. The dataset contains 6 categories: clean panels, bird droppings, dust/dirt, electrical damage, physical damage (cracks), and snow. A total of 7,889 images were collected. The split is 80% training, 10% validation, and 10% testing. The distribution is shown in Table 1.

Table 1: Dataset distribution of solar panel contamination images
Category Training Validation Test Total
Clean 591 119 135 845
Bird droppings 614 167 180 961
Dust/dirt 1,124 105 83 1,312
Electrical damage 170 34 35 239
Physical damage 374 24 33 431
Snow 1,179 189 172 1,540
Total 6,136 638 638 7,889

The images were collected from various sources including drone flights over actual photovoltaic plants and online databases. All bounding boxes were manually annotated. Mosaic augmentation was applied only to the training set to artificially increase diversity.

Experimental Setup

The experiments were conducted on a workstation with an Intel Xeon E5-2683 v4 CPU and an NVIDIA GeForce RTX 3060 GPU with 12 GB memory. The software environment included Ubuntu 18.04, Python 3.8, and PyTorch 1.10. The input size was fixed at 300×300. The batch size was 32, and the total number of training epochs was 300. The optimizer was Stochastic Gradient Descent (SGD) with momentum 0.9 and weight decay 0.0005. The initial learning rate was 0.01, and a cosine annealing scheduler was used to periodically reduce the learning rate to improve convergence. The momentum parameter helped accelerate gradients in consistent directions.

Evaluation Metrics

Several metrics were used to evaluate the model’s performance:

  • mAP (mean Average Precision): Computed on the validation set using the standard Pascal VOC 2012 metric (IoU threshold 0.5).
  • Accuracy: Overall pixel-level accuracy computed on the test set (correctly predicted pixels over total pixels).
  • Parameters: Total number of trainable parameters (in millions).
  • GFLOPS: Giga floating-point operations per second (inference cost).
  • Model Size: Storage size of the frozen PyTorch model (in MB).
  • FPS: Frames per second measured on the RTX 3060 at batch size 1.

Ablation Study

To verify the contribution of each component, I performed a series of ablation experiments. The results are summarized in Table 2.

Table 2: Ablation study results. Y = used, N = not used.
Exp Backbone CA Mosaic mAP (%) Accuracy (%) Params (M) GFLOPS
A ResNet50 N Y 72.68 78.43 44.55 30.5
B MobileNetV3 N Y 77.50 81.03 14.11 13.7
C MobileNetV3 Y N 78.41 84.11 14.11 13.7
D MobileNetV3 Y Y 82.71 92.28 14.11 13.7

Comparing Experiment A (ResNet50 + Mosaic) and Experiment B (MobileNetV3 + Mosaic): replacing the backbone with MobileNetV3 reduced parameters by 68.3% and GFLOPS by 55.1%, while surprisingly increasing mAP by 4.82% and accuracy by 2.6%. This indicates that the lightweight backbone not only saves computation but also avoids overfitting on this particular dataset. Comparing Experiment B (no CA) and Experiment D (with CA): adding the CA mechanism improved mAP by 5.21% and accuracy by 11.25%, demonstrating that attention is highly effective in boosting detection quality for solar panels. Comparing Experiment C (no Mosaic) and Experiment D (with Mosaic): Mosaic augmentation contributed a 4.3% increase in mAP and 8.1% increase in accuracy, confirming its role in improving generalization. The final model (D) achieves 82.71% mAP and 92.28% accuracy with only 14.1 million parameters and 13.7 GFLOPS.

Comparison with Other Detection Frameworks

I also compared the proposed model with several popular object detectors: Faster R-CNN with ResNet50, YOLOv3, and the original SSD with ResNet50. All models were trained and tested on the same dataset with identical training settings (where applicable). The results are shown in Table 3.

Table 3: Performance comparison of different object detection models.
Model mAP (%) Accuracy (%) Params (M) Model Size (MB) GFLOPS FPS
Faster R-CNN (ResNet50) 80.39 89.6 191.4 157.5 240.0 3.2
YOLOv3 (Darknet53) 72.63 82.9 61.5 100.6 20.6 21.1
SSD (ResNet50) 72.68 78.4 44.6 52.4 30.5 23.9
Proposed (MobileNetV3+CA+Mosaic) 82.71 94.2 14.1 18.3 13.8 45.6

The proposed model outperforms all compared methods. Compared to Faster R-CNN, it achieves higher mAP (82.71% vs 80.39%) and accuracy (94.2% vs 89.6%) while being 14× smaller in parameters and 75× faster in FLOPs. The inference speed of 45.6 FPS is more than sufficient for real-time UAV video streams (typically 25-30 FPS). In contrast, the original SSD with ResNet50 runs at only 23.9 FPS and has lower accuracy. YOLOv3, despite being a one-stage detector, is outperformed by the proposed model by 10.08% in mAP and 11.3% in accuracy, and the proposed model is 2.2× faster (45.6 vs 21.1 FPS). These results highlight the effectiveness of the combined lightweight design and attention mechanism for detecting contaminants on solar panels.

Qualitative Detection Results

In addition to quantitative metrics, I visually inspected the detection outputs. The original SSD (ResNet50) sometimes missed small bird droppings or misclassified snow as clean panels. In contrast, the proposed model consistently detected all defect types with high confidence. For example, in a scene with snow covering parts of the solar panels, the original model failed to recognize the snow region, while the improved model correctly identified it and also located multiple electrical damage spots. The confidence scores were also noticeably higher, indicating better feature learning.

Conclusion

In this work, I presented a lightweight and efficient deep learning model for detecting surface contamination on solar panels. By replacing the heavy backbone of SSD with MobileNetV3, introducing a coordinate attention mechanism, and applying Mosaic data augmentation, the proposed method achieves a remarkable balance between accuracy and computational efficiency. The model reduces parameters by 68.3% and GFLOPS by 55.1% compared to SSD with ResNet50, while improving mAP by 10.03% (from 72.68% to 82.71%) and accuracy by 15.8% (from 78.4% to 94.2%). The inference speed reaches 45.6 FPS, making it feasible for real-time drone-based inspection of large photovoltaic plants. The ablation study confirms that each component contributes positively. The comparison with Faster R-CNN and YOLOv3 further demonstrates the superiority of the proposed approach. Future work could explore quantization and pruning to further reduce model size for deployment on even more constrained microcontrollers, or extend the dataset to include more defect types such as snail trails and PID effect. The ultimate goal is to enable autonomous UAV systems to rapidly identify and localize any contamination on solar panels, thereby maximizing energy yield and reducing maintenance costs for solar power stations.

Scroll to Top