hcw-00 / PatchCore_anomaly_detection

Unofficial implementation of PatchCore anomaly detection
Apache License 2.0
324 stars 93 forks source link

ValueError: cannot reshape array of size 1024 into shape (28,28) #1

Closed xfby2016 closed 3 years ago

xfby2016 commented 3 years ago

When I run the test phase of this project(mvtec/carpet),I got this error:

train.py", line 333, in test_step anomaly_map = score_patches[:,0].reshape((28,28)) ValueError: cannot reshape array of size 1024 into shape (28,28) Testing: 0%| | 0/117 [00:09<?, ?it/s] Any ideas? thank you !

hcw-00 commented 3 years ago

Hi. I fixed code. please clone repo and try again.

letmejoin commented 3 years ago

When I run the test phase of this project(mvtec/carpet),I got this error:

train.py", line 333, in test_step anomaly_map = score_patches[:,0].reshape((28,28)) ValueError: cannot reshape array of size 1024 into shape (28,28) Testing: 0%| | 0/117 [00:09<?, ?it/s] Any ideas? thank you !

I met the same problem, do you resolve?

xfby2016 commented 3 years ago

This may be related to the size parameters you set,or you can change the shape to square root of the ValueError size : In my case: anomaly_map = score_patches[:,0].reshape((32,32))

letmejoin commented 3 years ago

This may be related to the size parameters you set,or you can change the shape to square root of the ValueError size : which size parameters is related with the reshape size, (32,32) or (28, 28) or others ? Is a correspondence?

letmejoin commented 3 years ago

This may be related to the size parameters you set,or you can change the shape to square root of the ValueError size : In my case: anomaly_map = score_patches[:,0].reshape((32,32))

And by the way, the time spent on ''Calculating distances...'' on my running is very very long with 28 CPU kernels and 3 GTX 2080Ti GPUs. Have you had the issue?

xfby2016 commented 3 years ago

You can check score_patches[:,0] value
"ValueError: cannot reshape array of size 1024 into shape (28,28) " 28 should be replaced with a square root of 1024. ''Calculating distances...''maybe depending on the train dataset size and input_size you set