Reputation: 9
I'm new to tensorflow. I know that CAFFE needs RGB mean value subtracted in advance. But I don't see the same codes in tensorflow examples.
Do I need to subtract mean value of IMAGENET when finetuning RESNET and INCEPTION provided by Tensorflow Models?
Upvotes: 0
Views: 1945
Reputation: 1802
There are multiple ways to normalize the image. Subtract mean value of training set / normalize image to [-1,1]
In this case, they normalized every image to [-1,1] using the function tf.image.per_image_standardization() which you can see in preprocessing folder section. You can follow the same preprocessing script for Fine-Tuning as well.
def preprocess_for_eval(image, output_height, output_width):
"""Preprocesses the given image for evaluation.
Args:
image: A `Tensor` representing an image of arbitrary size.
output_height: The height of the image after preprocessing.
output_width: The width of the image after preprocessing.
Returns:
A preprocessed image.
"""
tf.summary.image('image', tf.expand_dims(image, 0))
# Transform the image to floats.
image = tf.to_float(image)
# Resize and crop if needed.
resized_image = tf.image.resize_image_with_crop_or_pad(image,
output_width,
output_height)
tf.summary.image('resized_image', tf.expand_dims(resized_image, 0))
# Subtract off the mean and divide by the variance of the pixels.
return tf.image.per_image_standardization(resized_image)
I hope this helps.
Upvotes: 1