-
Notifications
You must be signed in to change notification settings - Fork 739
Implementation of GLASS model in Anomalib #2629
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
base: main
Are you sure you want to change the base?
Implementation of GLASS model in Anomalib #2629
Conversation
Signed-off-by: Devansh Agarwal <[email protected]>
674ebd8
to
5b4931b
Compare
@samet-akcay I am facing a problem. I need to add perlin noise to the image for training as done here in the getitem method. |
@code-dev05, you could use Anomalib's PreProcessor class. The advantage of the preprocessor is that you could apply any transform to the model input, including perlin noise. You could set train,val, test transforms separately, or all at once. Anomalib also provides PerlinAnomalyGenerator class that you could create as a transform and pass into Let me know if the documentation is not clear, or you would need more clarification. |
Thank you for the advice. I will look into it and get back to you if I do not understand something. |
Alternatively, you could use perlin_noise_generator function in What this would do is to apply the perlin noise when the model receives the input on batch start. You could prototype any one of them. We could always polish it later on once your pr is ready for review |
Signed-off-by: Devansh Agarwal <[email protected]>
@samet-akcay I have created one new commit. Please check it. I have noticed a few issues,
|
@samet-akcay I will also need to create a datamodule for the DTD dataset. Should I add that in this PR only or create a new PR? |
@@ -0,0 +1,161 @@ | |||
import torch |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add license and docstring to the top of all the files?
Hi @code-dev05 Thanks a lot for your effort! Here are some comments that may help you address your issues related to center computation and noise generation:
We want to reproduce the algorithm from the original paper as closely as possible, so I would suggest to compute the center of the dataset in an initialization step. You could try using the
Looking at your code, it is not entirely clear to me how you are intending to use My personal preference would be to apply the augmentation within the
This might not be necessary. As far as I understand (but please correct me if I'm wrong), we only use the DTD dataset as a source of textures for the synthetic anomaly generation step. This means that we don't need any ground truth information for this dataset, just the raw images. So instead of implementing a dedicated dataset/datamodule, we can just randomly sample some images that we read from the file system in every step. In fact, this mechanism has already been implemented for DRAEM, which uses a similar approach. Please have a look at this class to see if you can use this for the augmentation step of your GLASS model (note that you can just pass the root of the DTD dataset on your file system, and the augmenter will automatically sample and read the images). |
Yes, I was planning on adding a new dataclass interface but i will see the way it is done in the DRAEM model and try to get the same done here and will add the usage of the hooks for computing the center as soon as possible. I will also make the suggested changes as soon as possible. Thanks for the help. |
Signed-off-by: Devansh Agarwal <[email protected]>
Signed-off-by: Devansh Agarwal <[email protected]>
Signed-off-by: Devansh Agarwal <[email protected]>
Signed-off-by: Devansh Agarwal <[email protected]>
Signed-off-by: Devansh Agarwal <[email protected]>
@samet-akcay @ashwinvaidya17 @djdameln |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the update. There are still a few things that need polishing
src/anomalib/models/components/feature_extractors/network_feature_extractor.py
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot for your effort! I've got some initial feedback.
src/anomalib/models/components/feature_extractors/network_feature_extractor.py
Outdated
Show resolved
Hide resolved
@code-dev05 Also tests are failing. Do you have access to the test results ? |
Yes, I can see them. I will address those also and see what I can do to solve them. |
Great thanks |
Signed-off-by: Devansh Agarwal <[email protected]>
@samet-akcay The pre-commit hook is giving error in the line 202 of the |
📝 Description
✨ Changes
Select what type of change your PR is:
TODO
I will keep updating the PR as I implement the rest of the list.