Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem "ValueError: operands could not be broadcast together with shapes ( , ) (128, )" Solution #1541

Open
MrLangZe opened this issue Nov 21, 2023 · 0 comments

Comments

@MrLangZe
Copy link

MrLangZe commented Nov 21, 2023

  • face_recognition version:
  • Python version: 3.8.18
  • Operating System: Windows 11

Description

When I tried to run the /examples/facerec_from_webcam_faster.py, I found the error which is "ValueError: operands could not be broadcast together with shapes ( , ) (128, )".
There may be three possible reasons to cause the problem which I will show below.

What I Did

1.Check your image file encoding index.Get your image encoding by this way:
your_image = face_recognition.load_image_file("../your.jpg")
your_face_encoding = face_recognition.face_encodings(your_image)[0]

2.The parameter "face_location" in method "face_encodings" may not need when you first run the demo.So you can change the code like this:
face_locations = face_recognition.face_locations(rgb_small_frame)
face_encodings = face_recognition.face_encodings(rgb_small_frame)

3.The BGR image can be converted to RGB image by using cv2.cvtColor like this:
rgb_small_frame = cv2.cvtColor(small_frame, cv2.COLOR_BGR2RGB)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant