feat: 更改为facenet模型
This commit is contained in:
parent
2d59864f65
commit
a763cc00e6
|
@ -430,7 +430,7 @@ class HrmService:
|
||||||
def get_facedata_from_img(cls, img_path):
|
def get_facedata_from_img(cls, img_path):
|
||||||
try:
|
try:
|
||||||
from deepface import DeepFace
|
from deepface import DeepFace
|
||||||
embedding_objs = DeepFace.represent(img_path=img_path)
|
embedding_objs = DeepFace.represent(img_path=img_path, model_name='Facenet')
|
||||||
return embedding_objs[0]["embedding"], ''
|
return embedding_objs[0]["embedding"], ''
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
return None, '人脸数据获取失败请重新上传图片'
|
return None, '人脸数据获取失败请重新上传图片'
|
|
@ -118,7 +118,7 @@ def delete_face_pkl(epId):
|
||||||
photo_path = settings.BASE_DIR + ep.photo
|
photo_path = settings.BASE_DIR + ep.photo
|
||||||
face_path = os.path.join(settings.FACE_PATH, f'{epId}.jpg')
|
face_path = os.path.join(settings.FACE_PATH, f'{epId}.jpg')
|
||||||
shutil.copy(photo_path, face_path)
|
shutil.copy(photo_path, face_path)
|
||||||
file_path = os.path.join(settings.BASE_DIR, 'media/face/representations_vgg_face.pkl')
|
file_path = os.path.join(settings.BASE_DIR, 'media/face/representations_facenet.pkl')
|
||||||
if os.path.exists(file_path):
|
if os.path.exists(file_path):
|
||||||
try:
|
try:
|
||||||
os.remove(file_path)
|
os.remove(file_path)
|
||||||
|
|
|
@ -6,7 +6,7 @@ import time
|
||||||
def face_find(
|
def face_find(
|
||||||
img_path,
|
img_path,
|
||||||
global_face: list,
|
global_face: list,
|
||||||
model_name="VGG-Face",
|
model_name="Facenet",
|
||||||
distance_metric="cosine",
|
distance_metric="cosine",
|
||||||
enforce_detection=True,
|
enforce_detection=True,
|
||||||
detector_backend="opencv",
|
detector_backend="opencv",
|
||||||
|
|
Loading…
Reference in New Issue