无法将Keras Generator图像传递到面部识别

问题描述 投票:0回答:1

我正在使用Keras生成用于馈送face_recognition包的图片。

以下我用来阅读和准备要传递给生成器的图片的代码

image = cv2.imread(imagePath)
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)

image = np.expand_dims(image, axis=0)
imageGen = aug.flow(image, batch_size=1)

然后用于生成的图像,如下所示:

for gimage in imageGen:
   face_recognition.face_locations(gimage, 'cnn')

RuntimeError:不支持的图像类型,必须为8位灰度或RGB图像。

我试图在传递生成的图片之前使用squeeze解决该问题;但这也没有用

gimage = np.squeeze(gimage, axis=0)
python keras face-recognition data-augmentation
1个回答
0
投票

您应该检查gimage ndarray的值dtype。它应该是uint8,并且根据错误,看起来现在是float32

© www.soinside.com 2019 - 2024. All rights reserved.