人脸识别调整
This commit is contained in:
parent
b61212980b
commit
62ca3cefbd
|
@ -31,22 +31,22 @@ class HRMService:
|
|||
face_users = cache.get('face_users')
|
||||
try:
|
||||
results = face_recognition.compare_faces(face_datas,
|
||||
unknown_face_encoding, tolerance=0.4)
|
||||
unknown_face_encoding, tolerance=0.45)
|
||||
except:
|
||||
return None, '人脸未匹配'
|
||||
return None, '人脸未匹配1'
|
||||
for index, value in enumerate(results):
|
||||
if value:
|
||||
# 识别成功
|
||||
user = User.objects.get(id=face_users[index])
|
||||
return user, ''
|
||||
return None, '人脸未匹配'
|
||||
return None, '人脸未匹配2'
|
||||
|
||||
@classmethod
|
||||
def get_facedata_from_img(cls, img_path):
|
||||
try:
|
||||
photo_path = settings.BASE_DIR + img_path
|
||||
picture_of_me = face_recognition.load_image_file(photo_path)
|
||||
my_face_encoding = face_recognition.face_encodings(picture_of_me, num_jitters=10)[0]
|
||||
my_face_encoding = face_recognition.face_encodings(picture_of_me)[0]
|
||||
face_data_list = my_face_encoding.tolist()
|
||||
return face_data_list, ''
|
||||
except:
|
||||
|
|
|
@ -25,21 +25,25 @@ from rest_framework import routers
|
|||
from rest_framework.documentation import include_docs_urls
|
||||
from django.views.generic import TemplateView
|
||||
from utils.view import GenSignature, UpdateDevelop
|
||||
|
||||
import os
|
||||
router = routers.DefaultRouter()
|
||||
router.register('', FileViewSet, basename="file")
|
||||
|
||||
schema_view = get_schema_view(
|
||||
openapi.Info(
|
||||
schema_dict = dict(
|
||||
info=openapi.Info(
|
||||
title="航玻ERP API",
|
||||
default_version='v1',
|
||||
contact=openapi.Contact(email="caoqianming@foxmail.com"),
|
||||
license=openapi.License(name="MIT License"),
|
||||
),
|
||||
public=True,
|
||||
permission_classes=[],
|
||||
url="http://49.232.14.174:2222/"
|
||||
)
|
||||
permission_classes=[],)
|
||||
|
||||
if os.getenv('DJANGO_SETTINGS_MODULE') != 'server.settings_dev':
|
||||
schema_dict['url'] = "http://49.232.14.174:2222/"
|
||||
|
||||
schema_view = get_schema_view(**schema_dict)
|
||||
|
||||
|
||||
urlpatterns = [
|
||||
path('api/admin/doc/', include('django.contrib.admindocs.urls')),
|
||||
|
|
Loading…
Reference in New Issue