fix: face_find_from_base64 bug
This commit is contained in:
parent
19239c6b42
commit
5dded4d235
|
@ -406,12 +406,13 @@ class HrmService:
|
|||
def face_find_from_base64(cls, base64_data):
|
||||
from deepface import DeepFace
|
||||
img_name = str(uuid.uuid4())
|
||||
img_path = settings.BASE_DIR +'/temp/face_' + img_name +'.png'
|
||||
img_path = settings.BASE_DIR +'/temp/face_' + img_name +'.jpg'
|
||||
with open(img_path, 'wb') as f:
|
||||
f.write(base64_data)
|
||||
db_path = os.path.join(settings.BASE_DIR, 'media/face')
|
||||
df = DeepFace.find(img_path=img_path, db_path=db_path, model_name='Facenet512')
|
||||
if df.shape[0] > 0:
|
||||
dfs = DeepFace.find(img_path=img_path, db_path=db_path, model_name='Facenet512')
|
||||
df = dfs[0]
|
||||
if not df.empty:
|
||||
matched = df.iloc[0].identity
|
||||
epId = matched.split('/')[-1].split('.')[0]
|
||||
return Employee.objects.get(id=epId), ''
|
||||
|
|
Loading…
Reference in New Issue