common confidence scales

This commit is contained in:
Sefik Ilkin Serengil 2024-02-25 14:25:17 +00:00
parent 3ebcc82c17
commit 7ee55cb682
3 changed files with 8 additions and 2 deletions

View File

@ -90,6 +90,7 @@ class DlibClient(Detector):
left_eye = (shape.part(2).x, shape.part(2).y)
right_eye = (shape.part(0).x, shape.part(0).y)
# never saw confidence higher than +3.5 github.com/davisking/dlib/issues/761
confidence = scores[idx]
facial_area = FacialAreaRegion(
@ -99,7 +100,7 @@ class DlibClient(Detector):
h=h,
left_eye=left_eye,
right_eye=right_eye,
confidence=confidence,
confidence=min(max(0, confidence), 1.0),
)
resp.append(facial_area)

View File

@ -60,7 +60,7 @@ class OpenCvClient(Detector):
h=h,
left_eye=left_eye,
right_eye=right_eye,
confidence=confidence,
confidence=(100 - confidence) / 100,
)
resp.append(facial_area)

View File

@ -31,6 +31,7 @@ detector_backends = [
"yolov8",
]
# verification
for model_name in model_names:
obj = DeepFace.verify(
@ -46,6 +47,7 @@ for model_name in model_names:
embedding = embedding_obj["embedding"]
logger.info(f"{model_name} produced {len(embedding)}D vector")
# find
dfs = DeepFace.find(
img_path="dataset/img1.jpg", db_path="dataset", model_name="Facenet", detector_backend="mtcnn"
@ -54,6 +56,7 @@ for df in dfs:
logger.info(df)
# img_paths = ["dataset/img11.jpg", "dataset/img11_reflection.jpg", "dataset/couple.jpg"]
img_paths = ["dataset/img11.jpg"]
for img_path in img_paths:
@ -84,6 +87,8 @@ for img_path in img_paths:
assert isinstance(face_obj["facial_area"]["right_eye"][1], int)
assert isinstance(face_obj["confidence"], float)
assert face_obj["confidence"] <= 1
plt.imshow(face)
plt.axis("off")
plt.show()