amazon-science / patchcore-inspection

Apache License 2.0
691 stars 142 forks source link

Does PatchCore support different training and test image sizes? #76

Open viggykrish opened 1 year ago

viggykrish commented 1 year ago

I would like to train PatchCore using images of a certain size and at inference use it on images of a different size. Is this conceptually possible with PatchCore. My understanding is that this is not possible as we collect features at a certain image resolution during training to create the memory bank. Therefore, during testing the images must be the same resolution as that used during training. Is this correct?

free-soellingeraj commented 1 year ago

I am using with different size training and testing images and it works fine. The input size parameter --imagesize 224 is not being enforced.

William9Baker commented 1 year ago

I am using with different size training and testing images and it works fine. The input size parameter --imagesize 224 is not being enforced.

Can it support image sizes with different lengths and widths?

viggykrish commented 1 year ago

Yes, in general PatchCore can support rectangular images. The repo needs to be updated to support that.

viggykrish commented 1 year ago

Although the code doesn't enforce same size training and testing images, it seems that is a requirement for PatchCore because the algorithm computes embedded features and then finds the distance of the test image from the memory bank. If the memory bank were constructed from images of a different resolution, wouldn't this comparison work incorrectly? In a few experiments that I tried, PatchCore didn't perform well when train and test images were of different sizes.

William9Baker commented 1 year ago

Yes, in general PatchCore can support rectangular images. The repo needs to be updated to support that.

Thanks. If the input is a rectangular image, how to set the parameter of "imagesize" correctly?

William9Baker commented 1 year ago

Yes, in general PatchCore can support rectangular images. The repo needs to be updated to support that.

And what is the relationship between the two parameters of "imagesize" and "resize"? If the input is a rectangular image, how to set these two parameters?

shensongli commented 1 month ago

Yes, in general PatchCore can support rectangular images. The repo needs to be updated to support that.

And what is the relationship between the two parameters of "imagesize" and "resize"? If the input is a rectangular image, how to set these two parameters? hello,how did you solve this problem