如何在张量流中进行图像旋转? [英] How to do image rotation in tensorflow?

查看:38
本文介绍了如何在张量流中进行图像旋转?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想对我自己的数据集进行一些严肃的图像增强,因为它真的很小.Tensorflow 提供了图像库来做所有的扩充,非常方便.但是没有旋转"功能.我知道此处 有一个问题,但它太长而且看起来很复杂.有没有什么简单的方法/功能可以在 tensorflow 中进行图像旋转?非常感谢您.

I want to do some serious image augmentations on my own dataset because it is really small. Tensorflow provides the image library to do all the augmentation, which is very convenient. But there is no "rotation" functionality. I know there is an issue tracked here, but it is so long and looks complicated. Is there any simple way/function to do image rotation in tensorflow? thank you very much.

推荐答案

如果您想使用自己的图像旋转,您可以使用 py_func、PIL 和您自己的队列处理器来实现.或者,您可以编写自己的队列来提供示例.另一种丑陋的方法是在训练进行的同时以原子方式(写入 + 重命名)旋转这些图像并将它们以相同的文件名写入磁盘.

If you want to use your own image rotation, you could probably do that with py_func, PIL and your own queue processor. Alternatively, you could write your own queue to feed examples. Another ugly way, is to atomically (write + rename) rotate these images and write them on disk with the same filename, while the training is going on.

无论您做什么,请记住我们是分批训练的,因此请确保一次轮换一次,而不是连续提供同一图像的所有变体(shuffle(rotations([image]) 是不是 rotations(shuffle([image]))),否则训练会出错.

Whatever you do, remember that we train in batches, so make sure you serve rotations one at a time, not all variants of the same image contiguously (shuffle(rotations([image]) is not rotations(shuffle([image]))), otherwise training will misbehave.

这篇关于如何在张量流中进行图像旋转?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆