Python &引用;TypeError:';的操作数类型不受支持;列表';和';列表'&引用;使用人脸识别模块时

Python &引用;TypeError:';的操作数类型不受支持;列表';和';列表'&引用;使用人脸识别模块时,python,python-3.x,numpy,face-recognition,Python,Python 3.x,Numpy,Face Recognition,这是我的密码: import face_recognition image = face_recognition.load_image_file("images/me.jpg") my_face_encoding = face_recognition.face_encodings(image)[0] unknown_face_encoding = """[-1.24054216e-01 7.84611031e-02 1.30224943e-01 -9.93825272e-02 -1.5

这是我的密码:

import face_recognition

image = face_recognition.load_image_file("images/me.jpg")
my_face_encoding = face_recognition.face_encodings(image)[0]

unknown_face_encoding = """[-1.24054216e-01  7.84611031e-02  1.30224943e-01 -9.93825272e-02
 -1.54951781e-01 -2.31261551e-02 -1.49395000e-02 -1.26060829e-01
  2.01227441e-01 -1.06694490e-01  1.13739245e-01  4.98759709e-02
 -2.01444834e-01  7.44614825e-02 -5.97176738e-02  2.09760502e-01
 -1.42870039e-01 -1.00220293e-01 -8.31034407e-02 -9.54630375e-02
  4.45789173e-02  1.09126575e-01  3.59398499e-02  1.45934403e-01
 -1.93168193e-01 -3.01777571e-01 -1.07183568e-01 -7.31595308e-02
 -1.50131527e-04 -2.95262784e-02  3.00722718e-02  9.44098681e-02
 -1.63059399e-01  5.54478317e-02  3.09961736e-02  6.91680238e-02
 -2.36961320e-02 -4.18790579e-02  1.70652434e-01  4.25888747e-02
 -2.58502364e-01  3.65842879e-03  1.32888258e-01  2.31185630e-01
  2.81271577e-01  1.44403130e-02  8.59352276e-02 -1.08848065e-01
  1.75538525e-01 -3.06716532e-01  6.62894472e-02  1.04040325e-01
 -5.53213134e-02  1.08352706e-01  1.18429989e-01 -2.05909565e-01
  2.65853405e-02  1.08228736e-01 -1.17990330e-01  7.82525465e-02
  6.94117099e-02 -5.28226048e-02  2.02369466e-02 -2.68464088e-02
  2.33285502e-01  8.07429850e-02 -1.29087821e-01 -1.28810719e-01
  1.98019177e-01 -2.59635717e-01 -4.34794649e-02  9.55134556e-02
 -1.32557303e-01 -1.18004754e-01 -2.90254027e-01 -1.90082639e-02
  5.07782936e-01  1.99330628e-01 -1.46220222e-01  7.97692090e-02
 -1.13908842e-01 -1.16385147e-02  5.90377226e-02  1.37809873e-01
 -2.40938645e-02  1.17124617e-03 -5.54608963e-02  3.41117531e-02
  2.89724678e-01  3.09800580e-02  6.90461844e-02  3.82040054e-01
  8.85144323e-02  3.87038141e-02  1.42093441e-02  6.16699830e-02
 -1.69911921e-01 -6.57835901e-02 -1.20271772e-01 -5.29541224e-02
 -8.85188803e-02  5.68684936e-03  5.43909445e-02  1.38657838e-01
 -2.57879019e-01  3.05829167e-01 -3.75086144e-02  4.14556079e-02
 -4.64754403e-02  9.00954455e-02 -7.38727376e-02 -1.81735009e-02
  1.66310221e-01 -1.80386350e-01  1.40203476e-01  1.27873331e-01
  1.20235216e-02  1.15767881e-01  3.11074629e-02  1.28806829e-01
 -3.93882245e-02 -2.29371041e-02 -1.12116128e-01  7.39342347e-03
  6.12975173e-02 -1.92527130e-01  4.17169631e-02  7.89699629e-02]"""

results = face_recognition.compare_faces([my_face_encoding], unknown_face_encoding, tolerance=0.9)

if __name__ == "__main__":
    print(results)
我正在使用
face\u recognition
模块获取人脸编码,并将一种人脸编码与另一种人脸编码进行比较。但问题是,当我在变量中放入人脸编码时,它会给我这个错误

回溯(最近一次呼叫最后一次):

文件“/Users/john/Dev/face/compare.py”,第30行,在
结果=面部识别。比较面部([我的面部编码]、未知面部编码、公差=0.9)
文件“/usr/local/lib/python3.7/site packages/face\u recognition/api.py”,第226行,在compare\u faces中

返回列表(面距离(已知面编码,面编码到检查)查看代码后,我发现您使用了“未知面编码”作为字符串,将其转换为浮点数,并且不同的数字之间没有逗号,例如。[-1.24054216e-01,7.84611031e-02

“未知\u面\u编码”转换为浮点数组后,从中的[我的面\u编码]中删除列表符号

    face_recognition.compare_faces([my_face_encoding], ... ) 
换成

    face_recognition.compare_faces( my_face_encoding, ...)
我希望有帮助


谢谢

看到您的代码后,我发现您使用了“未知面编码”作为字符串,将其转换为浮点数,并且不同的数字之间没有逗号,例如。[-1.24054216e-01,7.84611031e-02

“未知\u面\u编码”转换为浮点数组后,从中的[我的面\u编码]中删除列表符号

    face_recognition.compare_faces([my_face_encoding], ... ) 
换成

    face_recognition.compare_faces( my_face_encoding, ...)
我希望有帮助

多谢各位