-
Notifications
You must be signed in to change notification settings - Fork 709
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
Bugfix code logic to allow for passing of nn.Module
to TorchFXFeatureExtractor
#935
Conversation
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.
Thanks @ORippler! I have a single comment only. I'll let @ashwinvaidya17 review the PR.
Co-authored-by: Samet Akcay <[email protected]>
Specify that only nn.Module class objects are acceptable, see https://docs.python.org/3/library/typing.html#typing.Type
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.
Thanks for spotting and addressing this! Can you add the example to the tests as well https://github.com/openvinotoolkit/anomalib/blob/main/tests/pre_merge/models/test_feature_extractor.py#L47. Just add it at the end. I'll refactor that test later on and split each torchfx tests.
create_feature_extractor only returns `GraphModule` objects https://pytorch.org/vision/stable/generated/torchvision.models.feature_extraction.create_feature_extractor.html#torchvision.models.feature_extraction.create_feature_extractor
We now instantiate the model from class as intended for local loading
I would suggest changing |
The idea was to allow jsonargparse to deserialize the the backbone class . This would allow us to use the Lightning CLI. But yeah. This whole thing needs some revisit. We are also planning on deprecating timm feature extractor. So this will change a bit |
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.
Thanks. I am fine with the changes.
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.
Thanks again for your contribution!
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## main #935 +/- ##
=======================================
Coverage 86.77% 86.77%
=======================================
Files 165 165
Lines 6319 6322 +3
=======================================
+ Hits 5483 5486 +3
Misses 836 836
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
Description
Provide a summary of the modification as well as the issue that has been resolved. List any dependencies that this modification necessitates.
Fix code logic to allow for passing of
nn.Module
toTorchFXFeatureExtractor
Fixes [Bug]: TorchFXFeatureExtractor Does not handle
nn.Module
passed to __init__ properly #933Changes
Checklist