Purpose of padding
AlessandroPolidori opened this issue · 2 comments
https://github.com/nelson1425/EfficientAD/blob/fcab5146f84ae17597044ad5ddf1656ccf805401/efficientad.py#LL279C9-L279C75
I'm wondering why this padding is necessary. Can you help me?
Hi, without this padding the segmentation metric will decrease very much because the segmentation pixels are not aligned anymore after the next line (map_combined = torch.nn.functional.interpolate(...)).
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.
In the case of EfficientAD, the patch size is 33, so 16 pixels padding on each border. The teacher has two layers with stride 2, so we need to divide the 16 pixels padding by 2 and again by 2, which gives us 4. So 4 pixels padding on each border for the output feature maps.
Hi, without this padding the segmentation metric will decrease very much because the segmentation pixels are not aligned anymore after the next line (map_combined = torch.nn.functional.interpolate(...)).
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.
In the case of EfficientAD, the patch size is 33, so 16 pixels padding on each border. The teacher has two layers with stride 2, so we need to divide the 16 pixels padding by 2 and again by 2, which gives us 4. So 4 pixels padding on each border for the output feature maps.
how caculate these values? how can I know what size should I pad?
For example, when it comes to these origin sizes, what size should I pad if I want to resize 56×56 to these origin sizes?