The system uses Google MediaPipe with the BlazeFace model for real-time face detection:
backend/identification/detector.py
class MediaPipeFaceDetector: """Face detector using Google MediaPipe Task API (0.10.x+). Implements the FaceDetector protocol from identification/__init__.py. """ def __init__(self, *, min_detection_confidence: float = 0.5) -> None: self._min_confidence = min_detection_confidence self._model_path = str(_MODEL_PATH) self._configured = _MODEL_PATH.exists() if not self._configured: logger.warning("MediaPipe model not found at {}", _MODEL_PATH)
class DetectedFace(BaseModel): """A single detected face with embedding.""" bbox: BoundingBox confidence: float = Field(ge=0.0, le=1.0) embedding: list[float] = Field(default_factory=list)
The manager uses frequency analysis to extract the most likely person name:
backend/identification/search_manager.py
def best_name_from_results(self, result: FaceSearchResult) -> str | None: """Extract the most likely person name from search results. Uses frequency analysis: the name that appears most across matches wins. """ if not result.matches: return None name_counts: dict[str, int] = {} for match in result.matches: if match.person_name: name = match.person_name.strip() name_counts[name] = name_counts.get(name, 0) + 1 if not name_counts: return None # Return the most frequent name return max(name_counts, key=name_counts.get) # type: ignore[arg-type]
def profile_urls_from_results(self, result: FaceSearchResult) -> list[str]: """Extract social profile URLs from search results.""" social_domains = { "linkedin.com", "twitter.com", "x.com", "instagram.com", "facebook.com", "github.com", "tiktok.com", } urls: list[str] = [] seen: set[str] = set() for match in result.matches: if match.url and match.url not in seen: if any(domain in match.url for domain in social_domains): urls.append(match.url) seen.add(match.url) return urls
@app.get("/api/pipeline/status")async def pipeline_status(): """Diagnostic: show what the face identification pipeline is doing right now.""" handler_state = { "seen_tracks": list(frame_handler._seen_tracks), "spawned_identifications": list(frame_handler._spawned), "identifications": { tid: { "status": ident.status, "name": ident.name, "person_id": ident.person_id, "error": ident.error, } for tid, ident in frame_handler._identifications.items() }, "face_detector_configured": frame_handler._face_detector is not None, "embedder_configured": frame_handler._embedder is not None, "face_searcher_configured": frame_handler._face_searcher is not None, } return { "frame_handler": handler_state, "services": settings.service_flags(), "deep_researcher": deep_researcher is not None, "synthesis_engine": synthesis_engine is not None, }