【问题标题】:batch image augment in tensorflow张量流中的批量图像增强
【发布时间】:2018-09-30 07:30:57
【问题描述】:

我想做图像增强,例如在张量流中旋转随机角度。在每批中,我想为每张图片旋转不同的随机角度。我可以通过使用 tf.contrib.image.rotateimage_batch 和随机生成的角度张量来做到这一点:

radian = tf.random_uniform(
    (batch_size),  
    minval=-ROT_TH,
    maxval=ROT_TH,
    dtype=tf.float32,
    seed=None,
    name=None
)
rotated_batch = tf.contrib.image.rotate(image_batch, radian)

但是,如果我使用allow_smaller_final_batch=True 构建批处理,batch_size 将毫无用处,因为image_batch 没有固定的批处理大小。并且旋转会失败,因为弧度和image_batch的N维不一样。

我该如何解决?

【问题讨论】:

    标签: python tensorflow data-augmentation


    【解决方案1】:

    我没有批量旋转图像,而是对来自image_queue.deque()的图像应用了相同的旋转:

    images = load_images(filenames, options)
    radian = tf.random_uniform([len(images)], ...)
    images =  tf.contrib.image.rotate(images, radian)
    
    image_batch = tf.train.batch_join([images, filenames],
                                      enqueue_many=True, allow_smaller_final_batch=True,
                                      batch_size=WHATEVER)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-07-02
      • 2018-04-04
      • 1970-01-01
      • 1970-01-01
      • 2017-11-15
      • 2019-01-27
      相关资源
      最近更新 更多