Some questions about the vgg_prepro function in utils.py files
Alxemade opened this issue · 3 comments
Issue Description
Hello,
when I read your code, I have some questions about the vgg_prepro functions in utils.py
This function is defined as follows:
def vgg_prepro(x):
x = imresize(x, [244, 244], interp='bilinear', mode=None)
x = np.tile(x, 3)
x = x / 127.5 - 1
return x
I know this function is to preprocess an image, such as to Changing an image from [256,256,1] to [244,244,3], but I don't understand why do we need to use x/127.5 - 1 , here we have already to scale the image to [-1,1].
In addition, I would also like to ask why we cut the size of 244 instead of 224 which is the size of the initial VGG paper.
I was hoping you could help me with this problem, I can't get it right.
Hi @Alxemade,
Thanks for your question.
Since imresize() will automatically rescale the image to [0, 255], we need to rescale it back to [-1,1] again.
We use 244 simply because VGG is fully-convolutional and bigger image input seems better the result a bit. Please feel free to adjust all these hyper-parameters, as we didn't make large efforts to tune them.
Thanks.