LilitYolyan / CutPaste

Unofficial implementation of Google "CutPaste: Self-Supervised Learning for Anomaly Detection and Localization" in PyTorch
MIT License
114 stars 25 forks source link

Dataset organization #14

Closed nesrnesr closed 2 years ago

nesrnesr commented 2 years ago

Hello, First of all, thank you for your neat work! I managed to run your code on the bottle class of the Mvtec dataset by running the command:

python train.py --dataset_path /home/username1/data/datasets/mvtec/bottle/train --num_class 3

However when I tried to run the anomaly_detection.py, using the following command:

python anomaly_detection.py --checkpoint ./tb_logs/exp1/version_3/checkpoints --data /data/username1/datasets/mvtec/bottle/test

I did not obtain any results, the problem is that the all_checkpoint list in the main part of the anomaly_detection.py contains only the checkpoint I specified in the command above, which makes me wonder whether I am doing something wrong when specifying the command above and also I wonder whether you have a different dataset organization on your side. Because for now, I am having the following organization (the original):

mvtec
│   readme.
│   license.txt    
│
└─── bottle
│   │   readme.txt
│   │   lisence.txt
│   │
│   └─── ground_truth
│   |   └─── broken_large
│   |   └─── broken_small   
│   |   └─── contamination
│   |
|   └─── train
|   |     └─── good
|   |       |  000.png
|   |       | ...
│   |
|   └─── test
|   |     └─── broken_large
|   |     | |  000.png  
|   |     | |  ...     
|   |     └───   broken_small
|   |     | |  000.png    
|   |     | |  ...
|   |     └───   contamination
|   |     | |   000.png
|   |     | |  ...   
|   |     └───   good
|   |     | |  000.png 
|   |     | | ...
└─── cable
| ...
└─── zipper

Can you please tell me whether you used a different organization? Because when I look at mvtec_anomaly_detection function I see that you build a path using the defect name + "train" and you do the same for "test". Thank you for your help.

farzadips commented 2 years ago

Hello, First of all, thank you for your neat work! I managed to run your code on the bottle class of the Mvtec dataset by running the command:

python train.py --dataset_path /home/username1/data/datasets/mvtec/bottle/train --num_class 3

However when I tried to run the anomaly_detection.py, using the following command:

python anomaly_detection.py --checkpoint ./tb_logs/exp1/version_3/checkpoints --data /data/username1/datasets/mvtec/bottle/test

I did not obtain any results, the problem is that the all_checkpoint list in the main part of the anomaly_detection.py contains only the checkpoint I specified in the command above, which makes me wonder whether I am doing something wrong when specifying the command above and also I wonder whether you have a different dataset organization on your side. Because for now, I am having the following organization (the original):

mvtec
│   readme.
│   license.txt    
│
└─── bottle
│   │   readme.txt
│   │   lisence.txt
│   │
│   └─── ground_truth
│   |   └─── broken_large
│   |   └─── broken_small   
│   |   └─── contamination
│   |
|   └─── train
|   |     └─── good
|   |       |  000.png
|   |       | ...
│   |
|   └─── test
|   |     └─── broken_large
|   |     | |  000.png  
|   |     | |  ...     
|   |     └───   broken_small
|   |     | |  000.png    
|   |     | |  ...
|   |     └───   contamination
|   |     | |   000.png
|   |     | |  ...   
|   |     └───   good
|   |     | |  000.png 
|   |     | | ...
└─── cable
| ...
└─── zipper

Can you please tell me whether you used a different organization? Because when I look at mvtec_anomaly_detection function I see that you build a path using the defect name + "train" and you do the same for "test". Thank you for your help.

Hello, How did you solve this problem? did you change the folders?

LilitYolyan commented 2 years ago

For now, the anomanly_detection.py works per damage at the time (ex. bottle folder as input), whereas train.py uses all mvtec at once. We are going to optimize it soon to work for whole classes at once.