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

编程入门 行业动态 更新时间:2024-10-24 18:20:58
本文介绍了tensorflow:如何旋转图像以进行数据增强?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

在 tensorflow 中,我想从随机角度旋转图像,以进行数据增强.但是我在 tf.image 模块中没有找到这种转换.

In tensorflow, I would like to rotate an image from a random angle, for data augmentation. But I don't find this transformation in the tf.image module.

推荐答案

更新:见下方@astromme 的回答.Tensorflow 现在支持原生旋转图像.

Update: see @astromme's answer below. Tensorflow now supports rotating images natively.

在 tensorflow 中没有本地方法的情况下你可以做的事情是这样的:

What you can do while there is no native method in tensorflow is something like this:

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))

这篇关于tensorflow:如何旋转图像以进行数据增强?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

更多推荐

[db:关键词]

本文发布于:2023-05-01 05:18:43,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1405173.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:图像   数据   tensorflow

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!