tongflow-modal-sapiens2

July 11, 2026 · View on GitHub

Official TongFlow plugin. Human-centric vision suite built on Sapiens2 (Meta, ICLR 2026, facebookresearch/sapiens2) — six capabilities from the five 1B task checkpoints, running on one GPU app via Modal.

Capabilities

  • Pose detection (image-pose) — 308-keypoint whole-body pose (body, hands, 274 face points) for every detected person, rendered as a skeleton overlay PNG.
  • Body-part segmentation (image-body-seg) — 29-class per-pixel body-part segmentation, color-coded overlay PNG.
  • Surface normals (image-normal) — per-pixel surface normal map, background masked via body-part segmentation.
  • Human matting (image-matting) — human foreground extraction as a straight-alpha transparent PNG.
  • Image → 3D (image-gen-model) — Sapiens2 pointmap turned into a colored, human-only 3D point cloud GLB.
  • Video motion capture (video-gen-model) — monocular video → animated 3D human GLB, pure Sapiens2: 2D pose is lifted to 3D by sampling the pointmap at each keypoint, One-Euro smoothed, solved into per-joint rotations (body + fingers + jaw, with rest-pose hold for unseen body parts), and retargeted onto MHR (Meta's Momentum Human Rig, Apache-2.0). Single subject (largest person, IoU-tracked). Plays directly in the TongFlow model node; imports as a skinned armature in Blender. Set MOCAP_STYLE=skeleton for the raw bone-puppet output; run modal run extract_mhr.py::extract once to (re)build the MHR bundle. For the SAM-3D-Body-based capture (learned prior, hands + experimental face), use the tongflow-modal-sam-3d-body plugin on the same node slot.

Credentials

Add in TongFlow Settings (gear icon, top-right):

KeyRequiredNotes
MODAL_TOKEN_IDCreate at modal.com/settings/tokens.
MODAL_TOKEN_SECRETPaired with MODAL_TOKEN_ID.

Checkpoints are public (no HF token needed). On first use the plugin deploys to your Modal account automatically; weights (~31 GB: five 1B checkpoints + the DETR person detector) are cached on a shared Modal volume.

Tuning (env, optional)

EnvDefaultNotes
SAPIENS2_MODEL_SIZE1bCheckpoint size to load (0.4b, 0.8b, 1b — re-run the weight download after changing).
SAPIENS2_GPUL40SModal GPU type (A100, H100, ... — applied on the next deploy).
SAPIENS2_DTYPEbf16Inference precision; set fp32 to disable bf16.
SAPIENS2_GPU_LRU5 (bf16) / 3 (fp32)Task models kept GPU-resident before evicting to CPU.
MOCAP_FPS24Mocap sampling framerate.
MOCAP_BATCH4Frames per batched pose/pointmap/detector forward.
MOCAP_MAX_SECONDS60Mocap duration cap.
MOCAP_POSE_CONF_THR0.3Keypoint confidence below this is temporally interpolated.
MOCAP_ONE_EURO_MIN_CUTOFF / MOCAP_ONE_EURO_BETA1.5 / 0.3Smoothing: lower cutoff = smoother, higher beta = snappier.
TONGFLOW_MODAL_CALL_TIMEOUT_S3600Max seconds to wait for a Modal call.

Hardware

One L40S container serves all six slots. Models load lazily with a 3-model GPU LRU; the mocap slot keeps pose + pointmap resident and runs ~2–4 frames/s end to end.

License

Plugin code: AGPL-3.0 (TongFlow). Sapiens2 models and code are under the Sapiens2 License (Meta) — review it before commercial use.