Skip to content

Troubleshooting & FAQ

Hit an error or seeing unexpected detections on your field footage? Start with the symptom that matches what you see below. Most setup and field-data issues take under two minutes to fix.


Installation & Environment

Wrong Python version or NumPy 2.x errors

PrimateFace requires Python >= 3.9 (Python 3.10 recommended) and pins numpy==1.26.4 because current OpenMMLab (mmcv / mmpose) packages are not yet compatible with NumPy 2.x. If you see AttributeError: _ARRAY_API not found or ImportError inside cv2 / mmcv:

uv pip install "numpy==1.26.4"

ModuleNotFoundError: No module named 'rfdetr'

The default v1.0.0 Apache-2.0 face detector (RF-DETR-M) is installed via the [rfdetr] optional extra:

uv pip install -e ".[rfdetr]"

mmcv / mmpose installation or compiled-extension errors

OpenMMLab packages require matched versions (mmengine==0.10.3, mmcv==2.1.0, mmdet==3.2.0, mmpose==1.3.2). Always install them via openmim (which fetches prebuilt binary wheels—pre-compiled packages matching your PyTorch/CUDA version) rather than compiling from source. Because mim calls pip internally, create uv environments with --seed so pip is installed inside .venv:

uv venv --python 3.10 --seed
source .venv/bin/activate
uv pip install -U pip openmim "numpy==1.26.4"
mim install mmengine==0.10.3 mmcv==2.1.0 mmdet==3.2.0 mmpose==1.3.2

For full step-by-step setup on Linux, macOS, Windows, and Google Colab, see Installation.


GPU & Memory

No GPU / running on a laptop

You do not need a GPU to run PrimateFace on photos or short clips. Pass device="cpu" with the lightweight 41 MB HRNet pose model, or switch to free cloud GPUs in Google Colab:

import primateface

pf = primateface.PrimateFace(device="cpu", pose_model="hrnet")
faces = pf.analyze("monkey.jpg")

CUDA out of memory (OOM)

ViTPose-L is our largest checkpoint (1.23 GB) and uses the most GPU memory (VRAM). If your GPU runs out of VRAM (GPU memory):

  • Switch to a lighter pose model: PrimateFace(pose_model="hrnet") (41 MB) or PrimateFace(pose_model="rtmpose") (62 MB, fastest).
  • In batch scripts (gui.pseudolabel, dinov2.dinov2_cli, or training scripts), lower --batch-size (for example, from 32 to 8) or --max-instances.

Model Downloads & Checksums

Running on an offline HPC cluster (no internet on compute nodes)

On university computing clusters, the login node (where you sign in) usually has internet access, while the compute node (the GPU worker node running your job) is offline. Download the models once on a login node, then point PrimateFace at that folder using model_dir:

# On the university cluster login node (has internet):
python demos/download_models.py ./models
# On the offline GPU worker (compute) node (skips Hugging Face network access):
import primateface

pf = primateface.PrimateFace(model_dir="./models")

ValueError: SHA-256 mismatch

Every v1.0.0 checkpoint is verified against a SHA-256 checksum (a digital fingerprint that detects corrupted or incomplete downloads). If a Wi-Fi drop cut a download short, re-download cleanly with --force:

python demos/download_models.py --force ./models

Detection & Landmark Quality in Field Data

False positives on empty camera-trap frames

Default detection confidence is det_threshold=0.5, which favors catching hard partial faces. On empty or cluttered forest backgrounds, raise the threshold to 0.70 or 0.75:

pf = primateface.PrimateFace(det_threshold=0.75)
faces = pf.analyze("camera_trap_frame.jpg")

Missing very small or distant faces (< 32 pixels wide)

Face detectors struggle when a face spans fewer than ~32 pixels across. Whenever possible:

  • Run inference on the original full-resolution frame (do not downscale video before detection).
  • If animals consistently stay in one region of a wide-angle enclosure camera, crop that region first so faces occupy a larger fraction of the image.

Jittery landmarks across consecutive video frames

Frame-by-frame landmark estimation can produce slight 1–2 pixel jitter in video. Enable our built-in temporal filter (Median + Savitzky-Golay smoothing), which removes single-frame spikes without blurring fast mouth or brow movements:

python demos/primateface_demo.py process \
    --input field_video.mp4 --input-type video \
    --det-checkpoint ./models/primateface_rfdetr_m_v1.0.0.pth \
    --pose-config ./models/mmpose_config.py \
    --pose-checkpoint ./models/mmpose_checkpoint.pth \
    --output-dir ./out --save-viz --smooth
from primateface._smooth import MedianSavgolSmoother

smoother = MedianSavgolSmoother(median_window=5, savgol_window=7)
smoothed_xy = smoother.update(
    instance_id=0,
    keypoints=face.keypoints[:, :2],
    keypoint_scores=face.keypoints[:, 2],
)

Blurry, occluded, or extreme-profile faces

Before computing downstream kinematics (such as mouth aperture or head pose), filter out low-quality detections using the built-in quality score and mean landmark confidence:

good_faces = [
    f for f in faces
    if f.quality["score"] >= 0.4 and f.keypoints[:, 2].mean() >= 0.5
]

See Scope & Limitations for expected accuracy across species, lighting, and extreme profiles.


Still Stuck?

Please open a ticket on GitHub Issues and include:

  1. Your OS, Python version (python --version), and whether you are using CPU or a GPU (nvidia-smi).
  2. The exact command or minimal Python snippet that triggered the problem.
  3. The full error traceback (or a description of the visual failure on your footage).