Closed-form, per-vertex uncertainty for 3D faces and bodies, and for SAM 3D Body in three lines of code.
Megh Shukla1 · Edo Collins2 · Prashanth Chandran2 · Karel Petránek2 · Sergio Orts-Escolano2 · Mathieu Salzmann1,3 · Alexandre Alahi1
1EPFL 2Google 3Waabi
CLUE colours every vertex of its mesh by how uncertain it is, from blue (certain) to red (uncertain).
CLUE maps the variance of a 3D morphable model's parameters to the variance of every vertex of its mesh, in closed form. This does not require sampling or computing expensive Jacobians. CLUE is accurate and computationally efficient for real time inference. Not only does CLUE make uncertainty visually interpretable, it also improves accuracy in comparison to deterministic and architecture agnostic unimodal baselines.
Already using Meta's SAM 3D Body? The plugin in ITW/inference/plugin adds a per-vertex uncertainty map to every mesh it predicts, with three lines of code. SAM 3D Body stays exactly as it is. The plugin reads its decoder through a hook, a 6 MB head trained on top of the frozen released model predicts the variance of the body parameters, and CLUE propagates this variance through the MHR rig in closed form. Meshes, keypoints and cameras do not change.
pip install ITW/inference/pluginfrom sam3dbody_clue import SAM3DBodyCLUE
clue = SAM3DBodyCLUE(estimator) # Add a hook to integrate CLUE into SAM 3D Body
# CLUE supported for inference_type = 'body', for 'full' original code behaviour maintained without CLUE
outputs = estimator.process_one_image(image, inference_type="body") # outputs[i]["vertex_sigma_cm"]: per-vertex std in cmThe head's weights are downloaded from meghshukla/clue on first use. The repository is gated with automatic approval so please accept its terms once and log in with hf auth login. The gate exists to ensure that users comply with SAM 3D Body's license too. This code is tested with sam-3d-body at commit b5c765a, which is the latest commit as of the time of writing. Details are provided in ITW/inference/plugin/README.md.
Hugging Face demo: meghshukla/clue-demo. No installation needed. Upload an image, take one with your webcam, or upload a video (its first 10 s are processed). For every person, the demo shows the input, Meta's SAM 3D Body (grey mesh) and CLUE (mesh coloured by per-vertex uncertainty) side by side.
The FLAME, SMPLX and MHR folders each come with an interactive viewer (demo.py). Every parameter (shape, expression, jaw, body pose, ...) has a second slider for its uncertainty (σ²). Move either one, and CLUE recomputes the per-vertex uncertainty and recolours the mesh as you go. Below, giving a single expression parameter some uncertainty lights up the mouth and the cheeks.
cd FLAME # or SMPLX, MHR
python demo.py # needs a displayAsk a coding agent to "find the frames where the left arm is most uncertain" or "find the people whose body shape is hard to estimate". The data-mining folder is an Agent Skill: it ranks the people in a folder of images or a video with CLUE and returns the frames, or exports every person's scores for curating a dataset. Link the folder into the folder where your agent loads skills from (link it, please don't copy it):
ln -s "$PWD/data-mining" <skills folder>/data-mining| Training images | Per-vertex uncertainty | 3DPW MPJPE / PA-MPJPE / PVE / PA-PVE | EMDB MPJPE / PA-MPJPE / PVE / PA-PVE | |
|---|---|---|---|---|
| SAM 3D Body | 3.8M | ✗ | 56.0 / 35.1 / 67.1 / 47.2 | 63.2 / 38.2 / 74.7 / 47.1 |
| CLUE | 1.2M | ✓ | 55.8 / 34.5 / 66.4 / 46.7 | 64.9 / 39.7 / 77.0 / 49.0 |
Errors in mm on the 3DPW test set and EMDB 1 (lower is better), and all models are evaluated with the same protocol. SAM 3D Body (CLUE) leaves SAM 3D Body's meshes unchanged, so its errors are those of SAM 3D Body.
Docker (recommended): We provide a Docker image which is pre-installed with all required packages. We recommend using this image to ensure reproducibility of our results. Using this image requires setting up Docker on Ubuntu, and the NVIDIA Container Toolkit for GPU access. Once installed, the provided docker-compose.yaml starts our environment:
docker-compose run --rm cluepip: In case using Docker is not possible, we recommend setting up a new virtual environment, installing the PyTorch build for your CUDA version (pytorch.org), and then the remaining packages:
pip install -r requirements.txt
sudo apt install ffmpeg python3-tk # the videos need ffmpeg, the interactive viewers TkinterThe repository contains three folders for the morphable-model experiments, FLAME, SMPLX and MHR, and two folders for in-the-wild human mesh recovery, ITW/inference and data-mining.
FLAME, SMPLX, MHR: Each folder contains CLUE for that model (algorithm.py) and three scripts: evaluation.py compares CLUE with Monte-Carlo sampling and a Jacobian baseline, video.py renders parameter sweeps with their uncertainty, and demo.py is an interactive viewer. These experiments run on a CPU. Running evaluation.py writes the error maps (results/error_maps/) and the runtime, memory and FLOPs tables (results/time/, results/memory/, results/flops/), measured on your machine. The experiments require the model files, which are distributed under their own licences:
Model files for FLAME, SMPL-X and MHR
-
FLAME:
generic_model.pklfrom the FLAME website, andflame_static_embedding.pkl,flame_dynamic_embedding.npyfrom FLAME_PyTorch, copied intoFLAME/model/. -
SMPL-X:
SMPLX_NEUTRAL.npzfrom the SMPL-X website, copied intoSMPLX/models/smplx/. -
MHR: the assets of the MHR release, downloaded within
MHR, which createsMHR/assets/:curl -OL https://github.com/facebookresearch/MHR/releases/download/v1.0.0/assets.zip && unzip assets.zip
ITW/inference: Runs SAM 3D Body, SAM 3D Body (CLUE) and CLUE on images and videos. CLUE is SAM 3D Body's architecture with its decoder and heads trained with CLUE from scratch. SAM 3D Body (CLUE) is Meta's released model unchanged, with CLUE's uncertainty head trained on top of it. All models are read from ITW/inference/assets/. Missing models are downloaded there on the first run from meghshukla/clue and facebook/sam-3d-body-dinov3. Both repositories are gated so please accept their terms on Hugging Face and log in with hf auth login. The folder ITW/inference/plugin is the standalone plugin described above. Further details are in ITW/inference/README.md and ITW/inference/plugin/README.md.
data-mining: Uses CLUE to find the images or video frames in which a body part (arm, hand, leg, foot, head, ...) or the body shape is most uncertain, or most certain, and exports every person's scores for data curation. mine.py runs the queries, and SKILL.md makes the folder an Agent Skill for coding agents. Please link the folder into your agent's skills folder and do not copy it: mine.py runs CLUE from ITW/inference next to it, so it only works inside the repository.
Start the container with docker-compose run --rm clue, or activate the virtual environment with the packages installed via pip.
FLAME, SMPLX, MHR: The experiments are run from within each folder.
cd FLAME # or SMPLX, MHR
python evaluation.py # error maps -> results/error_maps/, cost tables -> results/{time,memory,flops}/ (JSON and CSV)
python video.py # one MP4 per parameter sweep -> results/videos/
python demo.py # the interactive viewer, which requires a displayevaluation.py --qualitative renders only the error maps, and evaluation.py --set_parameters --seed 0 computes the error maps on random faces or bodies instead of the neutral one.
ITW/inference: Images and videos are processed from within ITW/inference. The input can also be a folder, and --model selects any of sam3dbody, sam3dbody_clue and clue (all three by default).
cd ITW/inference
python run.py --input examples/six_friends.jpg examples/video.mp4 --output results # -> results/six_friends.jpg, results/video.mp4data-mining: Queries are run from within data-mining. Each query creates a new folder queries/<query>__<input>/ with two rankings of people: those whose part stands out most from the rest of their body, and those whose part is most uncertain. --certain asks for the most certain people instead, --shape ranks the body shape, and --export scores.csv writes every person's scores to one table.
cd data-mining
python mine.py --input ../ITW/inference/examples/video.mp4 --part arm --query "find frames where the arm is most uncertain"A running container is stopped with docker stop <container id> (docker ps lists the running containers).
CLUE's code is released under the BSD-3-Clause-Clear License, which grants no patent rights. CLUE's weights build on SAM 3D Body and are released under the SAM License. Third-party code and models keep their own licences (see NOTICE).
We thank Meta for releasing SAM 3D Body, MHR and DINOv3, on which our in-the-wild experiments build. We also thank POCO for providing an open-source ITW pipeline as our starting point.
We use the FLAME and SMPL-X models with the FLAME_PyTorch and smplx code. The example images and videos are from Pexels.
If you find this work useful, please consider starring this repository and citing this work!
@misc{shukla2026modelinguncertaintypropagation3d,
title={Modeling Uncertainty Propagation in 3D Morphable Models},
author={Megh Shukla and Edo Collins and Prashanth Chandran and Karel Petránek and Sergio Orts-Escolano and Mathieu Salzmann and Alexandre Alahi},
year={2026},
eprint={2610.24646},
archivePrefix={arXiv},
primaryClass={cs.CV},
url={https://arxiv.org/abs/2610.24646},
}





