nelson1425 / EfficientAD

Unofficial implementation of EfficientAD https://arxiv.org/abs/2303.14535
https://arxiv.org/abs/2303.14535
Apache License 2.0
240 stars 62 forks source link

Why pad 4 pixels before resizing instead of resizing directly? #8

Closed kywish closed 1 year ago

kywish commented 1 year ago

Hi~, in the part of ouput anomaly map:

map_combined = torch.nn.functional.pad(map_combined, (4, 4, 4, 4)) map_combined = torch.nn.functional.interpolate(map_combined, (orig_height, orig_width), mode='bilinear')

why pad 4 pixel each side? what's the difference with resize to (orig_height, orig_width) directly? 🤔🤔🤔

nelson1425 commented 1 year ago

It is similar to applying 11x11 edge filter to 100x100 image. The result will be 90x90 image with detected edges. Resizing it to 100x100 would distort the detected edges. Instead you have to pad the 90x90 image with 5 pixels on each size.