title: Resnet50 image preprocessing
body: <p>I am using <code>https://tfhub.dev/google/imagenet/resnet_v2_50/feature_vector/3</code> to extract image feature vectors. However, I'm confused when it comes to how to preprocess the images prior to passing them through the module.</p>
  <p>Based on the related <a href="https://github.com/tensorflow/hub/blob/master/docs/common_signatures/images.md" rel="nofollow noreferrer">Github</a> explanation, it's said that the following should be done:</p>
  <pre><code>image_path = &quot;path/to/the/jpg/image&quot;
  image_string = tf.read_file(image_path)
  image = tf.image.decode_jpeg(image_string, channels=3)
  image = tf.image.convert_image_dtype(image, tf.float32)
  
  # All other transformations (during training), in my case:
  image = tf.random_crop(image, [224, 224, 3])
  image = tf.image.random_flip_left_right(image)
  
  # During testing:
  image = tf.image.resize_image_with_crop_or_pad(image, 224, 224)
  </code></pre>
  <p>However, using the aforementioned transformation, the results I am getting suggest that something might be wrong. Moreover, the <a href="https://arxiv.org/pdf/1512.03385.pdf" rel="nofollow noreferrer">Resnet paper</a> is saying that the images should be preprocessed by:</p>
  <blockquote>
  <p>A 224×224 crop is randomly sampled from an image or its
  horizontal flip, with the per-pixel mean subtracted...</p>
  </blockquote>
  <p>which I can't quite understand what is means. Can someone point me in the right direction?</p>
  <p>Looking forward to you answers!</p>