If I use the pretrained resnet50 to train my own project, I need to convert image from BGR to RGB, normalize image range from [0, 255] to [0, 1], 1. use transformer: normalize = transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]) to transform the image data.
But if I want to test an image, should I do the above steps? Or just convert image from BGR to RGB? I am confused…
Yes, except for those transformations that are meant for data-augmentation, all other transformation steps should be applied to the test data as well.
Specifically, this transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]) applied to your training data will sort of mean-center and standardize the image channels. Therefore, if you do not apply this transformation to your test images, the train data and test data will have different data distributions.
Data augmentation transformations include RandomHorizontalFlip, RandomCrop and so on, which do not need to be applied in the evaluation phase.