Beispiel #1
0
def translate_y(image):
    level = tf.convert_to_tensor(
        (config.AUGMENT_MAGNITUDE / config._MAX_LEVEL) *
        float(config.TRANSLATE_CONST), tf.float32)
    should_flip = tf.cast(tf.floor(tf.random.uniform([]) + 0.5),
                          tf.bool)  # 得到的结果为True和False
    pixels = tf.cond(should_flip, lambda: level, lambda: -level)
    image = image_ops.translate(image, [0, -pixels])
    return image
Beispiel #2
0
def translate_y(image, pixels, replace):
    """Equivalent of PIL Translate in Y dimension."""
    image = contrib_image.translate(wrap(image), [0, -pixels])
    return unwrap(image, replace)
def translate_y(image, pixels, fill_value):
    """Equivalent of PIL Translate in Y dimension."""
    image = tfi.translate(wrap(image), [0, -pixels])
    return unwrap(image, fill_value)
Beispiel #4
0
def translate_x(image, pixels, replace):
  """Equivalent of PIL Translate in X dimension."""
  image = image_ops.translate(wrap(image), [-pixels, 0])
  return unwrap(image, replace)
Beispiel #5
0
def translate_x(image, pixels, replace):
    '''Equivalent of PIL Translate in X dimension.'''
    image = contrib_image.translate(wrap(image), [-pixels, 0])
    return unwrap(image, replace)
Beispiel #6
0
def translate_y(image, pixels, replace):
    """Equivalent of PIL Translate in Y dimension."""
    with tf.name_scope("translate_y"):
        image = image_ops.translate(wrap(image), [0, -pixels])
        return unwrap(image, replace)