(image)
return distorted_image
Augmentation the image with a random modification.

  Args:
    image: input Tensor image of rank 3, with the last dimension
           of size 3.

  Returns:
    Distorted Tensor image of the same shape.
Augmentation the image with a random modification.
Augmentation the image with a random modification .
def augment_image(image):
  """Augmentation the image with a random modification.

  Args:
    image: input Tensor image of rank 3, with the last dimension
           of size 3.

  Returns:
    Distorted Tensor image of the same shape.
  """
  with tf.variable_scope('AugmentImage'):
    height = image.get_shape().dims[0].value
    width = image.get_shape().dims[1].value

    # Random crop cut from the street sign image, resized to the same size.
    # Assures that the crop is covers at least 0.8 area of the input image.
    bbox_begin, bbox_size, _ = tf.image.sample_distorted_bounding_box(
        tf.shape(image),
        bounding_boxes=tf.zeros([0, 0, 4]),
        min_object_covered=0.8,
        aspect_ratio_range=[0.8, 1.2],
        area_range=[0.8, 1.0],
        use_image_if_no_bounding_boxes=True)
    distorted_image = tf.slice(image, bbox_begin, bbox_size)

    # Randomly chooses one of the 4 interpolation methods
    distorted_image = inception_preprocessing.apply_with_random_selector(
        distorted_image,
        lambda x, method: tf.image.resize_images(x, [height, width], method),
        num_cases=4)
    distorted_image.set_shape([height, width, 3])

    # Color distortion
    distorted_image = inception_preprocessing.apply_with_random_selector(
        distorted_image,
        functools.partial(
            inception_preprocessing.distort_color, fast_mode=False),
        num_cases=4)
    distorted_image = tf.clip_by_value(distorted_image, -1.5, 1.5)

  return distorted_image
def augment_image ( image ) : with tf . variable_scope ( 'AugmentImage' ) : height = image . get_shape ( ) . dims [ 0 ] . value width = image . get_shape ( ) . dims [ 1 ] . value # Random crop cut from the street sign image, resized to the same size. # Assures that the crop is covers at least 0.8 area of the input image. bbox_begin , bbox_size , _ = tf . image . sample_distorted_bounding_box ( tf . shape ( image ) , bounding_boxes = tf . zeros ( [ 0 , 0 , 4 ] ) , min_object_covered = 0.8 , aspect_ratio_range = [ 0.8 , 1.2 ] , area_range = [ 0.8 , 1.0 ] , use_image_if_no_bounding_boxes = True ) distorted_image = tf . slice ( image , bbox_begin , bbox_size ) # Randomly chooses one of the 4 interpolation methods distorted_image = inception_preprocessing . apply_with_random_selector ( distorted_image , lambda x , method : tf . image . resize_images ( x , [ height , width ] , method ) , num_cases = 4 ) distorted_image . set_shape ( [ height , width , 3 ] ) # Color distortion distorted_image = inception_preprocessing . apply_with_random_selector ( distorted_image , functools . partial ( inception_preprocessing . distort_color , fast_mode = False ) , num_cases = 4 ) distorted_image = tf . clip_by_value ( distorted_image , - 1.5 , 1.5 ) return distorted_image