Use `torchvision.models` pretrained models but input of smaller sizes

Problem

The models provided in torchvision.models were trained on ImageNet so the size of image is (3, 224, 224). However, I have a small dataset (a custom dataset with about 20 thousand images) which is of smaller size.

I am wondering if there is anyway I could still use the pre-trained weights with those smaller images. There are two directions in my mind.

  • Modify the first layer and retrain that layer from scratch so that the the sizes of later layers are compatible with pre-trained weights.
  • Somehow augment the original images (perhaps some strategic padding) so that the size is made (224, 224).

However, both of them seems to be a long shot when moving into action.

Therefore, does anyone have encountered similar circumstances? Thank you in advance!

Hi,

I think the second one using classical resizing methods (with bilinear sampling for example) can be a good approach if the images in your new dataset are not too far from 224x224. Doc here.