-
Notifications
You must be signed in to change notification settings - Fork 636
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
Exclude classes from inference using pretrained or custom models #1104
Conversation
…ls on SAHI - Pull request 1. This feature allows to perform 'predict', 'get_sliced_prediction', and 'get_prediction' inserting a new custom parameter. An example is provided in the code 'test_exclude_classes.py'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only one thing missing is adding these new parameters into the methods definitions (the comments explaining the parameters, and not adding it to the method as parameter, which has been already done), it is not such a huge issue to deal with. Waiting for your review and approval.
I updated the code and workflow also using both black and isort. Waiting for your approval. |
I removed the test on exclude classes cause it was inserting conflicts on the tests levels. I am waiting for your approval |
Hi @fcakyon, If there is any other feature or things I can do to enhance the project, please let me know or contact me privately, if necessary. Thanks. |
Thanks for the work @gguzzy ! We can work to merge your PR after this project refactor PR 👍🏻 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Overview
This PR introduces new optional parameters to exclude specific classes from inference results, which can be used with pretrained and custom models. Key changes include the addition of a filter_predictions helper function and modifications to prediction functions (get_prediction, get_sliced_prediction, predict, and predict_fiftyone) to support the exclusion of classes by name or ID.
Reviewed Changes
File | Description |
---|---|
sahi/predict.py | Added filter_predictions function and integrated optional exclusion parameters into methods |
Copilot reviewed 1 out of 1 changed files in this pull request and generated 4 comments.
Comments suppressed due to low confidence (2)
sahi/predict.py:73
- [nitpick] The parameter name 'exclude_classes_by_name' differs from the PR description ('exclude_classes_names'). Aligning the naming will improve clarity and consistency.
exclude_classes_by_name: Optional[List[str]] = None,
sahi/predict.py:74
- [nitpick] The parameter name 'exclude_classes_by_id' differs from the PR description ('exclude_classes_id'). Consider renaming it to maintain consistency with the documentation.
exclude_classes_by_id: Optional[List[int]] = None,
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@gguzzy all tests pass! Can you please add some simple examples of usage for your newly added parameters in this md file? https://github.com/obss/sahi/blob/main/docs/predict.md |
Hello dear all,
I am writing you to share and open a PR to include in your framework the option to exclude certain classes from inferences/predictions performed, since I found this useful in general.
This allows us to exclude predictions which are not considered by a custom user.
This can be done by using two new optional parameters which are: exclude_classes_names and exclude_classes_id.
Recall to use the same notation for class names and ids accordingly to the loaded model.
I introduced an example which shows the usage of the new parameter, added to folder tests as test_exclude_classes.py'
The methods which include the new parameters are the ones which are responsible for predictions, which are 'prediction, get_sliced_prediction, get_prediction' and their respective usages inside the 'predict.py' class.