boltgolt / howdy

🛡️ Windows Hello™ style facial authentication for Linux
MIT License
5.75k stars 299 forks source link

Using InsightFace, for the ML model #925

Open InferencetrainAI opened 3 months ago

InferencetrainAI commented 3 months ago

Let's migrate to insightface huggingface model to do face feature extraction? Need to figure out how to verify by the model -


import cv2
from insightface.app import FaceAnalysis
import torch

app = FaceAnalysis(name="buffalo_l", providers=['CUDAExecutionProvider', 'CPUExecutionProvider'])
app.prepare(ctx_id=0, det_size=(640, 640))

image = cv2.imread("person.jpg")
faces = app.get(image)

faceid_embeds = torch.from_numpy(faces[0].normed_embedding).unsqueeze(0)

Current implementation - https://gitlab.com/inferencetraining.ai/faceAuth/-/blob/master/FaceAuth.py?ref_type=heads