Outputs should attach geometry if available
Currently the output method is a simple plot and boxes.head() will give x_min x_max y_min y_max bounding boxes around detections. It would be great if, in the case the input image has geometry (i.e., .tiff images), the output also contain the geometry.
This way the image and detections can be referenced on a map easily without the need for post process georeferencing.
Thanks for the request @Keenan-Nicholson
Is the boxes_to_shapefile() function (not heavily documented, but some docs here) what you're looking for?
from deepforest import main
from deepforest import get_data
from deepforest.utilities import boxes_to_shapefile
model = main.deepforest()
model.use_release()
raster_dir = get_data("")
raster_path = get_data("OSBS_029.tif")
predictions = model.predict_tile(raster_path, return_plot = False, patch_size=300, patch_overlap=0.25)
predictions_projected = boxes_to_shapefile(predictions, raster_dir)
Or were you thinking that it should be integrated into predict_tile() (or both!)
This is exactly what I was looking for, thank you!
I think integration into predict_tile (or both) would make a lot of sense :)
Glad that took care of it for you @Keenan-Nicholson! I'm going to reopen this to facilitate a quick discussion on integrating into predict tile.
@bw4sz any objections to adding an optional argument in predict_tile() to return the boxes in the original projection? Maybe keep_projection = True (defaulting to False for backwards compatibility).
okay, I think that's reasonable. As part of the PR https://github.com/weecology/DeepForest/pull/590 may touch on this in places, but we can deal with that as we merge farther down the road. Let's add this 2.0 milestone, it should be pretty straightfoward. In general, i'm not sure when we want to have both geometry types in the dataframe for that PR. Lots of users come without projected data, so it can be annoying to make sense of this for all users.
:+1:
Lots of users come without projected data, so it can be annoying to make sense of this for all users.
I think this observation supports the idea of it being an optional argument defaulting to false. If you have projected data you'll go looking for it in the function docs, if you don't have projected data you won't even think about it and things will just work as expected.
Hi @ethanwhite
I don't know if I understand what do you need to implement here correctly, but I will make a new PR to discuss it more
@Mu-Magdy - sounds good. The basic idea is to allow the use of boxes_to_shapefile() shown in https://github.com/weecology/DeepForest/issues/608#issuecomment-1949274863 to be conducted inside of predict_tile() if a new optional argument keep_projection is set to True.
I think this is completed based #1004 (I think it was this issue)