The conversion is done by the toTensor function of torchvision.transforms.
So, if you remove it from your pre-processing pipeline, your image will be in 0-255 range.
But, if you omit it, you need to convert to Tensor yourself.
So, there’s no issue with using a model trained on images of range 0-1, on images that have a range of 0-255? Because in testing, it looks like something is off.
import torch
from collections import OrderedDict
model = torch.load('vgg-16.pth')
new_state_dict = OrderedDict()
for (k, v) in model.items():
t = torch.ones(v.size()).float() *255
v = v.mul(t.cuda())
new_state_dict[k] = v
torch.save(new_state_dict, 'vgg-16-2.pth')
If the model is trained with 0-1 input, it should be tested with 0-1 input (and with the same mean/std normalization), and the same for other input ranges. It will not work otherwise.
I would have converted the model output to [0, 255] instead. However, you’ll have to make sure that your targets / labels are also in the same range. There is no advantage of using an input with [0, 255] over [0, 1], as the model weight parameters will adapt to whatever input range, it is a scaling factor as you can see. However, the common practice and the best performance can be obtained when the input is normalized to [0, 1] or [-1, 1].