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

Refactor feature extraction key #748

Merged

Conversation

ashwinvaidya17
Copy link
Collaborator

Description

  • All backbone/feature extraction keys are now in
model:
    feture_extractor:
        backbone:
        layers:
  • FeatureExtractor selects timm or torchfx based on the parameters passed to it.
  • This PR ended up way bigger than I thought 😃

Changes

  • Bug fix (non-breaking change which fixes an issue)
  • Refactor (non-breaking change which refactors the code base)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

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

@github-actions github-actions bot added the Tests label Nov 30, 2022
Copy link
Contributor

@jpcbertoldo jpcbertoldo left a comment

Choose a reason for hiding this comment

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

great effort, thanks!

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. I had a close look at the design and I have some concerns, which are outlined below, along with some minor comments.

anomalib/models/stfpm/config.yaml Outdated Show resolved Hide resolved
anomalib/models/reverse_distillation/torch_model.py Outdated Show resolved Hide resolved
anomalib/models/patchcore/torch_model.py Outdated Show resolved Hide resolved
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.

Similar to what @djdameln raised, my primary concern is the following line in torch_model.py and lightning_model.py:

feature_extractor: FeatureExtractorParams

feaature_extractor variable actually contains feature extractor parameters. Storing these as feature_extractor causes a confusion since the codebase has so many feature_extractor here and there.

anomalib/models/cflow/lightning_model.py Show resolved Hide resolved
anomalib/models/components/feature_extractors/wrapper.py Outdated Show resolved Hide resolved
anomalib/models/components/feature_extractors/wrapper.py Outdated Show resolved Hide resolved
anomalib/models/components/feature_extractors/wrapper.py Outdated Show resolved Hide resolved
anomalib/models/components/feature_extractors/wrapper.py Outdated Show resolved Hide resolved
anomalib/models/stfpm/torch_model.py Outdated Show resolved Hide resolved
@samet-akcay
Copy link
Contributor

This is way too much effort for a part that we plan to deprecate. Really appreciate your effort @ashwinvaidya17 !

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, huge improvement now that one layer of wrapper has been removed. I am not 100% convinced that we need the wrapper design at all, since the functionality added by the wrapper classes is only used for the construction of the model. But to speed things up, let's stick with this design for now. We can revisit the design once we deprecate timm.

anomalib/models/components/feature_extractors/wrapper.py Outdated Show resolved Hide resolved
anomalib/models/components/feature_extractors/wrapper.py Outdated Show resolved Hide resolved
anomalib/models/components/feature_extractors/timm.py Outdated Show resolved Hide resolved
@github-actions github-actions bot added Callbacks CI Config Dependencies Pull requests that update a dependency file HPO Inference Tools labels Dec 8, 2022
@jpcbertoldo
Copy link
Contributor

Is there a github discussion/issue from which one can read why

"TimmFeatureExtractor will be removed in the future version."

?

@samet-akcay
Copy link
Contributor

Is there a github discussion/issue from which one can read why

"TimmFeatureExtractor will be removed in the future version."

?

@jpcbertoldo, we have recently spotted that timm feature extractor provides inconsistent results, which overall adversely impact the performance of the models. We therefore decided to use torchfx feature extractor

@ashwinvaidya17
Copy link
Collaborator Author

Is there a github discussion/issue from which one can read why

"TimmFeatureExtractor will be removed in the future version."

?

I've gathered our motivation here #779

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 two minor comments left:

@@ -3,14 +3,16 @@
# Copyright (C) 2022 Intel Corporation
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this module be called feature_extraction? This would be more in line other modules under models.components (e.g. dimensionality_reduction and sampling)

anomalib/models/components/feature_extractors/utils.py Outdated Show resolved Hide resolved
@github-actions github-actions bot removed Dependencies Pull requests that update a dependency file Tools Callbacks Inference Config HPO CI labels Dec 12, 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, only a single comment. Thanks a lot for your effort!

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 3570cb1 into feature/cli_migration Dec 14, 2022
@ashwinvaidya17 ashwinvaidya17 deleted the ashwin/refactor_feature_extraction_key branch December 14, 2022 09:05
@jpcbertoldo jpcbertoldo mentioned this pull request Dec 16, 2022
13 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants