首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Tensorflow flow_from_dataframe将所有像素设置为白色

Tensorflow flow_from_dataframe将所有像素设置为白色
EN

Stack Overflow用户
提问于 2020-05-20 09:35:34
回答 1查看 147关注 0票数 0

他,我在用flow_from_dataframe来管理图像,但是在计算结束的时候,我得到了所有错误的图像像素,下面我展示了我所有的代码,有人能帮我吗

代码语言:javascript
复制
batch_size = 12 
train_datagen = ImageDataGenerator(
rescale = 1. / 255,\
zoom_range=0.1,\
rotation_range=10,\
width_shift_range=0.1,\
height_shift_range=0.1,\
horizontal_flip=True,\
vertical_flip=False,)


train_generator_left_cc = train_datagen.flow_from_dataframe(
dataframe=df,
target_size=(256,256),
x_col="left_cc",
y_col=["lb","lm","rb","rm","left_cc"],
color_mode="rgb",
batch_size=batch_size,
class_mode="multi_output",
shuffle=False,
interpolation="bilinear"

)

train_generator_right_cc = train_datagen.flow_from_dataframe(
dataframe=df,
target_size=(256,256),
x_col="right_cc",
y_col=["lb","lm","rb","rm", "right_cc"],
color_mode="rgb",
batch_size=batch_size,
class_mode="multi_output",
shuffle=False,
)

x1,y1=train_generator_left_cc.next()
x2,y2=train_generator_right_cc.next()

i=11
image = x1[i]
label = (y1[0][i],y1[1][i],y1[2][i],y1[3][i],y1[4][i])  # categorical from one-hot-encoding
print("Image shape: ", image.shape)

print(label)
pyplot.imshow(image.squeeze())
pyplot.show()
image = x2[i]
label = (y2[0][i],y2[1][i],y2[2][i],y2[3][i]) # categorical from one-hot-encoding
print(label)
pyplot.imshow(image)
pyplot.show()

#i put the directory of the image in the label of the dataset to make test
image_decoded = tf.image.decode_png(tf.io.read_file(y2[4][i]), channels=3)


arr_ = np.squeeze(image_decoded) 
pyplot.imshow(arr_)
pyplot.show()

这是结果图像:result of the flow_from_dataframe

what i need

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-06-01 20:54:10

在张量流库中,有一个处理resize函数的bug,因此我为图像构建了一个自定义生成器

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/61903655

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档