PaDiM-Anomaly-Detection-Localization-master
PaDiM-Anomaly-Detection-Localization-master copied to clipboard
About the size of the input image
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
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.
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()
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) ?