【问题标题】:Face-recognition results in ValueError: operands could not be broadcast together with shapes (1,1499,1200,3) (128,)人脸识别导致 ValueError:操作数无法与形状一起广播 (1,1499,1200,3) (128,)
【发布时间】:2021-09-29 04:25:29
【问题描述】:

所以我有一些看起来像这样的代码,用于我正在尝试做的人脸识别项目

import cv2
import face_recognition
import matplotlib.pyplot as plt
import numpy as np
path = 'youtube_stuff2/'
vid = cv2.VideoCapture(path+'obama.webm')
obama= face_recognition.load_image_file(path+'obama.jpg')
obama_encodings = face_recognition.face_encodings(obama)[0]
all_encoding = [obama]
images = face_recognition.load_image_file(path+'obama.jpg')
locations = face_recognition.face_locations(images)
encodings = face_recognition.face_encodings(images)
#print(encodings.shape)
print(face_recognition.compare_faces([obama],encodings[0]))



由于它们都是相同的图像,我希望得到“真实”的结果,但我得到了这个


ValueError: operands could not be broadcast together with shapes (1,1499,1200,3) (128,)

我不明白为什么我的编码具有不同的形状,因为它是相同的图像。对此的任何帮助将不胜感激。 P.S 图片链接here

【问题讨论】:

    标签: python face-recognition


    【解决方案1】:

    在这一行

    print(face_recognition.compare_faces([obama],encodings[0]))
    

    使用obama_encodings 而不是obama

    【讨论】:

    • 谢谢。如此简单的修复。
    猜你喜欢
    • 2017-09-09
    • 2012-10-31
    • 2013-04-07
    • 2012-08-05
    • 2018-08-18
    • 2020-06-20
    • 2014-08-24
    • 2018-12-26
    • 2018-02-01
    相关资源
    最近更新 更多