Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Outputs should attach geometry if available #608

Open
Keenan-Nicholson opened this issue Feb 16, 2024 · 8 comments
Open

Outputs should attach geometry if available #608

Keenan-Nicholson opened this issue Feb 16, 2024 · 8 comments
Assignees
Labels
Feature Request New feature or request good first issue Good for newcomers

Comments

@Keenan-Nicholson
Copy link

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.

@ethanwhite
Copy link
Member

ethanwhite commented Feb 16, 2024

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!)

@Keenan-Nicholson
Copy link
Author

This is exactly what I was looking for, thank you!

I think integration into predict_tile (or both) would make a lot of sense :)

@ethanwhite
Copy link
Member

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.

@ethanwhite ethanwhite reopened this Feb 19, 2024
@ethanwhite
Copy link
Member

@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).

@bw4sz
Copy link
Collaborator

bw4sz commented Feb 19, 2024

okay, I think that's reasonable. As part of the PR #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.

@bw4sz bw4sz self-assigned this Feb 19, 2024
@bw4sz bw4sz added the Feature Request New feature or request label Feb 19, 2024
@bw4sz bw4sz added this to the DeepForest 2.0 milestone Feb 19, 2024
@ethanwhite
Copy link
Member

👍

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.

@ethanwhite ethanwhite added the good first issue Good for newcomers label Mar 18, 2024
@Mu-Magdy
Copy link
Contributor

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

@ethanwhite
Copy link
Member

@Mu-Magdy - sounds good. The basic idea is to allow the use of boxes_to_shapefile() shown in #608 (comment) to be conducted inside of predict_tile() if a new optional argument keep_projection is set to True.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature Request New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

4 participants