← Back to work

Python · ONNX Runtime · InsightFace · 2025 · solo

See Me — face search

An interactive CLI that searches a photo library by face, matching InsightFace embeddings by cosine similarity, with CUDA acceleration when it's available.

See Me's engine.py in VS Code — building the InsightFace pipeline on ONNX Runtime, CUDA first with a CPU fallback, and scanning a photo for faces.

The problem

Finding every photo of one person in a large, unsorted photo library — without hand-tagging anything — needs a way to tell faces apart that’s robust to angle, lighting and expression, and a search fast enough to run over a real library rather than a folder of twenty test images.

The approach

Point it at a folder of reference photos and it detects and crops every face it finds, running each through InsightFace’s embedding model via ONNX Runtime — CUDA first, falling back to CPU automatically if no GPU is available. Since those embeddings are already L2-normalized, comparing two faces is just a plain dot product rather than a full cosine-similarity computation. From there it’s an interactive CLI: pick which of the detected reference faces to search for by number, then choose between two modes — “separate,” which sorts matches for each person into their own folder, or “together,” which only returns photos containing every selected person at once.

What was hard

Getting the reference-image handling right before the matching even starts: a reference photo needs its face detected and cropped the same way a library photo does, or the embeddings being compared aren’t really comparable. Treating that as its own first step, rather than folding it into the matching loop, is what kept the comparison honest. The similarity threshold also isn’t from a paper — it’s tuned empirically against a real test set until false positives between visually similar faces stopped showing up.

Result

A working face search over a local photo library, with input validation on every prompt, empty-result folders cleaned up automatically instead of left around, and single- or multi-person search depending on what you’re looking for — running on GPU or CPU depending on what’s available.