Tree crown delineation using detectreeRGB
Tree crown delineation using detectreeRGB¶
Forest Modelling Standard Python
Accurately delineating trees using
detectron2, a library that provides state-of-the-art deep learning detection and segmentation algorithms.
An established deep learning model, Mask R-CNN was deployed from
detectron2 library to delineate tree crowns accurately. A pre-trained model, named
detectreeRGB, is provided to predict the location and extent of tree crowns from a top-down RGB image, captured by drone, aircraft or satellite.
detectreeRGB was implemented in
python 3.8 using
pytorch v1.7.1 and
detectron2 v0.5. Further details can be found in the repository documentation.
detectreeRGB advances the state-of-the-art in tree identification from RGB images by delineating exactly the extent of the tree crown.
We demonstrate how to apply the pretrained model to a sample image fetched from a Zenodo repository.
Our pre-trained model was developed using aircraft images of tropical forests in Malaysia.
The model can be further trained using the user’s own images.
The project was supported by the UKRI Centre for Doctoral Training in Application of Artificial Intelligence to the study of Environmental Risks (AI4ER) (EP/S022961/1).
The authors acknowledge the authors of the Detectron2 package which provides the Mask R-CNN architecture.
import cv2 from PIL import Image import os import numpy as np import urllib.request import glob # intake library and plugin import intake from intake_zenodo_fetcher import download_zenodo_files_for_entry # geospatial libraries import geopandas as gpd from rasterio.transform import from_origin import rasterio.features import fiona from shapely.geometry import shape, mapping, box from shapely.geometry.multipolygon import MultiPolygon # machine learning libraries from detectron2 import model_zoo from detectron2.engine import DefaultPredictor from detectron2.utils.visualizer import Visualizer, ColorMode from detectron2.config import get_cfg from detectron2.engine import DefaultTrainer # visualisation import holoviews as hv import geoviews.tile_sources as gts import matplotlib.pyplot as plt import hvplot.pandas import hvplot.xarray import warnings warnings.filterwarnings(action='ignore') hv.extension('bokeh', width=100)