tensorflow - 将 random_shear 增强应用于图像张量
问题描述
我正在尝试random_shear
从 Keras 应用图像增强,但在此之后图像完全失真。
shape = inputs.shape #(32,512,512,3)
temp = np.empty(shape=(shape[0], shape[1],shape[2], shape[3]))
for i in range(shape[0]):
array_inputs = tf.keras.preprocessing.image.img_to_array(inputs[i])
sheared = tf.keras.preprocessing.image.random_shear(array_inputs, .2,
row_axis=0, col_axis=1,
channel_axis=2)
temp[i]= sheared
return tf.convert_to_tensor(temp)
我不确定这里有什么问题。有人可以在这里帮助我吗?
解决方案
值得一提的是,这是我测试的代码:
import tensorflow as tf
import numpy as np
from PIL import Image
inputs = [Image.open('./homersimpson.0.0.jpg')]
shape = (1,1400,1400,3)
temp = np.empty(shape=(shape[0], shape[1],shape[2], shape[3]))
for i in range(shape[0]):
array_inputs = tf.keras.preprocessing.image.img_to_array(inputs[i])
sheared = tf.keras.preprocessing.image.random_shear(array_inputs, 50,
row_axis=0, col_axis=1,
channel_axis=2)
temp[i]= sheared
for i in range(shape[0]):
tf.keras.preprocessing.image.array_to_img(temp[i]).show()
转动这个图像:
对此:
推荐阅读
- ios - 动态集合视图单元格大小调整无法正常工作
- hadoop - 在 HIVE 中创建数据库时权限被拒绝
- excel - VBA:转换为数字
- react-native - 当视频在 expo-video-player 上以 react native 结束时如何提醒某些东西?
- go - 使用多种方式转换十六进制值会导致不同的输出
- flutter - 在 dart/flutter 中使用 [][] 从包含列表的地图索引错误
- python - 我怎样才能让 tkinter 与 time.sleep 一起工作
- python - Pythons round 函数将一半的数字四舍五入到最接近的偶数
- c - 在 C 中,如何从文本流中读取整数列表并将它们转换为数组?
- laravel-6 - [Route: products.show] [URI: products/{product}] 缺少必需参数