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 SuperSimpleNet model #2428

Open
wants to merge 21 commits into
base: feature/v2
Choose a base branch
from

Conversation

blaz-r
Copy link
Contributor

@blaz-r blaz-r commented Nov 21, 2024

πŸ“ Description

  • This PR adds the SuperSimpleNet model implementation.
  • I also verified the performance on MVTec AD and the results are very close tho the ones reported in the paper.

✨ Changes

Select what type of change your PR is:

  • 🐞 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)
  • πŸ“š Documentation update
  • πŸ”’ Security update

βœ… Checklist

Before you submit your pull request, please make sure you have completed the following steps:

  • πŸ“‹ I have summarized my changes in the CHANGELOG and followed the guidelines for my type of change (skip for minor changes, documentation updates, and test enhancements).
  • πŸ“š I have made the necessary updates to the documentation (if applicable).
  • πŸ§ͺ I have written tests that support my changes and prove that my fix is effective or my feature works (if applicable).

For more information about code review checklists, see the Code Review Checklist.

blaz-r and others added 19 commits November 21, 2024 09:53
Signed-off-by: Blaz Rolih <blaz.rolih@gmail.com>
Signed-off-by: blaz.rolih <blaz.rolih@fri.uni-lj.si>
Signed-off-by: Blaz Rolih <blaz.rolih@gmail.com>
Signed-off-by: blaz.rolih <blaz.rolih@fri.uni-lj.si>
Signed-off-by: blaz-r <blaz.rolih@gmail.com>
Signed-off-by: blaz.rolih <blaz.rolih@fri.uni-lj.si>
Signed-off-by: blaz-r <blaz.rolih@gmail.com>
Signed-off-by: blaz.rolih <blaz.rolih@fri.uni-lj.si>
Signed-off-by: blaz-r <blaz.rolih@gmail.com>
Signed-off-by: blaz.rolih <blaz.rolih@fri.uni-lj.si>
Signed-off-by: blaz-r <blaz.rolih@gmail.com>
Signed-off-by: blaz.rolih <blaz.rolih@fri.uni-lj.si>
Signed-off-by: blaz-r <blaz.rolih@gmail.com>
Signed-off-by: blaz.rolih <blaz.rolih@fri.uni-lj.si>
Signed-off-by: blaz-r <blaz.rolih@gmail.com>
Signed-off-by: blaz.rolih <blaz.rolih@fri.uni-lj.si>
Signed-off-by: blaz-r <blaz.rolih@gmail.com>
Signed-off-by: blaz.rolih <blaz.rolih@fri.uni-lj.si>
Signed-off-by: blaz-r <blaz.rolih@gmail.com>
Signed-off-by: blaz.rolih <blaz.rolih@fri.uni-lj.si>
Signed-off-by: blaz-r <blaz.rolih@gmail.com>
Signed-off-by: blaz.rolih <blaz.rolih@fri.uni-lj.si>
Signed-off-by: blaz-r <blaz.rolih@gmail.com>
Signed-off-by: blaz.rolih <blaz.rolih@fri.uni-lj.si>
Signed-off-by: blaz-r <blaz.rolih@gmail.com>
Signed-off-by: blaz.rolih <blaz.rolih@fri.uni-lj.si>
Signed-off-by: blaz-r <blaz.rolih@gmail.com>
Signed-off-by: blaz.rolih <blaz.rolih@fri.uni-lj.si>
Signed-off-by: Blaz Rolih <blaz.rolih@gmail.com>
Signed-off-by: blaz.rolih <blaz.rolih@fri.uni-lj.si>
Signed-off-by: blaz.rolih <blaz.rolih@fri.uni-lj.si>
Signed-off-by: blaz-r <blaz.rolih@gmail.com>
Signed-off-by: blaz.rolih <blaz.rolih@fri.uni-lj.si>
Signed-off-by: blaz.rolih <blaz.rolih@fri.uni-lj.si>
Signed-off-by: blaz.rolih <blaz.rolih@fri.uni-lj.si>
@samet-akcay
Copy link
Contributor

This is amazing @blaz-r! Thanks a lot! I'll review it shortly

Signed-off-by: blaz.rolih <blaz.rolih@fri.uni-lj.si>
Signed-off-by: blaz.rolih <blaz.rolih@fri.uni-lj.si>
@blaz-r
Copy link
Contributor Author

blaz-r commented Nov 21, 2024

I have fixed the linter error and formated the files. The tests for SuperSimpleNet are still failing on onnx and openvino export locally. I'm not entirely sure how to fix this, but I'll take a lot when I get the time.

@blaz-r
Copy link
Contributor Author

blaz-r commented Nov 21, 2024

Tests are failing on imgaug, somethign with numpy version incompatiblity it seems.

@samet-akcay
Copy link
Contributor

samet-akcay commented Nov 22, 2024

@blaz-r, we will need to remove imgaug dependency to bump the numpy version.

directly predicts the anomaly map and score. The predicted anomaly map is upscaled to match the input image size
and refined with a Gaussian filter.

This implementation supports both unsupervised and supervised setting, but Anomalib currently supports only unsupervised learning.
Copy link
Contributor

Choose a reason for hiding this comment

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

What are the missing points in Anomalib to support supervised setting

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right now I believe there are no standard supervised datasets. Another problem is the Folder dataset as it assumes that abnormal samples are always in test set:

samples.loc[(samples.label == DirType.NORMAL), "split"] = Split.TRAIN
samples.loc[(samples.label == DirType.ABNORMAL) | (samples.label == DirType.NORMAL_TEST), "split"] = Split.TEST

Another thing for full reproduction of SuperSimpleNet results is the fixed flipping augmentation and frequency sampling. This is however not necessary, but needed for best results. It's also not SuperSimpleNet specific, so might be worth considering if other supervised model will be supported.

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah, we would like to diversify the model pool, and include more learning types than one-class models. Thanks for the feedback.
@abc-125, you might want to be aware of this discussion as you have recently worked on this stuff

Copy link
Contributor

Choose a reason for hiding this comment

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

Thank you for adding me, it would be great to have supervised models and datasets in Anomalib. Recently, I looked at how to add a supervised dataset, and it certainly would require changing some base structures, such as paths to folders (I guess we will need abnormal_train_dir and maybe renaming the rest to make it easier to understand, normal_train_dir, etc.):

normal_dir (str | Path | Sequence): Path to the directory containing normal images.
root (str | Path | None): Root folder of the dataset.
Defaults to ``None``.
abnormal_dir (str | Path | Sequence | None, optional): Path to the directory containing abnormal images.
Defaults to ``None``.
normal_test_dir (str | Path | Sequence | None, optional): Path to the directory containing
normal images for the test dataset.
Defaults to ``None``.

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.

3 participants