tensorflow:如何旋转图像以进行数据增强?

新手上路,请多包涵

在张量流中,我想从随机角度旋转图像以进行数据扩充。但我没有在 tf.image 模块中找到这种转换。

原文由 Mostafa 发布,翻译遵循 CC BY-SA 4.0 许可协议

阅读 705
2 个回答

更新:请参阅下面@astromme 的回答。 Tensorflow 现在原生支持旋转图像。

当 tensorflow 中没有本地方法时,你可以做的是这样的:

 from PIL import Image
sess = tf.InteractiveSession()

# Pass image tensor object to a PIL image
image = Image.fromarray(image.eval())

# Use PIL or other library of the sort to rotate
rotated = Image.Image.rotate(image, degrees)

# Convert rotated image back to tensor
rotated_tensor = tf.convert_to_tensor(np.array(rotated))

原文由 mathetes 发布,翻译遵循 CC BY-SA 3.0 许可协议

现在可以在 tensorflow 中完成:

 tf.contrib.image.rotate(images, degrees * math.pi / 180, interpolation='BILINEAR')

原文由 Andrew Stromme 发布,翻译遵循 CC BY-SA 3.0 许可协议

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题