This script is designed to perform the detection and segmentation of photovoltaic installations in aerial images using trained YOLOv8 models to estimate the surface area of the detected photovoltaic installations. The training and validation set have been created using aerial images of the Canton of Zurich, Switzerland.
git clone https://github.com/mattdepaolis/PV_AreaEstimator.git
cd PV_AreaEstimator
Then download the folders containing the pre-trained classification model and segmentation model for the photovoltaic installation detection and segmentation task and move them to the folder PV_AreaEstimator.
YOLOv8 detection model
YOLOv8 segmentation model
Install the required packages:
pip install -r requirements.txt
Command Line Execution:
python _PV_AreaEstimator.py --folder-path <path_to_images> --detection-model <path_to_detection_model> --segmentation-model <path_to_segmentation_model> [optional arguments]
Arguments:
--folder-path: Path to the folder containing the aerial images for processing.
--detection-model: Path to the trained detection YOLO model.
--segmentation-model: Path to the trained segmentation YOLO model.
--confidence-detection: Confidence threshold for the detection model (default: 0.1).
--confidence-segmentation: Confidence threshold for the segmentation model (default: 0.25).
--img-size: Size for image resizing (default: 640).
--tilt-angle: Tilt angle of the photovoltaic installation in degrees (default: 30).
Since the image was taken from a bird's eye view, it is necessary to specify the tilt angle of the installation to calculate the area of the solar installation. If the tilt angle is unknown, a tilt angle of 30 degrees is assumed. This corresponds to the optimal tilt angle based on the latitude of the given location. In the presented case it is 30 degrees.
The training and validation sets used were created based on orthophotos of the Canton of Zurich and are available for download for further research at the following links:
Training and Validation Set for PV Detection
Training and Validation Set for PV Segmentation
The script will visualize the aerial images, the prediction masks, and the estimated photovoltaic installation surface areas in square meters for each image.
Left: Original image. Center: YOLOv8 output. Right: Surface area estimation