This question is kind of a follow up for the discussion in comments of this answer.
From what I understand, the preprocess_input() function does mean subtraction and std-dev dvision for the input images. The mean are those that are computed on ImageNet-1K database when training VGG.
But this answer says that when using VGG features as a loss function, preprocess_input() is not required and we just need to normalize the image to [0,1] range before passing to VGG. This confuses me...
- If we don't preprocess, then the input will be in different range compared to those images used to train VGG. How are the VGG features still valid?
- From what I understand from this answer, we should have images in
[0,255]range andpreprocess_input()function takes care of the normalization and all. From the source code, I understand that for caffe models, normalization to[0,1]range is not done. Instead mean is subtracted and std-dev is divided. How would just normalizing network output to[0,1]range as suggested in the comments of this answer achieve the same?
Edit 1:
I'm considering the models which output images. It is not specific to a single model. One example is image denoising network. The input to my network is a noisy image and its output is a denoised image. I want to minimize MSE between denoised image and ground truth image in VGG feature space. Whatever be the range of my network's output, I can easily change it to [0,255] by multiplying by appropriate factors. Similarly I can do any preprocessing required on my network's output (subtract mean, divide by std-dev).
Empirically I found that the output of preprocess function is in approx range [-128,151]. So VGG network is trained on images in this range. Now, if I feed it with images (or tensors from my network output) in the range [0,1], convolution would be fine but biases will cause problem right? To elaborate, for images in range [-128,151], a layer of VGG network may have learnt a bias of 5. When I feed an image in the range [-1,1] to the VGG network, the bias disrupts everything, right?
I'm not training VGG model. I'm using the weights from the model trained on ImageNet-1k database.