WBR
WBR

Reputation: 77

How did Pytorch process images in ImageNet when training resnet pretrained models in torchvision.models.resnet34?

I downloaded the pretrained parameters of resnet34 in torchvision.models and put them to a tensorflow1.X network, but just get 58% accurary testing on the ImageNet2015 Validation set (50,000 picture).

I guess it may be caused by the different precessing method to the data set. The Validation I am using is in TFRecord format processed by my friend.

So I am wondering how Pytorch process images of ImageNet when training resnet34 pretrained models? Turn RGB to BGR? Scale pictures values to 0--1?

Upvotes: 1

Views: 3483

Answers (1)

IonicSolutions
IonicSolutions

Reputation: 2599

From the documentation:

All pre-trained models expect input images normalized in the same way, i.e. mini-batches of 3-channel RGB images of shape (3 x H x W), where H and W are expected to be at least 224. The images have to be loaded in to a range of [0, 1] and then normalized using mean = [0.485, 0.456, 0.406] and std = [0.229, 0.224, 0.225]. You can use the following transform to normalize:

normalize = transforms.Normalize(mean=[0.485, 0.456, 0.406],
                                 std=[0.229, 0.224, 0.225])```

The documentation links this example for preprocessing ImageNet data.

Upvotes: 3

Related Questions