# How are inputs to Inception v3 pre-processed?

When using the pre-trained Inception v3 model for image classification, how should the inputs be pre-processed? Should the images be individually normalized to 0 mean, 1 standard deviation?

In the original paper I could not find this information https://www.cv-foundation.org/openaccess/content_cvpr_2016/papers/Szegedy_Rethinking_the_Inception_CVPR_2016_paper.pdf and I expect inference results to be very affected by different inputs as to the ones the model was trained upon, so getting the inputs into the same pixel intensity space should be crucial.

If you look at the Keras implementation of Inception, it looks like they perform the following pre-processing steps:

def preprocess_input(x):
x = np.divide(x, 255.0)
x = np.subtract(x, 1.0)
x = np.multiply(x, 2.0)
return x


That is, they normalize each pixel to [-2, 0].

See here for details:

https://github.com/kentsommer/keras-inception-resnetV2/blob/master/evaluate_image.py#L9

And this is the exact pre-processing done in TensorFlow's implementation of Inception:

https://github.com/tensorflow/models/blob/master/research/slim/preprocessing/inception_preprocessing.py#L243-L281

Specifically,

def preprocess_for_eval(image, height, width,
central_fraction=0.875, scope=None):
"""Prepare one image for evaluation.
If height and width are specified it would output an image with that size by
applying resize_bilinear.
If central_fraction is specified it would crop the central fraction of the
input image.
Args:
image: 3-D Tensor of image. If dtype is tf.float32 then the range should be
[0, 1], otherwise it would converted to tf.float32 assuming that the range
is [0, MAX], where MAX is largest positive representable number for
int(8/16/32) data type (see tf.image.convert_image_dtype for details).
height: integer
width: integer
central_fraction: Optional Float, fraction of the image to crop.
scope: Optional scope for name_scope.
Returns:
3-D float Tensor of prepared image.
"""
with tf.name_scope(scope, 'eval_image', [image, height, width]):
if image.dtype != tf.float32:
image = tf.image.convert_image_dtype(image, dtype=tf.float32)
# Crop the central region of the image with an area containing 87.5% of
# the original image.
if central_fraction:
image = tf.image.central_crop(image, central_fraction=central_fraction)

if height and width:
# Resize the image to the specified height and width.
image = tf.expand_dims(image, 0)
image = tf.image.resize_bilinear(image, [height, width],
align_corners=False)
image = tf.squeeze(image, )
image = tf.subtract(image, 0.5)
image = tf.multiply(image, 2.0)
return image