You can use computer vision to identify solar panels in aerial imagery.
Identifying solar panels has a wide range of applications. For example, governments can analyze ordnance surveys to understand how many and where solar panels are used across their country. Insurance companies can use aerial imagery to automatically verify the number of solar panels on houses for new policy holders.
In this guide, we are going to demonstrate how to identify solar panels in aerial imagery with computer vision. This model, trained on 200 images, scores a 70% mean average precision (mAP) score. We will then talk about how the model can be fine-tuned by adding your own data.
Here is an example of the model working on an aerial image to identify solar panels:
We are going to use the Aerial Solar Panels model available on Roboflow Universe. Universe is a community where over 50,000 pre-trained vision models are available for use in computer vision projects. To access this model, you will need a free Roboflow account.
Without further ado, let’s get started!
Step #1: Test the Model
Open the Aerial Solar Panels model on Roboflow Universe. This model has been trained to identify solar panels using aerial images. Click “Model” on the left sidebar to test the model. You will be taken to a page on which you can upload your own data to test. You can also select an image from the Test set that accompanies the model.
Here is an example of the model running on an image from the test set:
The model successfully identifies solar panels in the image.
Step #2: Deploy the Model
With the model ready, we have two options for deployment:
- Use the hosted Roboflow API to run the model in the cloud, and;
- Use Roboflow Inference to run the model on our own hardware.
For this guide, we will show how to use the hosted Roboflow API. With that said, if you want to deploy the model on your own hardware you can do so by following the Roboflow Inference model setup instructions.
To get started with the hosted API, scroll down on the Aerial Solar Panels model page. A code snippet will appear which you can use to run the model. The code snippet will look like this, filled in with your Roboflow API key:
from roboflow import Roboflow
rf = Roboflow(api_key="API_KEY")
project = rf.workspace().project("aerial-solar-panels")
model = project.version(6).model
print(model.predict("your_image.jpg", confidence=40, overlap=30).json())
This code will return predictions from the hosted model. We can visualize our predictions using Supervision, a Python package with utilities for working with computer vision models. Supervision features an extensive API for visualizing model predictions.
Replace “your_image.jpg” with the name of the file on which you want to run inference.
When you run the code, you will see predictions.
Run the following command to install Supervision:
pip install supervision
Update your code to include the following:
import supervision as sv
import cv2
image_name = "image.jpeg"
image = cv2.imread(image_name)
results = model.predict(image_name, confidence=40, overlap=30).json()
detections = sv.Detections.from_inference(results)
bounding_box_annotator = sv.BoundingBoxAnnotator()
label_annotator = sv.LabelAnnotator()
annotated_image = bounding_box_annotator.annotate(
scene=image, detections=detections)
annotated_image = label_annotator.annotate(
scene=annotated_image, detections=detections)
sv.plot_image(annotated_image)
Above, replace image.jpg
with the name of the image you want to run through the solar panel model.
This code will retrieve results from the solar panel API then plot them on the image on which we run inference. The results will be displayed interactively.
Let’s run the code above on an example image. Here are the results:
Our model successfully identified the location of solar panels on the roof.
Next Steps: Improving the Model and Adding Logic
Now that we have a vision model that can identify solar panels, there are a few possible next steps:
- Improve the model using your own data;
- Add the capability to identify houses, and;
- Add your own logic to use the model.
Improve the Model
If the model above does not perform well on your images, we encourage you to export the dataset associated with the model. You can then use the dataset to create your own Roboflow project. This project can use your own data. You will need to label your data, but Roboflow’s automated labeling solution may be able to help you label many, if not most, of the solar panels in your dataset.
To learn more about Roboflow’s automated labeling solution, refer to our guide on automated labeling with Roboflow.
Identify Houses
For some applications, such as insurance valuation, you may need to know how many solar panels are on a specific roof. Even if you have cropped out the region of the property, there may be external solar panels (i.e. those in a garden), or otherwise near the property, that you don’t want to include.
You could update the model we used earlier to also identify roofs. Then, you could use your model to cut out each roof and count the number of solar panels on each roof.
Write Custom Logic
If the model above performs as expected on your data, you can start developing business logic around the model. For example, you can count the solar panels in an image. You can connect your results with an external product (i.e. insurance validation, ordinance surveying) to derive insights relevant to your business. You can monitor trends over time and answer questions like “has the use of solar panels in a city increased in the last year and, if so, to what extent?”
Supervision has a wide range of utilities you can use to analyze and manipulate detections from vision models. For example, you can count detections. You can filter detections by class, box area, confidence, and more.
To see more examples of what you can do with computer vision model predictions, refer to the Roboflow Templates.
Conclusion
You can use computer vision to identify solar panels in aerial imagery.
In this guide, we walked through how to identify solar panels in aerial imagery with computer vision. We used a pre-trained model to identify solar panels then deployed that model using the hosted Roboflow API. The model could also be deployed on your own hardware using Roboflow Inference. We visualized predictions from our model. Finally, we discussed ways that you can improve or add additional functionality to a solar panel detection system.
Cite this Post
Use the following entry to cite this post in your research:
James Gallagher. (Feb 6, 2024). Identify Solar Panels in Aerial Imagery with Computer Vision. Roboflow Blog: https://blog.roboflow.com/identify-solar-panels-in-aerial-imagery/
Discuss this Post
If you have any questions about this blog post, start a discussion on the Roboflow Forum.