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 AnomalyModule and LightningModules to explicitly define class arguments. #315

Merged
merged 42 commits into from
May 24, 2022

Conversation

samet-akcay
Copy link
Contributor

Description

  • This PR refactors AnomalyModule and LightningModules to explicitly define class arguments. Current design depends on hparams variable, which is a DictConfig. Despite being convenient, it is not explicit such that the user may not now what exactly needed to construct a model class. The proposed implementation addresses this explicitly construct the model classes.

Changes

  • Bug fix (non-breaking change which fixes an issue)
  • 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

@samet-akcay samet-akcay marked this pull request as ready for review May 19, 2022 14:28
Copy link
Collaborator

@ashwinvaidya17 ashwinvaidya17 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 the efforts! I have a few minor comments.

anomalib/utils/callbacks/metrics.py Outdated Show resolved Hide resolved
anomalib/utils/callbacks/tiler.py Outdated Show resolved Hide resolved
anomalib/models/cflow/lightning_model.py Outdated Show resolved Hide resolved
anomalib/models/ganomaly/lightning_model.py Show resolved Hide resolved
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. One concern that I'm having with these configuration callbacks, is that it might confuse the user. MetricsCallback may sound like it is responsible for collecting the outputs and computing the performance metrics, while in practive it is only used to initialize the metric collections. When more callbacks like this get added, it might be good to make a clear distinction between these configuration callbacks and the other callbacks. Maybe we could keep them in a separate folder and/or add a postfix to the class names, e.g. MetricsConfigurationCallback.

anomalib/models/components/base/anomaly_module.py Outdated Show resolved Hide resolved
anomalib/models/components/base/anomaly_module.py Outdated Show resolved Hide resolved
anomalib/models/dfkde/config.yaml Show resolved Hide resolved
anomalib/utils/callbacks/cdf_normalization.py Outdated Show resolved Hide resolved
anomalib/utils/callbacks/cdf_normalization.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@ashwinvaidya17 ashwinvaidya17 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 am fine with the changes.

@samet-akcay
Copy link
Contributor Author

@djdameln, if you are happy with the final changes we could merge this PR today

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.

Great work, thanks!

@samet-akcay samet-akcay merged commit c7d5232 into development May 24, 2022
@samet-akcay samet-akcay deleted the refactor/sa/lightning-modules branch May 24, 2022 09:13
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.

None yet

3 participants