Skip to content

Genus Classification & Facial Attributes

Large field, zoo, and museum photo archives often contain thousands of unlabeled primate faces mixed across taxa, head angles, and expressions. PrimateFace v1.0.0 includes two metadata tools to sort and filter those images automatically before you start manual coding or morphometrics:

  1. A 69-genus face classifier (ConvNeXt-Small) that predicts the primate genus of each face crop locally — no cloud API or internet connection required after download.
  2. Six observable facial-attribute heads that label visible teeth, mouth openness, head tilt, apparent age class, head turn, and facial occlusion.

Do I need a GPU?

  • Genus classification: Runs smoothly on a standard laptop CPU (~30–80 ms per face crop) and is near-instant on a GPU or free Google Colab T4.
  • Facial attributes: Precomputed predictions for all 281,520 faces in PrimateFace are already stored in primateface_v1.0.0_faces.parquet on Hugging Face Datasets, so you can filter the dataset in Python or R with zero GPU compute. Extracting custom DINOv3-L + BioCLIP 2.5 embeddings for your own images is fastest on a GPU (Colab T4 works well).

Part 1: Sorting Photos by Genus (69 Primate Genera)

The native PrimateFace genus model (primateface_genus_convnext_s_v1.0.0.pth, ConvNeXt-Small, BSD-3-Clause, 198 MB) takes a cropped primate face and outputs calibrated probability scores across 69 primate genera spanning all six primate superfamilies.

How Accurate Is It?

Evaluated on 11,149 held-out primate faces from images never seen during training:

  • 96.0% Top-1 accuracy (the model's #1 guess is right 96% of the time) and 98.8% Top-5 accuracy (the true genus is almost always inside the top five suggestions).
  • 97.6% Top-1 accuracy on the 8,747 faces with independent human, museum, or iNaturalist identifications.
  • 0.946 macro-F1 across the 55 well-sampled genera (macro-F1 averages performance equally across rare and common genera, ensuring abundant taxa like Macaca do not mask errors on rarer genera).
  • Well-calibrated confidence (ECE = 0.014): Expected Calibration Error measures whether predicted percentages match reality — an ECE of 0.014 means when the model reports 90% confidence, it is right roughly 90% of the time.

Running the Genus Classifier

First download the weights (python demos/download_models.py ./models — see Models & Thresholds).

Step 0: Extract a face crop from a full photo (the genus classifier expects a cropped primate face, not a full forest or enclosure scene):

import cv2, primateface

pf = primateface.PrimateFace()
faces = pf.analyze("forest_photo.jpg")
cv2.imwrite("face_crop.jpg", faces[0].crop)

Then classify a single face crop or an entire folder of crops:

python demos/classify_genus.py face_crop.jpg \
    --checkpoint ./models/primateface_genus_convnext_s_v1.0.0.pth \
    --min-conf 0.85

Expected output:

Image: face_crop.jpg -> Ateles (conf=0.9814)
  - Ateles: 0.9814
  - Lagothrix: 0.0082
  - Alouatta: 0.0031

# Saves calibrated predictions to a standard COCO JSON annotation file
python demos/classify_genus.py ./face_crops/ genus_predictions.json \
    --checkpoint ./models/primateface_genus_convnext_s_v1.0.0.pth \
    --min-conf 0.85

Expected output:

img_001.jpg: Macaca (conf=0.992)
img_002.jpg: Uncertain (conf=0.614)
Saved COCO output to genus_predictions.json

python demos/primateface_demo.py classify \
    --input face_crop.jpg \
    --checkpoint ./models/primateface_genus_convnext_s_v1.0.0.pth \
    --min-conf 0.85 \
    --output result.json

Expected output:

Image: face_crop.jpg -> Ateles (conf=0.9814)
  - Ateles: 0.9814

Use --min-conf 0.85 to flag blurry or tricky faces automatically

Setting --min-conf 0.85 tells the classifier to output "Uncertain" instead of guessing whenever confidence falls below 85%. On the held-out test set, this abstention threshold keeps 96.6% of faces while boosting accuracy on kept faces to 97.8% — letting you focus manual review strictly on the remaining ~3.4% of ambiguous crops.

Scope: genus-level only across 69 trained genera

This model predicts genus, not species within a genus (for example, it identifies Macaca, not Macaca mulatta vs. Macaca fascicularis). Faces from genera outside the 69 trained taxa will be assigned to the closest-looking trained genus unless filtered by --min-conf. See Scope & Limitations.

Part 2: Six Observable Facial Attributes

In many behavioral and morphological studies, you only want a clean slice of your photos — for instance, frontal, unoccluded, closed-mouth adults for craniofacial comparisons, or open-mouth / teeth-visible frames to screen for vocalizations and bared-teeth displays.

PrimateFace defines six directly observable facial attributes:

  • teeth_visible: False, True
  • mouth: closed, slightly_open, wide_open
  • pitch_bin (vertical head tilt): level, down, up
  • age_class (apparent developmental stage): adult, juvenile, infant
  • yaw_bin (horizontal head turn): frontal, three_quarter, profile, extreme
  • occlusion (obstruction by hands, branches, bars, or food): none, partial, heavy

Held-Out Benchmark Performance

A compact classifier built on pre-extracted image fingerprints from two general-purpose vision models (DINOv3-L and BioCLIP 2.5) was evaluated on a held-out test set (n = 1,617 faces; n = 1,608 for age_class excluding unknown age):

Attribute Classes Held-Out Accuracy Macro-F1 Majority Baseline n
teeth_visible 2 (False, True) 97.3% 84.2% 95.3% 1,617
mouth 3 (closed, slightly_open, wide_open) 93.9% 78.9% 85.6% 1,617
pitch_bin 3 (level, down, up) 91.4% 76.2% 85.4% 1,617
age_class 3 (adult, juvenile, infant) 92.8% 73.7% 83.6% 1,608
yaw_bin 4 (frontal, three_quarter, profile, extreme) 85.0% 68.4% 47.8% 1,617
occlusion 3 (none, partial, heavy) 92.5% 55.0% 81.4% 1,617

Majority baseline is the accuracy you would get by always guessing the most common label (for example, always guessing closed mouth).

Why does occlusion have 92.5% accuracy but 55.0% macro-F1?

Over 81% of faces in the corpus are unoccluded and heavy occlusion is very rare (<0.5% of labeled faces). Because macro-F1 weights rare and common classes equally, missing even a handful of heavily occluded faces lowers macro-F1 even when overall accuracy is high. If your analysis specifically depends on catching rare heavy occlusion, visually audit low-confidence frames.

Using Precomputed Predictions or Training on Custom Features

No end-to-end raw-image attribute CLI is shipped in v1.0.0

demos/train_attribute_heads.py operates on pre-extracted .npy image-fingerprint arrays rather than raw .jpg/.png photos. If you are analyzing the PrimateFace corpus, load the precomputed predictions directly from primateface_v1.0.0_faces.parquet on Hugging Face Datasets below—no feature extraction needed.

Already working with the PrimateFace dataset? Corpus-wide predictions for all 281,520 faces are precomputed inside primateface_v1.0.0_faces.parquet (Parquet = a fast, compact spreadsheet-like file readable in Python pandas and R arrow) in the Hugging Face v1.0.0 dataset (fparodi/PrimateFace). See Dataset Reference for the exact column schema.

Running on your own dataset? Once you have extracted frozen DINOv3-L + BioCLIP 2.5 feature arrays (.npy), use demos/train_attribute_heads.py to train and predict:

# 1. Train & evaluate on a group-disjoint 80/20 split (saves attr_heads.pt + JSON report)
python demos/train_attribute_heads.py train \
    --features features.npy \
    --labels labels.parquet \
    --out-dir ./attr_heads_out

# 2. Predict all six attributes (+ confidence scores) on new face embeddings
python demos/train_attribute_heads.py predict \
    --checkpoint ./attr_heads_out/attr_heads.pt \
    --features query_features.npy \
    --out predictions.parquet

Expected output:

Saved attribute heads (shared) -> attr_heads_out/attr_heads.pt
Wrote 1200 attribute predictions -> predictions.parquet

Technical details: feature inputs & multi-task architecture

demos/train_attribute_heads.py compares independent linear heads against a shared multi-task MLP trunk (d → 512 → GELU → Dropout 0.2) using square-root inverse-frequency class weights and label smoothing (0.05) to improve recall on minority classes (wide_open, infant, heavy). It automatically holds out entire images (--group-col image_key) so faces from the same photograph never leak between train and test, then refits the winning architecture on all labeled samples for deployment.