diff --git a/hb_server/apps/hrm/services.py b/hb_server/apps/hrm/services.py index 7f7334b..1a793b1 100644 --- a/hb_server/apps/hrm/services.py +++ b/hb_server/apps/hrm/services.py @@ -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() diff --git a/hb_server/apps/hrm/views.py b/hb_server/apps/hrm/views.py index 8755b18..89dfa66 100644 --- a/hb_server/apps/hrm/views.py +++ b/hb_server/apps/hrm/views.py @@ -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) # 更新人脸缓存