Why does the ResNet from the timm.models accept images of different sizes, although it is trained on 224

Viewed 24

I use the ResNet50. ResNet50 is trained for image size 224x224. Why don't they give an error when I submit tensors (images) of a different size?

import torch    
from timm.models.resnet import resnet50 
y_pred = model_resnet50(torch.rand(4, 3, 224, 224))  # OK
y_pred = model_resnet50(torch.rand(4, 3, 537, 537))  # Again OK. Why? The size is not the one that was trained on ResNet50

I assume that it runs in convolutions throughout the image. It creates a different number of properties for different images (after forward_features). The Global Average Pooling layer brings everything to a one-dimensional vector. Therefore, the image size only affects the number of properties in front of the Dense layer. Is it so?

What size images are better to train then?

0 Answers
Related