Python DeepFace verify()可以接受图像数组或PIL图像对象吗?
我的深度脸实现Python DeepFace verify()可以接受图像数组或PIL图像对象吗?,python,image,python-imaging-library,verify,Python,Image,Python Imaging Library,Verify,我的深度脸实现 def verify(img, frame, model): results= DeepFace.verify(img, frame, enforce_detection=False, model_name=model) print("result: ", results) verification= results['verified'] if verification is True: print(model
def verify(img, frame, model):
results= DeepFace.verify(img, frame, enforce_detection=False, model_name=model)
print("result: ", results)
verification= results['verified']
if verification is True:
print(model, "Successfully recognised. SCORE=")
return
return
我试图传递一个PIL图像而不是“*.jpg”来验证()函数,但它给出了错误
raise ValueError("Invalid arguments passed to verify function: ", instance)
ValueError: ('Invalid arguments passed to verify function: ', <PIL.Image.Image image mode=RGB size=160x160 at 0x7F4D5D03FBE0>)
请注意,我仍然可以通过将图像保存在目录中,然后使用imread()读取来成功实现DeepFace。我只想知道是否有其他方法不将图像保存到磁盘如果您使用的是模块,文档中会说:
在此,面部对可以是精确的图像路径、numpy阵列或base64编码图像
因此,您可以将PIL图像制作成如下Numpy数组:
results = DeepFace.verify(np.array(PILIMAGE), ...)
非常感谢兄弟,我按照你的方式得到了我的结果 对于其他人: 当我跟随兄弟MarkSetchell时,我再次遇到了错误,但这正是因为我将一个输入作为path传递,另一个作为numpy数组传递。 如果必须传递numpy数组,请确保为两个输入参数传递它
picture= "extracted_face_picture/single_face_picture.jpg"
picture= Image.open(picture)
.
.
df.verify(picture, np.array(frame), "Facenet")
更正:
df.verify(np.array(picture),np.array(frame), "Facenet")
非常感谢马克·塞切尔兄弟。非常感谢
df.verify(np.array(picture),np.array(frame), "Facenet")