mirror of
https://github.com/blakeblackshear/frigate.git
synced 2025-02-18 00:16:41 +01:00
Adjust to score system
This commit is contained in:
parent
3d1c35370d
commit
2b7c40494e
@ -456,15 +456,15 @@ class EmbeddingMaintainer(threading.Thread):
|
||||
if not res:
|
||||
return
|
||||
|
||||
sub_label, distance = res
|
||||
sub_label, score = res
|
||||
|
||||
logger.debug(
|
||||
f"Detected best face for person as: {sub_label} with distance {distance}"
|
||||
f"Detected best face for person as: {sub_label} with score {score}"
|
||||
)
|
||||
|
||||
if id in self.detected_faces and distance >= self.detected_faces[id]:
|
||||
if id in self.detected_faces and score <= self.detected_faces[id]:
|
||||
logger.debug(
|
||||
f"Recognized face distance {distance} is greater than previous face distance ({self.detected_faces.get(id)})."
|
||||
f"Recognized face distance {score} is less than previous face distance ({self.detected_faces.get(id)})."
|
||||
)
|
||||
return
|
||||
|
||||
@ -473,11 +473,12 @@ class EmbeddingMaintainer(threading.Thread):
|
||||
json={
|
||||
"camera": obj_data.get("camera"),
|
||||
"subLabel": sub_label,
|
||||
"subLabelScore": score
|
||||
},
|
||||
)
|
||||
|
||||
if resp.status_code == 200:
|
||||
self.detected_faces[id] = distance
|
||||
self.detected_faces[id] = score
|
||||
|
||||
def _detect_license_plate(self, input: np.ndarray) -> tuple[int, int, int, int]:
|
||||
"""Return the dimensions of the input image as [x, y, width, height]."""
|
||||
|
@ -165,7 +165,7 @@ class FaceClassificationModel:
|
||||
def __init__(self, config: FaceRecognitionConfig, db: SqliteQueueDatabase):
|
||||
self.config = config
|
||||
self.db = db
|
||||
self.recognizer = cv2.face.LBPHFaceRecognizer_create(radius=4, threshold=config.threshold)
|
||||
self.recognizer = cv2.face.LBPHFaceRecognizer_create(radius=4, threshold=(1 - config.threshold) * 1000)
|
||||
self.label_map: dict[int, str] = {}
|
||||
|
||||
def __build_classifier(self) -> None:
|
||||
@ -198,5 +198,6 @@ class FaceClassificationModel:
|
||||
if index == -1:
|
||||
return None
|
||||
|
||||
return self.label_map[index], distance
|
||||
score = 1.0 - (distance / 1000)
|
||||
return self.label_map[index], round(score, 2)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user