def image_preprocessing(image, train):
"""Decode and preprocess one image for evaluation or training.
Args:
image: JPEG
train: boolean
Returns:
3-D float Tensor containing an appropriately scaled image
Raises:
ValueError: if user does not provide bounding box
"""
with tf.name_scope('image_preprocessing'):
if train:
image = tf.image.random_flip_left_right(image)
image = tf.image.random_brightness(image, 0.6)
if FLAGS.image_channel >= 3:
image = tf.image.random_saturation(image, 0.6, 1.4)
# Finally, rescale to [-1,1] instead of [0, 1)
image = tf.subtract(image, 0.5)
image = tf.multiply(image, 2.0)
image = tf.image.per_image_standardization(image)
return image
评论列表
文章目录