data_augmentation.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:tefla 作者: openAGI 项目源码 文件源码
def random_image_scaling(image, label):
    """Randomly scales the images between 0.5 to 1.5 times the original size.

    Args:
      img: Training image to scale.
      label: Segmentation mask to scale.
    """
    scale = tf.random_uniform(
        [1], minval=0.5, maxval=1.5, dtype=tf.float32, seed=None)
    h_new = tf.to_int32(tf.multiply(tf.to_float(tf.shape(image)[0]), scale))
    w_new = tf.to_int32(tf.multiply(tf.to_float(tf.shape(image)[1]), scale))
    new_shape = tf.squeeze(tf.stack([h_new, w_new]), axis=1)
    image = tf.image.resize_images(image, new_shape)
    label = tf.image.resize_nearest_neighbor(
        tf.expand_dims(label, 0), new_shape)
    label = tf.squeeze(label, axis=0)

    return image, label
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号