【发布时间】:2022-06-22 21:18:21
【问题描述】:
我正在尝试从本地文件夹加载数据集并将其用作 tf 数据集。文件夹结构为:
../dataset/
class_0/
class_1/
其中 0 类子文件夹包含所有 0 类和 1 类所有 1 类图像。
为了实现这一点,我的代码是:
images = image_dataset_from_directory('../dataset/',
shuffle=True,
batch_size=32,
image_size=(1080,1920))
所有图片的大小为(1080,1920,3) 或(1920,1080,3)
我正在尝试使用以下方式显示图像:
for image, labels in images.take(1):
img = image[0].numpy() # take first image of batch
print(img.shape)
img = Image.fromarray(img, 'RGB')
img.save('my.png')
img.show()
打印图像形状=(1080, 1920, 3)
但是,PIL 显示的图像失真,看起来像是随机噪声。
知道我做错了什么吗?
【问题讨论】:
标签: image tensorflow tensorflow2.0 tensorflow-datasets