This repository includes the methods developed and described in Puliti and Astrup (2022).
Please note that this is a repository developed two years ago and it might require some fixing :)
The methods heavily relies on the YOLOv5 repo by Ultralytics for training the object detector and for inference.
However, the method was re-adapted to allow working with georeferenced drone RGB orthomosaics. To do so the full pipeline can be subdivided in the following steps:
- splitting them into overlapping tiles
- predicting on each tile
- converting bounding box coordinates from image to map space
- aggrregating the predictions for all tiles to produce a wall-to-wall layer (see image below) as a shapefile or GeoJSON
clone repo
git clone https://github.com/SmartForest-no/SmartForest_UAV_damage_detection
cd SmartForest_UAV_damage_detection
create new environment
conda create -n SmartForest_UAV_damage_detection python=3.10
conda activate SmartForest_UAV_damage_detection
Install required packages
- Install gdal (this step might require some fiddling around :) Always fun to install gdal :))
conda install -c conda-forge gdal=3.4.0
- Other required packages
pip install pandas
pip install fiona
pip install shapely
pip install pyproj
pip install geopandas
pip install geopandas==0.10.2
pip install rasterio==1.2.10
# not sure if there are missing ones from the full requirements
pip install -r requirements.txt
In addition:
- Download model weights (*.pt format) at: https://drive.google.com/drive/folders/1SnNRdGXhBFhAyPMKIcxklmw9FTFAp3DI?usp=sharing
- Unzip the two files and place them in the model_zoo folder
The input is a (high resolution; <= 3-4 cm) georeferenced RGB orthomosaic in GeoTIFF format.
The output is a multi-polygon vector layer (either shapefile or GeoJSON) covering the entire area (tiles that are on the edges of the orthomosaic are removed from predictions). Each polygon consists of the predicted bounding box for a single tree and is associated with the following fields:
- class: predicted class (healthy, broken, dead)
- prob: predicted probability
model_name | description | Classes |
---|---|---|
yolov5x_damage_img640_healthy_broken_dead.pt | model used in the original snowbreak detection paper | healthy, broken-top, dead |
yolov5x_damage_im1280_batch2_healthy_broken_dead_recentDead.pt | retrained model with more bark-beatle affected areas | healthy, broken-top, dead, recently dead |
- We suggested using the second model as it is the latest version and it has more training data on dead-tree detection (Bark-beetles).
You can follow the example reported in 'ObjectDetection_damage.ipynb'