简体   繁体   English

keras flow_from_dataframe 用于图像分割(即使用二进制掩码作为标签)

[英]keras flow_from_dataframe for image segmentation (i.e. with a binary mask as label)

Is there a way to use the method "flow_from_dataframe" from keras ( https://keras.io/api/preprocessing/image/#flowfromdataframe-method ) to load an image with a mask?有没有办法使用来自keras( https://keras.io/api/preprocessing/image/#flowfromdataframe-method )的方法“flow_from_dataframe”来加载带有掩码的图像? Such that instead of y being a category, y is a path such that a binary mask gets loaded together with the image.这样,y 不是一个类别,而是一个路径,以便二进制掩码与图像一起加载。

An example dataframe to load the data would be:加载数据的示例数据框是:

+---+---------------------+---------+-------------------------+
|   | img_path            | subject | mask_path               |
+---+---------------------+---------+-------------------------+
| 0 | images/DSC_4540.TIF | 4540    | masks/DSC_4540_mask.tif |
+---+---------------------+---------+-------------------------+
| 1 | images/DSC_9228.TIF | 9228    | masks/DSC_9228_mask.tif |
+---+---------------------+---------+-------------------------+
| 2 | images/DSC_6674.TIF | 6674    | masks/DSC_6674_mask.tif |
+---+---------------------+---------+-------------------------+
| 3 | images/DSC_3453.TIF | 3453    | masks/DSC_3453_mask.tif |
+---+---------------------+---------+-------------------------+
| 4 | images/DSC_6808.TIF | 6808    | masks/DSC_6808_mask.tif |
+---+---------------------+---------+-------------------------+
| 5 | images/DSC_5494.TIF | 5494    | masks/DSC_5494_mask.tif |
+---+---------------------+---------+-------------------------+

You can create a separate ImageDataGenerator for the masks and then zip it with the existing ImageDataGenerator.您可以为掩码创建一个单独的 ImageDataGenerator,然后使用现有的 ImageDataGenerator 将其压缩。

Check out the third example from the documentation .查看文档中的第三个示例。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM