def create_graph_to_decode_and_normalize_image()

in tensorflow-examples-legacy/label_image/download.py [0:0]


def create_graph_to_decode_and_normalize_image():
  """See file docstring.

  Returns:
    input: The placeholder to feed the raw bytes of an encoded image.
    y: A Tensor (the decoded, normalized image) to be fed to the graph.
  """
  image = tf.placeholder(tf.string, shape=(), name='encoded_image_bytes')
  with tf.name_scope("preprocess"):
    y = tf.image.decode_image(image, channels=3)
    y = tf.cast(y, tf.float32)
    y = tf.expand_dims(y, axis=0)
    y = tf.image.resize_bilinear(y, (IMAGE_HEIGHT, IMAGE_WIDTH))
    y = (y - MEAN) / SCALE
  return (image, y)