Operands could not be broadcast together with shapes (128,) (0,) error

General Tech Bugs & Fixes 2 years ago

0 2 0 0 0 tuteeHUB earn credit +10 pts

5 Star Rating 1 Rating

Posted on 16 Aug 2022, this text provides information on Bugs & Fixes related to General Tech. Please note that while accuracy is prioritized, the data presented might not be entirely correct or up-to-date. This information is offered for general knowledge and informational purposes only, and should not be considered as a substitute for professional advice.

Take Quiz To Earn Credits!

Turn Your Knowledge into Earnings.

tuteehub_quiz

Answers (2)

Post Answer
profilepic.png
manpreet Tuteehub forum best answer Best Answer 2 years ago

 

I am trying to implement a facial recognition login system but I have an error "Operands could not be broadcast together with shapes (128,) (0,)" and I have no idea what or how can I solve it. Here are my view.py and facedetector.py that have been implemented and the error that I get from my server:

errors

Traceback (most recent call last):
File "C:\django-projects\lib\site packages\django\core\handlers\exception.py", line 34, in inner
response = get_response(request)
File "C:\django-projects\lib\site-packages\django\core\handlers\base.py", 
line 126, in _get_response
response = self.process_exception_by_middleware(e, request)
File "C:\django-projects\lib\site-packages\django\core\handlers\base.py", line 124, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "C:\django-projects\aps\aps_site\authenticate\views.py", line 54, in login_user
if facedect(user.userprofile.head_shot.url):
File "C:\django-projects\aps\aps_site\authenticate\views.py", line 37, in facedect
check=face_recognition.compare_faces(face_1_face_encoding, face_encodings)
File "C:\django-projects\lib\site-packages\face_recognition\api.py", line 222, in compare_faces
return list(face_distance(known_face_encodings, face_encoding_to_check) <= tolerance)
File "C:\django-projects\lib\site-packages\face_recognition\api.py", line 72, in face_distance
return np.linalg.norm(face_encodings - face_to_compare, axis=1) 
ValueError: operands could not be broadcast together with shapes (128,) (0,)

views.py

from django.shortcuts import render, redirect
from django.contrib.auth import authenticate, login, logout, 
update_session_auth_hash
from django.contrib.auth.forms import UserCreationForm, UserChangeForm, PasswordChangeForm
from django.contrib import messages
from .forms import SignUpForm, EditProfileForm
from django.urls import path, include
import os
import face_recognition
import cv2 

# Create your views here.

def home(request):
    return render(request, 'authenticate/home.html', {})

def facedect
                                                
                                                
0 views
0 shares
profilepic.png
manpreet 2 years ago

Did you got solution?
if yes, please help me I am having same problem. I have asked you on stackverflow too and send you request on linkdin.


0 views   0 shares

No matter what stage you're at in your education or career, TuteeHub will help you reach the next level that you're aiming for. Simply,Choose a subject/topic and get started in self-paced practice sessions to improve your knowledge and scores.