feat: 改用vggface
This commit is contained in:
parent
a9cfeeb48e
commit
1416b83b4e
|
@ -0,0 +1,18 @@
|
|||
# Generated by Django 3.2.12 on 2023-09-11 09:17
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('hrm', '0012_employee_facenet512_data'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RenameField(
|
||||
model_name='employee',
|
||||
old_name='facenet512_data',
|
||||
new_name='facenet_data',
|
||||
),
|
||||
]
|
|
@ -44,7 +44,7 @@ class Employee(CommonBModel):
|
|||
not_work_remark = models.CharField('当前未打卡说明', null=True, blank=True, max_length=200)
|
||||
third_info = models.JSONField('三方信息', default=dict, null=False, blank=True) # 主要是定位卡信息
|
||||
post = models.ForeignKey(Post, verbose_name='所属岗位', on_delete=models.SET_NULL, null=True, blank=True)
|
||||
facenet512_data = models.JSONField('人脸数据', null=True, blank=True)
|
||||
facenet_data = models.JSONField('人脸数据', null=True, blank=True)
|
||||
class Meta:
|
||||
verbose_name = '员工补充信息'
|
||||
verbose_name_plural = verbose_name
|
||||
|
|
|
@ -410,13 +410,13 @@ class HrmService:
|
|||
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')
|
||||
db_path = os.path.join(settings.BASE_DIR, 'media/face')
|
||||
face_df = cache.get('global_face_df', None)
|
||||
if face_df is None:
|
||||
from apps.hrm.tasks import update_global_face_pd
|
||||
face_df = update_global_face_pd()
|
||||
dfs = face_find(img_path=img_path, global_df=face_df)
|
||||
# dfs = DeepFace.find(img_path=img_path, db_path=db_path)
|
||||
# dfs = face_find(img_path=img_path, global_df=face_df)
|
||||
dfs = DeepFace.find(img_path=img_path, db_path=db_path)
|
||||
df = dfs[0]
|
||||
if not df.empty:
|
||||
matched = df.iloc[0].identity
|
||||
|
@ -428,7 +428,7 @@ class HrmService:
|
|||
def get_facedata_from_img(cls, img_path):
|
||||
try:
|
||||
from deepface import DeepFace
|
||||
embedding_objs = DeepFace.represent(img_path=img_path, model_name='Facenet512')
|
||||
embedding_objs = DeepFace.represent(img_path=img_path)
|
||||
return embedding_objs[0]["embedding"], ''
|
||||
except Exception as e:
|
||||
return None, '人脸数据获取失败请重新上传图片'
|
|
@ -130,7 +130,7 @@ def delete_face_pkl(epId):
|
|||
def update_global_face_pd():
|
||||
import pandas as pd
|
||||
facedata = Employee.objects.filter(facenet512_data__isnull=False,
|
||||
user__is_active=True).values_list('id', 'facenet512_data')
|
||||
face_df = pd.DataFrame(list(facedata), columns=["identity", "Facenet512_representation"])
|
||||
user__is_active=True).values_list('id', 'face_data')
|
||||
face_df = pd.DataFrame(list(facedata), columns=["identity", "VGG-Face_representation"])
|
||||
cache.set('global_face_df', face_df, timeout=None)
|
||||
return face_df
|
Loading…
Reference in New Issue