他,我在用flow_from_dataframe来管理图像,但是在计算结束的时候,我得到了所有错误的图像像素,下面我展示了我所有的代码,有人能帮我吗
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()发布于 2020-06-01 20:54:10
在张量流库中,有一个处理resize函数的bug,因此我为图像构建了一个自定义生成器
https://stackoverflow.com/questions/61903655
复制相似问题