Real-time multi-model face analysis: 15 per-face and whole-frame features, four pluggable face detectors, and held-out-tested ways of combining interchangeable backends.
Try the live demo: upload a photo (or press Try a sample for NASA's Expedition 59 crew portrait) and read each face's age, gender, race, emotion and eye color. It runs a reduced, CPU-only model set (docs/deploy.md) and may take a minute to wake up.
A Streamlit app, with upload and live-webcam tabs, that detects faces in an uploaded image or webcam feed and runs any combination of attribute models on each face: age, gender, race, emotion, gaze, liveness, recognition, and more. Most features have two or more backends that can run side by side, and the app combines their answers.
- Interchangeable face detectors. SSD, YOLOv8-Face, SCRFD, and RetinaFace share a common call
shape in
src/face_analyzer/detectors/, selected per frame by a factory with SSD as the fallback. - Fusion across label taxonomies. Emotion backends are fused by weighted vote, after their
labels are mapped onto shared canonical classes (
happyandhappinessare one vote). - Fusion rejected where the evidence says so. On 1,002 held-out FairFace faces, the old race fusion scored 63.3% against 76.5% for its best model, and neither fusion nor a learned stacker beat the best single model for age or gender. So those three name their best model (Results).
- Concurrent, cached inference. Per-face attribute models run in parallel on a thread pool, outputs are memoized on a hash of the exact model input, and LIVE mode shows FPS and per-model latency.
- Build-time model selection, graceful runtime degradation. Docker build arguments choose which weights and dependencies go into the image; at runtime any missing model is skipped and listed as unavailable rather than crashing the app.
flowchart LR
subgraph UI["ui/ (results.py, live.py)"]
A[Frame] --> C["Colorization (grayscale input only)"]
K[Face cards and result tables]
end
subgraph P["pipeline/: analyze_frame()"]
B["Global adjustments (optional)"] --> D["Face detector: YOLO / SCRFD / RetinaFace, SSD fallback"]
D --> E[Face tracking]
E --> H["Hand landmarks (whole frame)"]
E --> F["Per face: roll alignment, crop, face adjustments, face landmarks"]
F --> G["Attribute backends in parallel"]
G --> I["Fusion and best-model selection"]
I --> J[Annotated overlay]
H --> J
end
C --> B
J --> K
The source is the installable face_analyzer package; paths below are relative to
src/face_analyzer/. Colorization runs in the UI layer before analyze_frame(): in
ui/results.py for uploads and snapshots, and in ui/live.py for live webcam frames.
pipeline/analyzer.py orchestrates the remaining stages, configured by one AnalysisConfig
(pipeline/config.py); the stages live in pipeline/stages.py (per-feature face tasks in
pipeline/face_tasks.py, the prediction cache and thread pool in pipeline/cache.py). Model
loading is in pipeline/loader.py, fusion in fusion/, and vendored third-party architectures
in nets/; inference.py is a facade that re-exports the public names the UI, tools and
tests use. The Streamlit entry point app.py only wires these together: the theme
(ui/theme.py plus theme.css), the sidebar (ui/sidebar.py), the image adjustment sliders
(ui/adjustments.py), the per-image results view (ui/results.py), and the Live webcam tab
(ui/live.py). ARCHITECTURE.md covers module boundaries, the weights
lifecycle and demo mode in more depth.
CONTRIBUTING.md covers local setup, the lint and test commands CI runs, and
commit conventions. docs/ci.md maps the CI: lint, a type-check ratchet, tests with
coverage on two Pythons, a real-browser run of the public demo, Docker builds that prove the
image works, security scanning, a daily check of the deployed demo, and Claude Code agents that
review pull requests, triage issues and diagnose CI failures. The repo is also set up for coding agents: AGENTS.md is the
single instruction file (CLAUDE.md imports it), with project skills in .agents/skills/, a
Docker-testing subagent for Claude Code and Codex, Playwright MCP config in .mcp.json, and
the design specs and implementation plans behind past changes in docs/agents/.
Held-out, on 1,002 test faces from the public FairFace validation split (race-stratified sample, seed 0; 95% bootstrap intervals; detection recall 100%):
| Feature | App (shipped) | Best single model | Learned stacker (not shipped) |
|---|---|---|---|
| Gender | 96.7% (95.5-97.7) | mivolo 96.7% (95.5-97.7) |
96.7% (95.5-97.7) |
| Race, 6 classes | 76.5% (74.0-79.2) | fairface 76.5% (74.0-79.2) |
75.1% (72.5-77.8) |
| Age, 9 buckets | 62.3% (59.2-65.1) | mivolo 62.3% (97.0% within one bucket) |
62.8% (59.7-65.7) (96.5% within one) |
- Gender and age: the headlines name MiVOLO, so the shipped numbers are MiVOLO's (the gender headline used to be a weighted fusion that always returned MiVOLO's answer). MiVOLO's training data is not published, so overlap with FairFace cannot be ruled out.
- Learned stacker: one logistic regression per attribute over every backend's output, fitted on the other half of the sample. Against the shipped answer it scored +0.0 points for gender (interval +0.0 to +0.0), -1.4 for race (-3.4 to +0.7) and +0.5 for age (-1.8 to +2.8); none clears the bar of an interval above zero, so the app does not use it. It is fitted on FairFace data, so its FairFace numbers are in-distribution and it may not transfer to other photos.
- Race: the headline names its most reliable model (
fairface) instead of fusing, because this evaluation showed the previous equal-weight fusion trailingfairfacealone (63.3% against 76.5%):deepface's overconfident probabilities dominated the blend.fairfaceanddeepfacerace were both trained on FairFace's training split, so these numbers are in-distribution and the ranking may not carry over to other photos. - Age: FairFace labels age in nine ranges (mostly decades), so this is bucket accuracy; error in years is reported for UTKFace below, which has exact ages.
- Emotion is not evaluated (FairFace has no emotion labels).
Fusion weights fitted on the other half of the sample did no better than the previous gender
ones; for race, fitted weights (70.1%) still trailed fairface alone. Full tables, label mappings and
caveats: docs/eval/heldout_fairface.md. The earlier 75-face,
in-sample benchmark (the set the weights were hand-set on) is kept in
docs/benchmark.md.
Age out of distribution: UTKFace (1,498 faces, age-decade-stratified, seed 0; exact ages, so error in years too; docs/eval/age_model.md):
| Age backend | Bucket accuracy | MAE (years) |
|---|---|---|
mivolo (shipped headline) |
67.5% (65.1-69.8) | 3.7 (3.5-3.9) |
convnext, fine-tuned on FairFace (not shipped) |
58.8%; -8.7 pp vs mivolo (-11.2 to -6.3) |
- |
fairface |
57.5% | - |
dex |
40.0% | 8.4 |
caffe |
35.9% | - |
- The ConvNeXt-Tiny also trailed MiVOLO on the FairFace test half (60.0%, -2.3 pp, -5.6 to +1.2), its own training distribution, so it is not shipped.
- Caveats: UTKFace only ships tight face crops, so each is padded with black to let the detector find it; MiVOLO's training data is unknown, so it may have seen UTKFace.
No git-lfs needed. The model weights (about 2.9 GB for every downloadable model) are fetched on
demand by tools/fetch_models.py, which downloads only the models you select and checks each
file's sha256 against models/manifest.json. Permissively licensed
weights come from the project's Hugging Face mirror; the rest come from their original upstream
source, and three (dan emotion, deep3d 3D reconstruction and mobilenet glasses) are
bring-your-own. See
docs/setup.md and MODEL_LICENSES.md.
Upgrading an existing clone? Pulling this change deletes the git-lfs weights from disk, including
the bring-your-own dan, deep3d and glasses files that cannot be downloaded again. Run
cp -al models models.bak before git pull; see
docs/setup.md.
Native, with the guided installer (Debian/Ubuntu), which fetches the weights you pick:
git clone https://github.com/dpologdvinity/multimodel-face-analyzer.git
cd multimodel-face-analyzer
./install-and-run.sh # pick backends, then open http://localhost:8501Docker, which downloads the selected weights during the build:
git clone https://github.com/dpologdvinity/multimodel-face-analyzer.git
cd multimodel-face-analyzer
docker build -t face-analyzer . # or ./build-and-run.sh for guided model selection
docker run -d -p 127.0.0.1:8501:8501 --name face_analyzer_container face-analyzerThe image runs streamlit run src/face_analyzer/app.py. For a manual install, add
pip install --no-deps -e . after the requirements so the face_analyzer package is importable, then
fetch weights with python tools/fetch_models.py --keys AGE_MODEL=fairface EMOTION_MODEL=hsemotion
(or --all; --list shows every file and its source). Build
arguments, manual setup, and the remote-access notes (the app has no authentication) are in
docs/setup.md.
A public, stateless demo mode (FACE_ANALYZER_DEMO=1, or the streamlit_app.py entry point)
runs only permissively licensed, lightweight models and drops every feature that stores faces;
docs/deploy.md covers it and the Streamlit Community Cloud deployment. Its
answers are fairface's alone: on the same held-out test faces, gender 92.2% (90.5-93.9), race
76.0% (73.6-78.6) and age bucket 59.4% (56.4-62.4)
(demo configuration).
| Feature | Backends | Notes |
|---|---|---|
| Face detection | ssd (default fallback), yolo, scrfd, retinaface |
One detector per frame; at least one is needed |
| Age | mivolo, fairface, dex, caffe |
Headline names the most reliable model present |
| Gender | mivolo, fairface, caffe, deepface |
Headline names the most reliable model present |
| Race | fairface, deepface |
Headline names the most reliable model present; close runner-up shown |
| Emotion | hsemotion, dan, ferplus, mini_xception |
Fused vote over canonical labels |
| Gaze and head pose | mediapipe |
Coarse direction, eye contact, yaw and pitch |
| Liveness | mediapipe + texture heuristic |
Blink and replay cues; a screening signal only |
| Recognition | vggface, lbph |
Against a gallery you enroll yourself |
| Glasses | mobilenet |
Bring-your-own: the upstream repository was deleted |
| Mask | mobilenetv2 |
|
| Eye color | colorimetric |
Heuristic, not a trained model |
| Face landmarks | mediapipe |
468-point mesh |
| Hand landmarks | mediapipe |
Whole frame, up to two hands |
| Colorization | eccv16 |
Whole frame, grayscale input only, before detection |
| Age progression | franunet |
Non-commercial use only |
| 3D reconstruction | deep3d |
No working default weights: needs the registration-gated Basel Face Model |
The 15 rows after face detection are the analysis features in the Models container
(src/face_analyzer/core/types.py). Thirteen work with weights tools/fetch_models.py downloads; 3D
reconstruction is wired but stays unavailable until you supply its checkpoint and the Basel Face
Model file yourself. Glasses detection is bring-your-own too (its upstream repository was
deleted), as is the dan emotion backend.
The app also has tools that need no extra model: identity search against your own reference photos, SAVE to a local SQLite database with eigenfaces matching, a scan that labels every face recognized or unrecognized, an opt-in crowd count, image adjustment sliders, a mouse crop, per-face image operations, and an opt-in voice and face arousal check in LIVE mode. Per-model details: docs/models.md.
Two themes, picked in the sidebar: Night (dark, the default) and Day (light). Results come
back as one solid-colour card per face, with the age in large type and every other answer
labelled with the model that gave it; Save card downloads any card as a 1080x1350 PNG. Each theme is one block of colour tokens in
src/face_analyzer/ui/theme.css; tests/test_theme.py checks every text, accent and card colour
against WCAG AA contrast.
| Night | Day |
|---|---|
![]() |
![]() |
- Predicted age, gender, race, and emotion are statistical guesses about how a face appears in one image. They are not a person's identity, and the app cannot know how anyone identifies.
- The categories are coarse and culturally contingent: a fixed list of six or seven race labels, binary gender, and a handful of emotion words do not describe real people well.
- The underlying models were trained on datasets (FairFace, AffectNet, IMDB-WIKI, VGGFace and others) with known demographic imbalances, so error rates differ across groups.
- Do not use this software to make decisions about individuals, such as hiring, policing, access control, credit, or surveillance.
- Run recognition and identity search only on people who have consented to it.
The code is MIT-licensed; see LICENSE. Vendored architectures in src/face_analyzer/nets/ keep
their upstream licenses. The model weights are third-party files under their own terms, several
of them non-commercial or with no stated license; see MODEL_LICENSES.md.
The Bricolage Grotesque font in src/face_analyzer/ui/fonts/, used to draw the shareable face
cards, is under the SIL Open Font License 1.1 (OFL.txt).


