-
Hi I have experimented to see how top-1 validation accuracy changed with different preprocessing steps. QuestionMy question is if there is a plan to add
I also found that Experiment setupI just add following code to original validate.py. (full code) This code is made for experiment only.
from torchvision import transforms
from torchvision.transforms.functional import InterpolationMode
import numpy as np
class MyToTensor:
def __init__(self, option):
self.mean = torch.tensor(127.5).half()
self.std = torch.tensor(127.5).half()
self.option = option
def __call__(self, pic):
img = torch.from_numpy(np.array(pic, np.uint8, copy=True))
img = img.permute((2, 0, 1)).contiguous()
if self.option == 'timm':
return img.half().sub_(self.mean).div_(self.std)
elif self.option == 'original':
return (img.to(torch.float) - 128.0) / 128.0
elif self.option == 'torchvision':
return (img.to(torch.float).div(255) - 0.5) / 0.5
interpolation_dict = {
'bilinear': InterpolationMode.BILINEAR,
'bicubic': InterpolationMode.BICUBIC
}
interpolation = interpolation_dict[data_config['interpolation']]
if args.resize == 'resize_shorter':
loader.dataset.transform = transforms.Compose([
transforms.Resize(data_config['input_size'][-2], interpolation=interpolation),
transforms.CenterCrop(data_config['input_size'][-2:]),
MyToTensor(args.divide)
])
elif args.resize == 'resize':
loader.dataset.transform = transforms.Compose([
transforms.Resize(data_config['input_size'][-2:], interpolation=interpolation),
MyToTensor(args.divide)
]) Experiment Results
Thank you. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
@hankyul2 I'm aware of this but chose not to add support since it is not trivial to support properly (via pretrained default_cfg entries, arg pass through to transform factory). I also don't agree with deviating from what has been a fairly consistent standard re ImageNet eval, especially when it doesn't preserve aspect ratios... efficientnet v2 are not the only models, the deepmind nfnet weights and convnext weights (384x384 only) also rely on different preprocess. Something I may do in the future, but hasn't been a priority. |
Beta Was this translation helpful? Give feedback.
@hankyul2 I'm aware of this but chose not to add support since it is not trivial to support properly (via pretrained default_cfg entries, arg pass through to transform factory).
I also don't agree with deviating from what has been a fairly consistent standard re ImageNet eval, especially when it doesn't preserve aspect ratios... efficientnet v2 are not the only models, the deepmind nfnet weights and convnext weights (384x384 only) also rely on different preprocess.
Something I may do in the future, but hasn't been a priority.