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.
I am trying to implement a facial recognition loginsystem 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,inlogin_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
returnlist(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 importUserCreationForm,UserChangeForm,PasswordChangeFormfrom django.contrib import messages
from.forms importSignUpForm,EditProfileFormfrom 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
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.
manpreet
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
views.py