Esempio n. 1
0
def preprocess_image(image,label,is_training):
'''preprocess a single image of layout[h,w,depth]'''
    if is_training:
        image,label=preprocessing.randm_rescale_image_and_label(
            image,label,_MIN_SCALE,_MAX_SCALE)
        #randomly crop or pad a [_HEIGHT,_WIDTH] selection of the image and label
        image,label=preprocessing.random_crop_or_pad_image_and_label(
            image,label,_HEIGHT,_WIDTH,_IGNORE_LABEL)
        #Randomly flip the image and label horizontally.
        image, label = preprocessing.random_flip_left_right_image_and_label(
            image, label)
Esempio n. 2
0
def preprocess_image(image, sem, disp, is_training):
    """Preprocess a single image of layout [height, width, depth]."""

    disp_ori = disp
    disp_ori.set_shape([_EVAL_HEIGHT, _EVAL_WIDTH, 1])

    if is_training:
        # Randomly scale the image and label.
        image, sem, disp = preprocessing.random_rescale_image_and_label(
            image, sem, disp, _HEIGHT, _WIDTH, _EVAL_WIDTH / _WIDTH,
            _MIN_SCALE, _MAX_SCALE)

        # Randomly crop or pad a [_HEIGHT, _WIDTH] section of the image and label.
        image, sem, disp = preprocessing.random_crop_or_pad_image_and_label(
            image, sem, disp, _HEIGHT, _WIDTH, _IGNORE_LABEL)

        # Randomly flip the image and label horizontally.
        image, sem, disp = preprocessing.random_flip_left_right_image_and_label(
            image, sem, disp)

        image.set_shape([_HEIGHT, _WIDTH, 3])
        sem.set_shape([_HEIGHT, _WIDTH, 1])
        disp.set_shape([_HEIGHT, _WIDTH, 1])
    else:
        image.set_shape([None, None, 3])
        image = tf.image.resize_images(image, (_HEIGHT, _WIDTH),
                                       method=tf.image.ResizeMethod.BILINEAR)

        sem.set_shape([None, None, 1])
        sem = tf.image.resize_images(sem, (_HEIGHT, _WIDTH),
                                     method=tf.image.ResizeMethod.BILINEAR)
        sem = tf.to_int32(sem)

        disp.set_shape([None, None, 1])

        disp = tf.image.resize_images(disp, (_HEIGHT, _WIDTH),
                                      method=tf.image.ResizeMethod.BILINEAR)
        disp = tf.to_int32(disp)

    image = preprocessing.mean_image_subtraction(image)
    disp = preprocessing.normalization(disp, dataset=FLAGS.dataset)

    return image, sem, disp
Esempio n. 3
0
def preprocess_image(image, label, is_training):
  """Preprocess a single image of layout [height, width, depth]."""
  if is_training:
    # Randomly scale the image and label.
    image, label = preprocessing.random_rescale_image_and_label(
        image, label, _MIN_SCALE, _MAX_SCALE)

    # Randomly crop or pad a [_HEIGHT, _WIDTH] section of the image and label.
    image, label = preprocessing.random_crop_or_pad_image_and_label(
        image, label, _HEIGHT, _WIDTH, _IGNORE_LABEL)

    # Randomly flip the image and label horizontally.
    image, label = preprocessing.random_flip_left_right_image_and_label(
        image, label)

    image.set_shape([_HEIGHT, _WIDTH, 3])
    label.set_shape([_HEIGHT, _WIDTH, 1])

  image = preprocessing.mean_image_subtraction(image)

  return image, label