Tree Detection Framework (TDF) 🌲is a Python package developed at Open Forest Observatory (OFO) that enables tree detection on realistic scale raster data. This framework was developed to facilitate simplified usage, evaluation, and comparison of existing models and algorithms that detect trees in orthomosaics or raw drone imagery (RGB). As of today, TDF supports four computer vision based detectors including DeepForest, Detectree2, SAM2 and SAM3, and a learning-free detector based on geometric analysis using canopy height models (CHM).
An important functionality of TDF is its ability to do on-the-fly image chip generation for the input raster file. Thanks to torchgeo, we were able to integrate this vital preprocessing functionality seamlessly within the framework. Similarly, TDF also includes a diverse set of postprocessing functions such as non-maximum suppression (NMS), polygon hole suppression, height-based filtering, etc. The output of this workflow is a geopackage file (.gpkg) with detected polygons from each image chip stitched back together in a specified CRS. This framework supports generating detections as points, polygons, or bounding boxes, depending on the user's requirements and the underlying detection method.
This framework has been containerized, and can be used to evaluate multiple detectors across datasets parallelly, to find the best detector with the Argo workflow script.
As the lead developer of this package, one of my favorite parts was going through the entire thought process of designing and developing a Python package for the first time. I was exposed to various new concepts and libraries including geopandas, pytorch lightning, and torchgeo among many others.
Another exciting outcome of this project was getting to work on analyzing and evaluating SAM2 for zero-shot tree detection. I was lucky to collaborate with a team from UC Berkeley and co-author the ICLR Machine Learning for Remote Sensing (ML4RS) Workshop paper in 2025.
M. Chen, D. Russell, A. Pallavoor, D. Young, J. Wu. Zero-Shot Tree Detection and Segmentation from Aerial Forest Imagery. ICLR Machine Learning for Remote Sensing Workshop, Apr 2025, Singapore. (link to manuscript)