上传照片bug
This commit is contained in:
parent
b88ad25749
commit
cb2986ca91
|
@ -40,9 +40,9 @@ class HRMService:
|
||||||
return user, ''
|
return user, ''
|
||||||
return None, '识别失败'
|
return None, '识别失败'
|
||||||
|
|
||||||
def get_facedata_from_img(cls, img_rpath):
|
def get_facedata_from_img(cls, img_path):
|
||||||
try:
|
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)
|
picture_of_me = face_recognition.load_image_file(photo_path)
|
||||||
my_face_encoding = face_recognition.face_encodings(picture_of_me)[0]
|
my_face_encoding = face_recognition.face_encodings(picture_of_me)[0]
|
||||||
face_data_list = my_face_encoding.tolist()
|
face_data_list = my_face_encoding.tolist()
|
||||||
|
|
|
@ -42,7 +42,7 @@ class EmployeeViewSet(CreateUpdateModelAMixin, OptimizationMixin, UpdateModelMix
|
||||||
serializer.is_valid(raise_exception=True)
|
serializer.is_valid(raise_exception=True)
|
||||||
photo = data.get('photo', None)
|
photo = data.get('photo', None)
|
||||||
if instance.photo != photo:
|
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:
|
if f_l:
|
||||||
serializer.save(update_by=request.user, face_data = f_l)
|
serializer.save(update_by=request.user, face_data = f_l)
|
||||||
# 更新人脸缓存
|
# 更新人脸缓存
|
||||||
|
|
Loading…
Reference in New Issue