open-forest-observatory / tree-detection-framework

BSD 3-Clause "New" or "Revised" License
3 stars 0 forks source link

Add SAM2 detector #46

Open russelldj opened 2 weeks ago

russelldj commented 2 weeks ago

As we talked about with @janehwu and Michelle, the segment anything model v2 has a lot of potential to be used for tree detection. It would be helpful to integrate it into this framework as an additional detection method. An example detection workflow notebook can be found on this PR (#44) and the example data used in it can be found in this folder.

The main thing that needs to happen is creating a Detector subclass for SAM2. In this class, you'll need to implement the predict_batch method and match the type signature described in the docstring. An example for the DeepForest detector is here. If your predictions are generated as a binary mask and not a polygon, you may find this function helpful: mask_to_shapely.

Finally, we only have nonmax suppression implemented for rectangular bounding boxes but we also need to support polygons. This issue (#39) explains the considerations.

russelldj commented 2 weeks ago

One more thing. It's important to see if we can get all the dependencies to work together. If possible, dependencies should in installed using poetry, which handles sub-dependency resolution in an effective way. This is done with the poetry add <dependency name> command. If the dependency can't be installed with poetry, you can document the steps to install it using conda/pip. This should occur after the poetry install command has been run.

russelldj commented 2 weeks ago

The notebook is now merged to here.