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

A plot_results function that works across predict* functions and multiple annotation types. #768

Merged
merged 19 commits into from
Sep 25, 2024

Conversation

bw4sz
Copy link
Collaborator

@bw4sz bw4sz commented Sep 4, 2024

Quick roadmap for a number of visualization related issues.

  • Create a single plot_results function that can take in points, boxes and polygons and plots them using supervision package, optionally saving a plot, and shows the image
  • Confirm no backwards compatibility changes in plot_predictions
  • Update docs to only use plot_results where possible.
  • Make a decision on Consider decoupling plotting from predict_* functions #761 and close.

@bw4sz bw4sz changed the title [WIP] created structure for general viz function Created structure for general viz function Sep 10, 2024
@bw4sz
Copy link
Collaborator Author

bw4sz commented Sep 10, 2024

@ethanwhite this is ready for review. There is one backwards compatibility error. Within the predict_* functions, there is no longer a return_plot argument. This seemed cleaner than adding a deprecation.

@bw4sz
Copy link
Collaborator Author

bw4sz commented Sep 10, 2024

Quick demo is within the doc build see docs/advanced_features/visuzalization.md in the readthedoc build

https://deepforest--768.org.readthedocs.build/en/768/advanced_features/visualizations.html

from deepforest import main, get_data
from deepforest.visualize import plot_results
import os

model = main.deepforest()
model.use_release()

sample_image_path = get_data("OSBS_029.png")
results = model.predict_image(path=sample_image_path)
plot_results(results, root_dir=os.path.dirname(sample_image_path))

@bw4sz bw4sz changed the title Created structure for general viz function A plot_results function that works across predict* functions and multiple annotation types. Sep 10, 2024
@bw4sz
Copy link
Collaborator Author

bw4sz commented Sep 11, 2024

Add root_dir as a class attribute of a prediction dataframe through pandas. Remove the root_dir argument from plot_results.

@bw4sz
Copy link
Collaborator Author

bw4sz commented Sep 11, 2024

Make the visualizations larger. on the markdown document.

deepforest/visualize.py Outdated Show resolved Hide resolved
docs/advanced_features/visualizations.md Outdated Show resolved Hide resolved
docs/data_annotation/annotation.md Outdated Show resolved Hide resolved
docs/getting_started/getting_started.md Outdated Show resolved Hide resolved
docs/getting_started/getting_started.md Show resolved Hide resolved
Copy link
Member

@ethanwhite ethanwhite left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really excellent work @bw4sz and a lot of it. I've done my best to review the whole thing thoroughly. Almost all of the comments are minor cleanup, with the one slightly more major thing being a small change to how multi-class colors are handled. Let me know if you have any questions.

deepforest/main.py Outdated Show resolved Hide resolved
deepforest/main.py Outdated Show resolved Hide resolved
deepforest/main.py Outdated Show resolved Hide resolved
deepforest/main.py Outdated Show resolved Hide resolved
deepforest/main.py Show resolved Hide resolved
docs/getting_started/getting_started.md Outdated Show resolved Hide resolved
tests/test_main.py Outdated Show resolved Hide resolved
tests/test_main.py Outdated Show resolved Hide resolved
tests/test_main.py Outdated Show resolved Hide resolved
tests/test_main.py Outdated Show resolved Hide resolved
@ethanwhite
Copy link
Member

@bw4sz - is this ready for me to give it another look?

@bw4sz
Copy link
Collaborator Author

bw4sz commented Sep 19, 2024 via email

@bw4sz
Copy link
Collaborator Author

bw4sz commented Sep 19, 2024

@ethanwhite I rebased and this should be ready.

Copy link
Member

@ethanwhite ethanwhite left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This all looks great. There was one remaining issue with our color handling in plot_results (my fault, I didn't have the fix quite right in my review). I just submitted a PR against this branch that I think fixes it.

@bw4sz - take a look at that PR and if everything looks good merge it and then we can get this merged.

We were checking results_color, which will typically be a length 3 list.
This would cause incorrect behavior in the presence of multiple labels.
This switches to always creating results_color_sv upfront and checking
it.

Also adds some type/value checks to the input.
@henrykironde henrykironde merged commit e14bc6d into main Sep 25, 2024
5 checks passed
@henrykironde henrykironde deleted the general_viz_function branch September 25, 2024 17:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants