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 25 commits into
base: release/v2.0.0
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>
@blaz-r blaz-r force-pushed the feature/supersimplenet branch from 6acde98 to 3c65da6 Compare November 21, 2024 08:53
@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``.

@samet-akcay
Copy link
Contributor

@blaz-r, I've created #2436 to remove imgaug stuff and write our own perlin noise generation stuff. Would it be an idea to try this in supersimplenet ?

@blaz-r
Copy link
Contributor Author

blaz-r commented Nov 25, 2024

Sure. SuperSimpleNet used only _rand_perlin_2d function, which I think can now be replaced with the new generate_perlin_noise.

@samet-akcay
Copy link
Contributor

@blaz-r can you pull the latest changes again? The tests should pass after that

@blaz-r
Copy link
Contributor Author

blaz-r commented Dec 2, 2024

Okay, I am currently at the ICPR. I will try to sort this out when I get some time.

@samet-akcay
Copy link
Contributor

Okay, I am currently at the ICPR. I will try to sort this out when I get some time.

ah nice, enjoy the conference!

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