如何解决ImageDataGenerator无法正确读取TIFF数据集
我有一个要加载的数据集,其中包含人群图像(rgb-jpg)和密度图(tiff)作为标签。但是,读取这些图像很麻烦,因为它们似乎无法正确加载。
# Train model
model.fit(
x=train_generator,steps_per_epoch=STEPS_PER_EPOCH,epochs=EPOCHS,callbacks=[model_checkpoint_callback]
)
其中train_generator
是一个生成器,产生一个(img,label)
元组,它本身是从两个单独的DirectoryIterators
返回的,其定义如下:
img_datagen = ImageDataGenerator()
# Add images to datagenerator
img_generator = img_datagen.flow_from_directory(
directory='dataset/train_data',target_size=(768,1024),color_mode='rgb',classes=['image'],class_mode=None,batch_size=2,shuffle=True,seed=None,interpolation='bilinear'
)
# Similarly for the label generator,# with the exception of classes
# being ['label'] and the
# color_mode of the label
# being grayscale
# Zip them into tuples
zipped = zip(img_generator,gt_generator)
for (img,label) in zipped:
# Hijacked this line to load plots,images
yield (img,label)
不仅无法读取我的jpg图像,而且tiff标签已加载为完整零。 original-image label-zero
但是,如果将图像加载为灰度图像,则可以看到它,但是密度图仍为零。 original-image-grayscale
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。