rvorias / ind_knn_ad

Vanilla torch and timm industrial knn-based anomaly detection for images.
https://share.streamlit.io/rvorias/ind_knn_ad
MIT License
147 stars 50 forks source link

PADIM method consumes too much memory #13

Closed Mshz2 closed 3 years ago

Mshz2 commented 3 years ago

Hi there,

I am using the pipeline based on the padim method and backbone_name="wide_resnet50_2". However, I see excessive raise in my memory when I check it with htop command in another terminal. I don't have same experience with spade method.

Capture2

As picture shows, it consumes up to 121G in the memory. I even tried to reduce the 'd_reduced' parameter, but it is still around 100G. May I ask about your opinion how can I make it better? did U also faced same issue?

Best

rvorias commented 3 years ago

Djezus!

First of all, I shed some light on memory issues and possible solutions here: https://github.com/rvorias/ind_knn_ad/issues/8#issuecomment-902633484

What dataset are you using? If custom, how many training samples are in there?

Mshz2 commented 3 years ago

Djezus!

First of all, I shed some light on memory issues and possible solutions here: #8 (comment)

What dataset are you using? If custom, how many training samples are in there?

I am using 2100 custom 348*348 resolution dataset.

rvorias commented 3 years ago

For such a dataset, you'd need to do an online calculation for mean and the cov matrix.

Atm I don't have time to implement that, but I'm open to PRs!

rvorias commented 3 years ago

I think you will run into trouble for every method. Maybe you can try it with a subset of the training images?

Mshz2 commented 3 years ago

I just followed the #8 (comment) and changed the backbone to backbone_name="efficientnet_b0" and it worked 💯 memory reduced to approx 20G (from 100G). Next I will just reduce the dataset size :) Thanks a lot