Detecting solar panels from satellite images (github)

Goal of this project is to deliver segmentation masks of solar panel farms using satellite images. Due to large varieties of the images, I decided to use deep segmentation/PyTorch.


Data preparation/cleaning was intensive. Most labels were provided thought quality was not ideal. Nevertheless, I am grateful for what seems to have been a painful labeling job. I also generated some labels using LabelMe. I first split several large (~1GB) satellite images into smaller ones (256x256 size). There were 449 labels of 3 classes: racks, common panels, and dense panels:

label1.png label2.png label3.png


It was insightful to plot mean and standard deviation of labeled and unlabeled images to identified range for ColorJitter as augmentation: normalization.png

Labeled and unlabeled data have decent overlap, with non-covered datapoints typically being clouds (high mean, low stdev) or with partial out-of-bounds, i.e. black, zones (low mean). See for examples.


I used Adam optimizer and weighed CrossEntropyLoss. Segmentation was based on UNet-like arhitecture and this paper (see


Training for 120 epoch took about 6 minutes (RTX5000). Achieved 71% Jaccard index (aka IoU) on validation dataset.


Finally, I evaluated and stitched together predicted images back into large satellite images (size ~1Gb, showing here only smaller section):


(Note: some missing patches in the image were used for training).

Shadows and clouds are probably the biggest obstacle for precise counting. While augmentations can help to some extent, ideally multiple images of the same solar farm should be obtained and combined for thorough coverage.

The following are some notable examples.

Handling multiple classes:

img_2.png img_3.png img_6.png img_8.png

Handling different backgrounds:

img_4.png img_7.png img_17.png img_10.png

And here are the common failures, mostly shades and clouds:

img_9.png img_11.png img_13.png img_15.png img_16.png img_18.png img_19.png


Object segmentation has shown to perform well for solar panel detection. Augmentation using brightness and contrast improved detection significantly.

Number of solar panels is calculated knowing pixel resolution is 50cm/pixel and panels width of about 100 cm (i.e. 2 pixels).

Small edge improvements can be done by allowing for some overlap when cropping large images and combining masks subsequently.

References: Boiler-plate code based on a book “PyTorch: Step by Step” by Daniel Voigt Godoy.