Skip to content

Installation

This guide walks you through installing PrimateFace (v1.0.0) on your own computer. No prior experience with deep-learning environments is required.

Do I need to install anything?

Not if you just want to test PrimateFace or don't have an NVIDIA graphics card (GPU). You can run PrimateFace on your own photos and short videos right now in a web browser using free Google Colab—zero setup required. Head to the Interactive Tutorials to get started immediately.

Do I need to download the 240,241-image dataset? No!

If you are just analyzing your own primate photos or videos, you do NOT need the dataset. PrimateFace automatically downloads only the compact pretrained models (41–137 MB) the first time you run it.

CPU vs. GPU: What hardware do I need?

A CPU is the standard processor in any laptop or desktop; a GPU (specifically an NVIDIA graphics card with CUDA support) is specialized hardware that runs neural networks in parallel.

Task Regular Laptop (CPU) NVIDIA GPU (CUDA)
A handful of photos (1–100 images) Works fine (~1–3 seconds per image) Very fast (~20–50× faster)
Video analysis (thousands of frames) Impractically slow Strongly recommended (or use Google Colab)
68↔48 landmark conversion (NumPy-only) Instant (~1.3 ms per face) Not needed
Fine-tuning models on a new species Not recommended Required

Step 1: Clone the repository and create an environment

Open Terminal (Mac), PowerShell (Windows), or the built-in terminal in VS Code, and make sure Git is installed (git --version). Below you will create an isolated Python environment (.venv) so PrimateFace's libraries never interfere with other software on your computer. Each time you open a new terminal later, re-run source .venv/bin/activate (or .venv\Scripts\activate on Windows) inside the PrimateFace folder to re-enter your environment.

We recommend uv, a fast Python environment manager. If you prefer standard pip, switch to the pip + venv tab below.

First install uv if you don't have it yet (install instructions), then clone PrimateFace and create a Python 3.10 environment (--seed includes pip, which Step 4 needs):

git clone https://github.com/KordingLab/PrimateFace.git
cd PrimateFace
uv venv --python 3.10 --seed
source .venv/bin/activate  # On Windows: .venv\Scripts\activate

With Python 3.10 installed on your machine:

git clone https://github.com/KordingLab/PrimateFace.git
cd PrimateFace
python3.10 -m venv .venv
source .venv/bin/activate  # On Windows: .venv\Scripts\activate
pip install --upgrade pip

Step 2: Install PyTorch

PyTorch is the deep-learning engine that runs PrimateFace's neural networks. Choose NVIDIA GPU (CUDA 12.4) if you have a Linux/Windows workstation with an NVIDIA card (run nvidia-smi in your terminal to check), or CPU-only for a standard laptop or Mac.

uv pip install torch torchvision --index-url https://download.pytorch.org/whl/cu124
uv pip install torch torchvision --index-url https://download.pytorch.org/whl/cpu

(If you are using pip instead of uv, replace uv pip install with pip install in Steps 2 and 3.)

Check that PyTorch sees your hardware:

python -c "import torch; print(f'PyTorch {torch.__version__}, GPU available: {torch.cuda.is_available()}')"

Step 3: Install PrimateFace

Install the core library together with the recommended RF-DETR-M face detector (permissively licensed under Apache-2.0 — safe for academic and commercial projects; zero AGPL). Here -e ".[rfdetr]" installs the folder you just downloaded plus the RF-DETR-M face detector:

uv pip install -e ".[rfdetr]"

You can add optional feature packs at any time by listing them inside the brackets (for example, uv pip install -e ".[rfdetr,interop,gui]"):

Extra What it adds When you need it
rfdetr RF-DETR-M primate face detector Recommended for almost everyone (default detector in v1.0.0)
interop sleap-io, pynwb, ndx-pose Exporting/importing SLEAP (.slp) and NWB (.nwb) files
gui Gradio web interface Interactive pseudo-labeling and human-in-the-loop correction
dinov2 DINOv2 feature extraction & UMAP (2D visual clustering map) Selecting diverse frames from long videos for labeling
embedding InsightFace / ArcFace embeddings (numerical face fingerprints) Individual face recognition (requires labeled reference photos)
megadescriptor timm MegaDescriptor embeddings (numerical face fingerprints) Alternative wildlife re-identification embeddings
dev pytest, Jupyter, linting tools Running unit tests or local Jupyter notebooks

Step 4: Install a 68-point pose backend

PrimateFace's built-in PrimateFace().analyze() pipeline uses MMPose to run our 68-point facial landmark models (HRNetV2-W18, RTMPose-M, and ViTPose-L). Pick the tab matching your Python version:

None of the v1.0.0 pose backbones require compiled mmcv C++/CUDA extensions. PrimateFace automatically enables pure-Python mmcv-lite compatibility so installation takes ~15 seconds on Python 3.12 and PyTorch 2.x with zero C++ compilation:

pip install -q "setuptools<81" cython
pip install -q --no-build-isolation "mmengine>=0.10.3" "mmcv-lite==2.1.0" "mmpose==1.3.2"
pip install -q --no-deps "mmdet==3.2.0" "mmpretrain==1.2.0"
pip install -q terminaltables shapely importlib-metadata einops modelindex
uv pip install -U pip openmim "numpy==1.26.4"
mim install mmengine==0.10.3 --trusted-host download.openmmlab.com --trusted-host pypi.org
mim install "mmcv==2.1.0" --trusted-host download.openmmlab.com --trusted-host pypi.org
mim install "mmdet==3.2.0" --trusted-host download.openmmlab.com --trusted-host pypi.org
mim install "mmpose==1.3.2" --trusted-host download.openmmlab.com --trusted-host pypi.org
Technical details: Using DeepLabCut, Lightning Pose, or SLEAP instead of MMPose

If your lab already runs DeepLabCut 3.0.2, Lightning Pose 2.0, or SLEAP-NN, you do not have to install MMPose to use PrimateFace's pretrained 68-point weights. Each of those ecosystems has its own environment requirements and dedicated checkpoint in v1.0.0. See the Framework Integration Guide for step-by-step setup in each toolkit.

Step 5: Verify your installation

Run these two commands to confirm that Python finds PrimateFace and its model registry:

python -c "import primateface; print(primateface.__version__)"
primateface models list

Expected output:

1.0.0
Models hosted at: https://huggingface.co/fparodi/primateface-models

Task            Variant          Type         Description
--------------------------------------------------------------------------------
detection       default          checkpoint   RF-DETR-Medium v1.0.0 face detector (Apache-2.0, 137 MB, recommended)
...

Ran into an install error?

OpenMMLab (mmcv) compilation errors or NumPy version mismatches are the most common snags. Check the Troubleshooting Guide for quick copy-paste fixes.

Next steps