上传照片bug

This commit is contained in:
caoqianming 2022-01-26 17:03:24 +08:00
parent b88ad25749
commit cb2986ca91
2 changed files with 3 additions and 3 deletions

View File

@ -40,9 +40,9 @@ class HRMService:
return user, ''
return None, '识别失败'
def get_facedata_from_img(cls, img_rpath):
def get_facedata_from_img(cls, img_path):
try:
photo_path = settings.BASE_DIR + img_rpath
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)[0]
face_data_list = my_face_encoding.tolist()

View File

@ -42,7 +42,7 @@ class EmployeeViewSet(CreateUpdateModelAMixin, OptimizationMixin, UpdateModelMix
serializer.is_valid(raise_exception=True)
photo = data.get('photo', None)
if instance.photo != photo:
f_l = HRMService.get_facedata_from_img(photo)
f_l = HRMService.get_facedata_from_img(img_path=photo)
if f_l:
serializer.save(update_by=request.user, face_data = f_l)
# 更新人脸缓存