煤油ImageDataGenerator.flow带彩色调模

2024-03-28 09:17:41 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在使用python和keras,希望使用keras图像预处理,我的一些图像是rgb,而有些是灰度图像,我需要读取所有这些图像并将灰度图像的维度更改为x、x、3或处理它们,我想把它作为.flow函数的一部分,就像我可以使用color_mode with.flow_from_目录一样,可以设置为rgb并将所有图像作为rgb读取,即使它们是灰度图像, 有可能吗?在


Tags: 函数from图像目录modewithrgbflow
1条回答
网友
1楼 · 发布于 2024-03-28 09:17:41

不能将其作为.flow的一部分,因为这假设您已经将准备好的图像加载到4D张量中。您可以使用.flow_from_directory使用的load_img函数,该函数实际使用color_mode参数:

img = load_img(os.path.join(self.directory, fname),
               color_mode=self.color_mode,
               target_size=self.target_size,
               interpolation=self.interpolation)

这是来自flow_from_directory代码。您可以使用此函数加载图像,然后调用.flow。在

相关问题 更多 >