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

✨ Add torchfx feature extractor #675

Merged
merged 22 commits into from
Nov 25, 2022

Conversation

ashwinvaidya17
Copy link
Collaborator

@ashwinvaidya17 ashwinvaidya17 commented Nov 3, 2022

Description

This PR only introduces torchfx. For other refactor see #717

  • Add torchfx feature extractor
  • Rename existing one to timm
  • Add custom backbone support in TorchFX feature extractor

Changes

  • New feature (non-breaking change which adds functionality)

Checklist

  • My code follows the pre-commit style and check guidelines of this project.
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing tests pass locally with my changes

@openvinotoolkit openvinotoolkit deleted a comment from djdameln Nov 4, 2022
Copy link
Contributor

@samet-akcay samet-akcay left a comment

Choose a reason for hiding this comment

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

Another comment would be that this PR would break the backward compatibility due to the removal of FeatureExtractor. It would be good to still support it such that when the user tries to import from anomalib.models.components import FeatureExtractor it would inherit TimmFeatureExtractor but throws a deprecation warning.

@ashwinvaidya17
Copy link
Collaborator Author

ashwinvaidya17 commented Nov 8, 2022

Another comment would be that this PR would break the backward compatibility due to the removal of FeatureExtractor. It would be good to still support it such that when the user tries to import from anomalib.models.components import FeatureExtractor it would inherit TimmFeatureExtractor but throws a deprecation warning.

Good point

@jpcbertoldo jpcbertoldo mentioned this pull request Nov 8, 2022
12 tasks
@github-actions github-actions bot added the Tools label Nov 18, 2022
Copy link
Contributor

@samet-akcay samet-akcay left a comment

Choose a reason for hiding this comment

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

Thanks @ashwinvaidya17 for your great effort! Only minor comments

@samet-akcay samet-akcay requested review from jpcbertoldo and djdameln and removed request for jpcbertoldo November 22, 2022 14:28
Copy link
Contributor

@samet-akcay samet-akcay left a comment

Choose a reason for hiding this comment

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

Thanks for addressing my comments

Copy link
Contributor

@djdameln djdameln left a comment

Choose a reason for hiding this comment

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

Thanks, just one suggestion for improving the unit tests.

@@ -39,6 +42,32 @@ def test_feature_extraction(self, backbone, pretrained):
else:
pass

def test_torchfx_feature_extraction(self):
Copy link
Contributor

@djdameln djdameln Nov 24, 2022

Choose a reason for hiding this comment

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

Maybe add a test case for creating a feature extractor from a local model definition, and a string to a weights file. That way we would have a more complete coverage of the possible use cases of the class.

We could use a dummy model consisting of a few convolutional layers and a corresponding weights file.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I've added functionality to directly pass locally defined class + tests for it

Copy link
Contributor

@djdameln djdameln left a comment

Choose a reason for hiding this comment

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

Thanks!

@ashwinvaidya17 ashwinvaidya17 merged commit 0bf9706 into main Nov 25, 2022
@ashwinvaidya17 ashwinvaidya17 deleted the ashwin/add_tochfx_feature_extractor branch November 25, 2022 07:42
@jpcbertoldo
Copy link
Contributor

sorry @ashwinvaidya17 i couldn't find the time to review this one

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants