使用django登录的人脸识别 [英] Face Recognisation for login using django

查看:170
本文介绍了使用django登录的人脸识别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试实现面部识别登录系统,但出现错误无法将操作数与形状(128,)(0,)一起广播",并且我不知道如何解决或如何解决它.这是我已执行的view.py和facedetector.py以及从服务器获取的错误:

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:

链接到完整的项目 https://github.com/Vampboy/Face-Recognition-登录系统
以前有人已经问过这个问题

link to complete project https://github.com/Vampboy/Face-Recognition-Login-System
someone has already asked this question previously Operands could not be broadcast together with shapes (128,) (0,) error but didn't get much response. probably because he didn't provided complete code.

我正在得到错误提示:

Environment:


Request Method: POST
Request URL: http://127.0.0.1:8000/base/

Django Version: 2.2.3
Python Version: 3.6.8
Installed Applications:
['django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'pages']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware']



Traceback:

File "/home/tiktok/.local/lib/python3.6/site-packages/django/core/handlers/exception.py" in inner
  34.             response = get_response(request)

File "/home/tiktok/.local/lib/python3.6/site-packages/django/core/handlers/base.py" in _get_response
  115.                 response = self.process_exception_by_middleware(e, request)

File "/home/tiktok/.local/lib/python3.6/site-packages/django/core/handlers/base.py" in _get_response
  113.                 response = wrapped_callback(request, *callback_args, **callback_kwargs)

File "/var/www/django_app/djangoproject/mysite/pages/views.py" in base
  54.                                 if facedect(user.userprofile.head_shot.url):

File "/var/www/django_app/djangoproject/mysite/pages/views.py" in facedect
  33.                 check=face_recognition.compare_faces(face_1_face_encoding, face_encodings)

File "/home/tiktok/.local/lib/python3.6/site-packages/face_recognition/api.py" in compare_faces
  222.     return list(face_distance(known_face_encodings, face_encoding_to_check) <= tolerance)

File "/home/tiktok/.local/lib/python3.6/site-packages/face_recognition/api.py" in face_distance
  72.     return np.linalg.norm(face_encodings - face_to_compare, axis=1)

Exception Type: ValueError at /base/
Exception Value: operands could not be broadcast together with shapes (128,) (0,) 

推荐答案

face_recognition.compare_faces 函数的第一个参数应为 中所述).将您的 djangoproject/mysite/pages/views.py 第33行更改为:

The first argument for face_recognition.compare_faces function should be a list as stated in the documentation. Change your djangoproject/mysite/pages/views.py line 33 to:

check=face_recognition.compare_faces([face_1_face_encoding], face_encodings)

解决异常的原因.

这篇关于使用django登录的人脸识别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆