PaDiM-Anomaly-Detection-Localization-master icon indicating copy to clipboard operation
PaDiM-Anomaly-Detection-Localization-master copied to clipboard

About the size of the input image

Open xfby2016 opened this issue 4 years ago • 4 comments

Is the size of the input image unadjustable(resize, cropsize)? I get error after changing resize and cropsize. The inference stage, how to deal with larger images, such as 900*1000, resize and crop makes area of anomaly incomplete! Thank you

xfby2016 avatar Feb 09 '21 03:02 xfby2016

The size of the image is completely adjustable, just not with the current code.

Firstly, crop is not necessary; In fact I got higher AUC scores for some classes that I've test on than the original paper. However, be careful if your image isn't square, as explained here https://pytorch.org/docs/stable/torchvision/transforms.html#torchvision.transforms.Resize. In this scenario, crop becomes necessary if you want to keep the original image's proportions (if not, just change T.Resize to take (h, w) instead of int). You would also need to change https://github.com/xiahaifeng1995/PaDiM-Anomaly-Detection-Localization-master/blob/main/main.py#L172 so that the upsampled output image match the size of your input image.

harewei avatar Feb 16 '21 09:02 harewei

The size could be any value that is divisible by 16. as @harewei mentioned, upsampled output image matches the size of your input image score_map = F.interpolate(dist_list.unsqueeze(1), size=(x.size(2),x.size(3)), mode='bilinear', align_corners=False).squeeze().numpy()

DeepKnowledge1 avatar Jun 17 '21 13:06 DeepKnowledge1

The size of the image is completely adjustable, just not with the current code.

Firstly, crop is not necessary; In fact I got higher AUC scores for some classes that I've test on than the original paper. However, be careful if your image isn't square, as explained here https://pytorch.org/docs/stable/torchvision/transforms.html#torchvision.transforms.Resize. In this scenario, crop becomes necessary if you want to keep the original image's proportions (if not, just change T.Resize to take (h, w) instead of int). You would also need to change https://github.com/xiahaifeng1995/PaDiM-Anomaly-Detection-Localization-master/blob/main/main.py#L172 so that the upsampled output image match the size of your input image.

Do you know how to change T.Resize to take (h, w) ?

Omarelsaadany avatar Aug 27 '21 14:08 Omarelsaadany