face_encoding函数返回错误

当调用face_encodings函数时,我遇到了以下错误。

TypeError: __call__(): incompatible function arguments. The following argument types are supported:    1. (self: dlib.fhog_object_detector, image: array, upsample_num_times: int=0) -> dlib.rectanglesInvoked with: <dlib.fhog_object_detector object at 0x7f066f834340>, '36121754-36121734.jpg', 2

这是我的代码

  img = plt.imread(face)  plt.imshow(img)  x=face_recognition.load_image_file(face)  x_code = face_recognition.face_encodings(face)[0]

图像路径是正确的,因为我尝试输出图像时,它显示load_image_file()已经执行并返回了一个数字数组。

我不确定哪里出了问题。

可能的错误原因是load_image_file或face_encodings的输入类型。

face-recognition文档链接


回答:

问题出在传递给face_encoding()的参数变量上。

正确的做法是:

x=face_recognition.load_image_file(face)x_code = face_recognition.face_encodings(x)[0]

原因是:

根据face-recognition库,load_image_file是一个初始函数,我们将文件传递给它并存储在一个变量中(在我这里是变量x)。

之后,对于face_recognition包的任何其他函数,我们必须传递变量x,而不是文件名。

PS:那错误详情仍然让我感到害怕

Related Posts

使用LSTM在Python中预测未来值

这段代码可以预测指定股票的当前日期之前的值,但不能预测…

如何在gensim的word2vec模型中查找双词组的相似性

我有一个word2vec模型,假设我使用的是googl…

dask_xgboost.predict 可以工作但无法显示 – 数据必须是一维的

我试图使用 XGBoost 创建模型。 看起来我成功地…

ML Tuning – Cross Validation in Spark

我在https://spark.apache.org/…

如何在React JS中使用fetch从REST API获取预测

我正在开发一个应用程序,其中Flask REST AP…

如何分析ML.NET中多类分类预测得分数组?

我在ML.NET中创建了一个多类分类项目。该项目可以对…

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注