amazon-science / patchcore-inspection

Apache License 2.0
691 stars 142 forks source link

Vision Transformer Models Cause IndexError in PatchCore #63

Open 1amrutesh opened 1 year ago

1amrutesh commented 1 year ago

I encountered an issue when trying to use Vision Transformer based models like _vitbase, _vit_swinlarge, etc. in the PatchCore implementation. I tried to execute this on the Kaggle Notebook environment. I get an IndexError: list index out of range when running the provided script, as shown below: Traceback (most recent call last): File "/kaggle/input/patchcore/patchcore-inspection-main/bin/run_patchcore.py", line 435, in <module> main() ... File "/kaggle/input/patchcore/patchcore-inspection-main/src/patchcore/patchcore.py", line 110, in _embed ref_num_patches = patch_shapes[0] IndexError: list index out of range Here's the command I used to run the script:

!python /kaggle/input/patchcore/patchcore-inspection-main/bin/run_patchcore.py --gpu 0 --seed 0 --save_patchcore_model \ --log_group IM224_WR50_L2-3_P01_D1024-1024_PS-3_AN-1_S0 --log_project MVTecAD_Results results \ patch_core -b vit_small --faiss_on_gpu \ --pretrain_embed_dimension 1024 --target_embed_dimension 1024 --anomaly_scorer_num_nn 1 --patchsize 3 \ sampler -p 0.1 approx_greedy_coreset dataset --resize 224 --imagesize 224 {dataset_flags} mvtec $datapath I followed the guidelines provided in the GitHub repository but still encountered this error. I would appreciate any help in resolving this issue.

Please let me know if any additional information is required to better understand and diagnose the problem.

ahi267aa commented 1 year ago

May I ask have you solved this problem? I've tried to train with swin model too.

1amrutesh commented 1 year ago

May I ask have you solved this problem? I've tried to train with swin model too.

No, I am still unable to resolve this issue. I think that the problem arises due to the _embed function in the patchcore.py script.