fix: raise detection confidence threshold to 0.7, move model cache to project dir
This commit is contained in:
parent
adf949b805
commit
9fc5bfc2c4
3 changed files with 29 additions and 3 deletions
|
|
@ -1,9 +1,16 @@
|
|||
"""CLI module for faceblur-poc."""
|
||||
|
||||
import argparse
|
||||
import os
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
# Set model cache to project-local models/ directory before importing uniface
|
||||
os.environ.setdefault(
|
||||
"UNIFACE_CACHE_DIR",
|
||||
str(Path(__file__).resolve().parent.parent.parent / "models"),
|
||||
)
|
||||
|
||||
from .video import extract_frames
|
||||
from .detect import FaceDetector
|
||||
from .cluster import cluster_faces
|
||||
|
|
@ -35,6 +42,12 @@ def main():
|
|||
detect_parser.add_argument(
|
||||
"--min-samples", type=int, default=2, help="DBSCAN min_samples"
|
||||
)
|
||||
detect_parser.add_argument(
|
||||
"--confidence",
|
||||
type=float,
|
||||
default=0.7,
|
||||
help="Minimum face detection confidence (0-1)",
|
||||
)
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
|
|
@ -66,7 +79,7 @@ def run_detect(args):
|
|||
sys.exit(1)
|
||||
|
||||
print("\n[2/5] Initializing face detector...")
|
||||
detector = FaceDetector()
|
||||
detector = FaceDetector(confidence_threshold=args.confidence)
|
||||
|
||||
print("\n[3/5] Detecting faces...")
|
||||
all_faces = []
|
||||
|
|
|
|||
|
|
@ -26,8 +26,8 @@ class FaceData:
|
|||
class FaceDetector:
|
||||
"""Face detector using RetinaFace + ArcFace via UniFace."""
|
||||
|
||||
def __init__(self):
|
||||
self.detector = RetinaFace()
|
||||
def __init__(self, confidence_threshold: float = 0.7):
|
||||
self.detector = RetinaFace(confidence_threshold=confidence_threshold)
|
||||
self.recognizer = ArcFace()
|
||||
|
||||
def detect_faces(self, frame_path: Path, frame_index: int) -> List[FaceData]:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue