Face recognition bug fixes (#17401)

* Simplify normalization

* Fix confidence check
This commit is contained in:
Nicolas Mowen 2025-03-26 18:43:10 -06:00 committed by GitHub
parent a37f804469
commit ff34739f40
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 3 additions and 4 deletions

View File

@ -10,7 +10,7 @@ from scipy import stats
from frigate.config import FrigateConfig
from frigate.const import MODEL_CACHE_DIR
from frigate.embeddings.onnx.facenet import ArcfaceEmbedding
from frigate.embeddings.onnx.face_embedding import ArcfaceEmbedding
logger = logging.getLogger(__name__)
@ -329,7 +329,7 @@ class ArcFaceRecognizer(FaceRecognizer):
cosine_similarity = dot_product / (magnitude_A * magnitude_B)
confidence = self.similarity_to_confidence(cosine_similarity)
if cosine_similarity > score:
if confidence > score:
score = confidence
label = name

View File

@ -90,8 +90,7 @@ class ArcfaceEmbedding(BaseEmbedding):
frame[y_center : y_center + og_h, x_center : x_center + og_w] = og
# run arcface normalization
normalized_image = frame.astype(np.float32) / 255.0
frame = (normalized_image - 0.5) / 0.5
frame = (frame / 127.5) - 1.0
frame = np.transpose(frame, (2, 0, 1))
frame = np.expand_dims(frame, axis=0)