Run this model with HF Jobs
Run sleepyreapy/sam3d-body-jax on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs to fine-tune https://huggingface.co/sleepyreapy/sam3d-body-jax. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/sleepyreapy/sam3d-body-jax on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Instructions to use sleepyreapy/sam3d-body-jax with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- SAM 3D Body
How to use sleepyreapy/sam3d-body-jax with SAM 3D Body:
import cv2 import numpy as np from notebook.utils import setup_sam_3d_body from tools.vis_utils import visualize_sample_together estimator = setup_sam_3d_body("sleepyreapy/sam3d-body-jax") img_bgr = cv2.imread("path/to/image.jpg") outputs = estimator.process_one_image(cv2.cvtColor(img_bgr, cv2.COLOR_BGR2RGB)) rend_img = visualize_sample_together(img_bgr, outputs, estimator.faces) cv2.imwrite("output.jpg", rend_img.astype(np.uint8)) - Notebooks
- Google Colab
- Kaggle
sam3d-body-jax
A static-shape JAX/Flax port of Meta's SAM 3D Body
(facebook/sam-3d-body-dinov3: DINOv3 ViT-H+/16 backbone, promptable body and hand decoders, MHR rig),
written for batched inference on Google Cloud TPUs and Colab TPU runtimes.
- Weights as
safetensors+config.json. Every tensor of Meta'smodel.ckptis accounted for in a conversion ledger; nothing is retrained. - One XLA program per batch size. The whole body β hands β fusion β keypoint-prompted refinement pipeline is a single static graph: hand crops are a padded
[B, 2, H, W, 3]tensor with a validity mask, there is no data-dependent Python control flow, and nothing recompiles between frames. - bfloat16 on the matrix units, float32 where it matters. Transformer matmuls run in bf16; LayerNorm, RoPE, the regression heads, camera geometry and the MHR rig stay in float32.
- Parameter-only fast path. By default the model returns MHR parameters, joints and the 70 keypoints (which need only 468 of the 18,439 vertices). The full mesh is opt-in or rebuilt later from the parameters.
- Verified against PyTorch. Stage-by-stage float32 parity at 1e-6 β 3e-4 relative (worst tensor of each stage), on CPU and again on a TPU. Numbers below.
This is an independent port. It is not affiliated with or endorsed by Meta. The weights remain under the SAM License; see Licences.
Quick start
pip install "jax[tpu]" -f https://storage.googleapis.com/jax-releases/libtpu_releases.html # or jax[cuda12] / jax
pip install flax ml_dtypes "opencv-python-headless==4.14.*" huggingface_hub
import numpy as np, cv2
from sam3d_body_jax import Sam3dBodyPipeline
pipe = Sam3dBodyPipeline.from_pretrained("path/to/this/repo", precision="bf16") # "fp32" for reference numerics
image = cv2.cvtColor(cv2.imread("frame.jpg"), cv2.COLOR_BGR2RGB)
boxes = np.array([[410, 30, 870, 700]], np.float32) # person boxes, xyxy, from any detector
out = pipe(image, boxes) # body + both hands + fusion
out["pred_keypoints_3d"] # (N, 70, 3) metres, camera-relative
out["pred_keypoints_2d"] # (N, 70, 2) pixels in the input frame
out["mhr_model_params"], out["shape"] # MHR pose / identity parameters
out["hand_valid_mask"] # (N, 2) which hand estimates were fused (left, right)
out = pipe(image, boxes, hands=False) # body decoder only (still a full-body estimate)
Vertices:
pipe = Sam3dBodyPipeline.from_pretrained(path, mesh=True)
out = pipe(image, boxes, mesh=True) # adds pred_vertices (N, 18439, 3)
# or keep inference parameter-only and rebuild the mesh afterwards
from sam3d_body_jax import weights
from sam3d_body_jax.mesh import reconstruct_vertices, save_obj
mesh_mhr = weights.load_mhr(path, mesh=True)
verts = reconstruct_vertices(mesh_mhr, out)
save_obj("person0.obj", verts[0], mesh_mhr["faces"])
Batched video, one device call per batch (see tools/bench_tpu.py and the
Colab notebook):
fn = pipe.fn("frames") # (params, mhr, frames[B,H,W,3] uint8, boxes[B,4]) -> outputs
out = fn(pipe.params, pipe.mhr_f, frames, boxes) # crops, both decoders, fusion: all on the accelerator
fn = pipe.fn("full") # same, with body crops cut on the host (exact OpenCV crops)
Keep the batch size fixed (pad the last batch): a new batch size is a new XLA program.
What is in the repository
| path | |
|---|---|
model.safetensors, config.json |
converted network weights (2.08 GB; backbone in its released bfloat16, heads float32) and configuration |
mhr_keypoints.safetensors |
MHR rig restricted to the 468 vertices the 70 keypoints depend on (27 MB) β all the fast path needs |
mhr_mesh.safetensors |
full MHR rig, 18,439 vertices + faces (706 MB) β only for vertices |
conversion_ledger.json |
what happened to each of the 1,127 checkpoint tensors |
sam3d_body_jax/ |
the model: backbone.py, layers.py, model.py, mhr.py, rotations.py, preprocess.py, pipeline.py, weights.py, mesh.py, config.py |
convert_weights.py |
model.ckpt + mhr_model.pt β the files above |
tools/make_reference.py, tools/parity.py, tools/summarize_parity.py |
PyTorch reference dump and the parity harness |
tools/bench_tpu.py, tools/tpu_vm.ps1, tools/tpu_startup.sh, tools/run_tpu_job.sh |
throughput benchmark and the Spot TPU VM runner used for the numbers below |
parity/, bench/ |
the raw reports behind every number in this file |
tools/stage_hf.py, tools/smoke_staged.py |
assemble this Hub layout from a git checkout + converted weights, and run every snippet of this README against it |
tests/ |
pytest parity suite |
notebooks/sam3d_body_tpu_demo.ipynb |
Colab TPU demo |
How the port is put together
Upstream pipeline
For each person box, upstream SAM 3D Body
- crops the person to 512Γ512, runs the ViT-H+ backbone (1,024 patch tokens of width 1,280), and decodes a full-body estimate with the 6-layer body decoder (pose token + prompt token + 70 keypoint tokens, each layer re-projecting intermediate keypoints into the feature map);
- reads left/right hand boxes off the body decoder, crops both hands from the frame (the left one mirrored), and runs backbone + hand decoder on each;
- decides per hand whether to trust it (wrist-angle, box-size and 2D-keypoint agreement tests), replaces the body's hand pose, wrist and scale parameters with the hand decoder's where it does, turns wrist and elbow keypoints into prompts, and runs the body decoder once more with those prompts;
- converts everything to MHR parameters and evaluates the rig.
What had to change for a static graph
| upstream (dynamic) | here (static) |
|---|---|
| Python loop over people; batch-size-1 path differs from the batched path | Meta's batched (B > 1) code path for every batch size |
| hand crops only for some people; boolean-mask indexing when fusing | every person always gets both hand passes as a padded [B, 2, β¦] batch; fusion is where(valid, hand, body); the mask is returned as hand_valid_mask |
keypoint prompts chosen with if / boolean indexing |
fixed-size prompt tensors with an "invalid point" label |
F.grid_sample, antialiased F.interpolate on runtime sizes |
gather-based bilinear sampling and a fixed antialias kernel, all sizes known at trace time |
| 16Γ16 patch conv | reshape + matmul |
| sparse pose-corrective layer, ragged skinning weights | dense matrix; four packed skin slots per vertex |
| mesh always computed | keypoints from a 468-vertex sub-rig; full mesh optional |
| cv2 crops on the host | exact cv2 path kept (exact_crops=True), plus an on-device bilinear warp_crop for single-program inference |
Weight conversion
convert_weights.py needs only torch and safetensors:
python convert_weights.py --ckpt-dir /path/to/sam-3d-body-dinov3 --out weights/
1,127 checkpoint tensors (953,309,996 elements) become 1,000 Flax parameters (941,516,618 elements). Nothing is left
unmapped: 649 are copied, 307 Linear weights transposed, 70 per-keypoint tensors stacked, 32 DINOv3 attention biases
multiplied by their bias_mask (which absorbs the 32 masks), 9 convolutions reshaped, 3 squeezed, 13 MHR buffers moved to
the mhr_*.safetensors files and 13 duplicate buffers dropped. weights.verify checks the result against the
shapes the Flax model expects (no missing, unexpected or mismatched entries), and conversion_ledger.json lists the
fate of every tensor.
Precision
| part | precision="bf16" |
precision="fp32" |
|---|---|---|
| backbone and decoder matmuls (Dense, attention) | bfloat16 | float32 |
| LayerNorm, RoPE rotation | float32 | float32 |
| pose / camera heads, prompt encoder, ray embedding | float32 | float32 |
| camera projection, rotations, MHR rig | float32 | float32 |
TPU matmul precision. TPUs evaluate float32 matmuls with a reduced-precision shortcut by default. Measured on
a v6e that costs about 3e-3 relative error β 4 mm on the MHR rig alone. The entry points therefore trace under
jax.default_matmul_precision("highest"). In an early v6e run, tracing every layer under highest
cost 34β35 % throughput at batch 8 compared with tracing none of them that way (139.8 β 91.9 frames/s body-only,
47.4 β 30.7 full). bfloat16 layers therefore switch back to the default explicitly, which costs no accuracy
(bf16 TPU parity below was measured with exactly this arrangement). The released arrangement was fully benchmarked
on v5e only; how much of the 34β35 % it recovers on v6e was not re-measured. If you call the modules yourself, keep sam3d_body_jax.model.precise / layers.mxu_precision in place.
Parity with PyTorch
Reference: upstream PyTorch code and model.ckpt in float32 on CPU, dumped with tools/make_reference.py
(every intermediate of every stage). Two fixtures: a 4-box one and an "edge" one (frame resized Γ0.37, 3 boxes) where
upstream rejects two of the six hands, so both branches of the fusion are exercised.
max abs is the worst element of the worst tensor in the group; relative errors are max|aβb| / max|b|.
Float32 on CPU (JAX 0.12.1) β main fixture
parity/cpu_fp32.json β 0.12.1 cpu x1 precision=fp32
| stage | features, max rel | parameters, max abs (mean) | 3D geometry, max abs (mean), m | 2D keypoints, max abs (mean), px |
|---|---|---|---|---|
| mhr | β | 2.9e-06 (5.3e-09) | 9.5e-07 (7.9e-08) | β |
| backbone | 1.4e-05 | β | β | β |
| body | 8.4e-06 | 7.6e-06 (3.7e-07) | 1.2e-06 (2.5e-07) | 6.7e-04 (1.3e-04) |
| mask | 5.2e-06 | 5.7e-06 (5.1e-07) | 1.9e-06 (6.6e-07) | 7.3e-04 (2.3e-04) |
| hands | 1.2e-04 | 6.1e-05 (2.9e-06) | 3.8e-06 (7.3e-07) | 3.7e-04 (5.4e-05) |
| fuse | 9.7e-07 | 5.6e-06 (2.5e-07) | 1.7e-06 (2.3e-07) | 7.3e-04 (1.8e-04) |
| e2e | β | 2.5e-03 (2.7e-05) | 4.0e-05 (1.3e-06) | 2.5e-02 (9.9e-04) |
| device | β | 2.0e-02 (9.2e-04) | 1.6e-03 (9.6e-05) | 5.8e-01 (5.3e-02) |
hand-valid mask agreement: fuse 8/8, e2e 8/8, device 8/8
Float32 on CPU β edge fixture (two rejected hands)
parity/cpu_fp32_edge.json β 0.12.1 cpu x1 precision=fp32
| stage | features, max rel | parameters, max abs (mean) | 3D geometry, max abs (mean), m | 2D keypoints, max abs (mean), px |
|---|---|---|---|---|
| mhr | β | 9.5e-07 (5.8e-09) | 9.5e-07 (7.5e-08) | β |
| backbone | 1.3e-05 | β | β | β |
| body | 1.2e-05 | 6.0e-06 (4.1e-07) | 2.9e-06 (7.3e-07) | 2.4e-04 (7.3e-05) |
| mask | 8.2e-06 | 7.6e-06 (6.3e-07) | 1.2e-06 (3.7e-07) | 2.1e-04 (6.3e-05) |
| hands | 1.7e-04 | 3.8e-05 (1.9e-06) | 8.8e-06 (6.3e-07) | 2.4e-04 (3.2e-05) |
| fuse | 9.2e-07 | 5.7e-06 (2.9e-07) | 1.9e-06 (2.4e-07) | 2.4e-04 (6.5e-05) |
| e2e | β | 3.9e-03 (6.8e-05) | 1.5e-04 (2.7e-06) | 3.6e-02 (8.1e-04) |
| device | β | 3.1e-02 (1.2e-03) | 2.8e-03 (3.0e-04) | 6.9e-01 (6.7e-02) |
hand-valid mask agreement: fuse 6/6, e2e 6/6, device 6/6
Float32 on a TPU v5e (JAX 0.6.2, libtpu 0.0.17)
parity/tpu_v5e_fp32.json β 0.6.2 tpu x1 precision=fp32
| stage | features, max rel | parameters, max abs (mean) | 3D geometry, max abs (mean), m | 2D keypoints, max abs (mean), px |
|---|---|---|---|---|
| mhr | β | 3.3e-06 (9.1e-09) | 1.3e-06 (8.8e-08) | β |
| backbone | 1.3e-05 | β | β | β |
| body | 1.2e-05 | 7.1e-06 (3.7e-07) | 1.9e-06 (3.2e-07) | 6.1e-04 (1.2e-04) |
| mask | 8.3e-06 | 2.1e-06 (3.1e-07) | 5.4e-07 (1.5e-07) | 4.3e-04 (1.3e-04) |
| hands | 2.2e-04 | 7.6e-05 (2.9e-06) | 5.2e-06 (7.3e-07) | 3.7e-04 (7.6e-05) |
| fuse | 1.3e-06 | 6.2e-06 (2.4e-07) | 2.1e-06 (2.6e-07) | 6.1e-04 (1.7e-04) |
| e2e | β | 1.8e-02 (1.5e-04) | 1.6e-04 (7.7e-06) | 6.1e-02 (5.5e-03) |
| device | β | 2.2e-02 (8.9e-04) | 1.6e-03 (9.5e-05) | 5.8e-01 (5.2e-02) |
hand-valid mask agreement: fuse 8/8, e2e 8/8, device 8/8
Edge fixture on the TPU: parity/tpu_v5e_fp32_edge.json β same picture (stages β€ 2.8e-4 relative, e2e geometry β€ 0.19 mm, masks 6/6).
bfloat16, against the float32 PyTorch reference
On CPU (JAX 0.12.1), parity/cpu_bf16.json: backbone features 1.1e-1 max relative; end to
end 3.5 mm max / 0.40 mm mean on 3D geometry, 1.7 px max / 0.18 px mean on 2D keypoints; hand masks 8/8. On a TPU v5e:
parity/tpu_v5e_bf16.json β 0.6.2 tpu x1 precision=bf16
| stage | features, max rel | parameters, max abs (mean) | 3D geometry, max abs (mean), m | 2D keypoints, max abs (mean), px |
|---|---|---|---|---|
| mhr | β | 3.3e-06 (9.1e-09) | 1.3e-06 (8.8e-08) | β |
| backbone | 9.2e-02 | β | β | β |
| body | 7.4e-02 | 1.9e-02 (9.2e-04) | 2.8e-03 (5.3e-04) | 2.0e+00 (1.4e-01) |
| mask | 2.6e-02 | 1.6e-02 (1.0e-03) | 9.8e-04 (3.2e-04) | 3.0e-01 (1.0e-01) |
| hands | 4.2e-01 | 2.7e-02 (8.6e-04) | 7.3e-03 (7.7e-04) | 1.4e-01 (3.5e-02) |
| fuse | 3.7e-02 | 2.9e-02 (7.3e-04) | 4.0e-03 (5.4e-04) | 1.4e+00 (2.7e-01) |
| e2e | β | 8.3e-02 (2.7e-03) | 3.3e-03 (4.7e-04) | 2.0e+00 (2.4e-01) |
| device | β | 8.9e-02 (3.2e-03) | 2.5e-03 (4.0e-04) | 1.6e+00 (2.6e-01) |
hand-valid mask agreement: fuse 8/8, e2e 8/8, device 8/8
Edge fixture: parity/tpu_v5e_bf16_edge.json (e2e geometry β€ 2.8 mm, mean 0.5 mm; masks 6/6). Keeping the attention softmax in float32 (softmax_fp32=True, parity/tpu_v5e_bf16_softmax32.json) changes little (e2e geometry 2.0 mm max, 0.45 mm mean), so it is off by default.
Reading the tables:
- Stage rows (
backboneβ¦fuse) feed each stage the reference inputs of that stage. This is the strict comparison of the network itself: every float32 stage is below 1e-3 on every output (worst: 3e-4 relative on one hand-decoder feature tensor). e2eis JAX from pixels to the final output using host (OpenCV) hand crops, so float differences compound through the hand-box regression, an integer-rounded crop (99.9 % of hand-crop pixels identical), and the re-prompted decoder. Geometry stays within ~0.2 mm and 2D keypoints within 0.06 px; individual parameters move by up to 4e-3 on CPU and 2e-2 on the TPU (mean ~1e-4).- bfloat16 is a different numerical regime, not a porting error: the backbone features differ from float32 by about 1 % on average (9 % worst element), which ends up as ~0.5 mm mean / ~3 mm worst-case on 3D keypoints and vertices and ~0.25 px mean / 2 px worst-case on 2D keypoints. The MHR rig itself stays at 1e-6 because it is always float32.
deviceis the single-program mode (pipe.fn("full")): hand crops are resampled on the accelerator with a float bilinear kernel rather than OpenCV's fixed-point one, so it is close, not identical: a few millimetres and under one pixel.- The hand-valid mask matched upstream on every hand of both fixtures in every mode (8/8 and 6/6).
Known, deliberate deviations from upstream:
joint_global_rotshere comes from the final MHR evaluation. Upstream returns the rotations from before the hand fusion and re-prompt (the field is never refreshed); the parity harness compares against upstream's final MHR call instead.- Upstream normalises the right-wrist distance test by the left hand box (and vice versa). The default
wrist_distance_norm="upstream"reproduces that;"matched"uses each hand's own box. - Exact hand crops need OpenCV 4.x (4.14 tested, pixel-identical). OpenCV 5.1 produces slightly different
warpAffineoutput (97 % identical pixels), which is enough to move outputs by ~1e-3.
Reproduce:
python tools/make_reference.py --upstream /path/to/sam-3d-body --ckpt-dir /path/to/sam-3d-body-dinov3 \
--image person.jpg --boxes "x1,y1,x2,y2;..." --out fixtures/reference_fp32.npz # needs PyTorch
python tools/parity.py --fixture fixtures/reference_fp32.npz --precision fp32 --out parity/cpu_fp32.json
python tools/summarize_parity.py parity/cpu_fp32.json
pytest # -m "not slow" skips the full-network stages
TPU throughput
Measured on single-chip Spot TPU VMs in us-east1 on 2026-12-02 (JAX 0.6.2, libtpu 0.0.17, runtime
v2-alpha-tpuv5-lite / v2-alpha-tpuv6e), with tools/bench_tpu.py:
- body = body decoder only, parameter outputs (one backbone pass per person).
- full = body + both hands + fusion + re-prompted body decoder in one XLA program, starting from 1280Γ720
uint8frames resident in host memory (three backbone passes per person, hand crops resampled on the TPU). - device = steady state with inputs already on the accelerator; end to end = host NumPy in, host NumPy out, including the transfer of the frames. Cost uses the end-to-end rate.
- No recompiles: the jit cache grew by exactly one program per batch size (plus one for the host-NumPy calling
convention) and never during the timed iterations (
xla_programs_device/jit_cache_entriesin the reports are cumulative per compiled function). All outputs were finite. - Inputs are synthetic (noise frames), which costs the same as real footage because the graph is static: both hand passes always run, whether or not the hands end up being fused.
- Prices are the Spot list prices of the zone the VM actually ran in, per chip-hour (the host VM is included in the
Cloud TPU price): v5e $0.3773, v6e $0.6360 in
us-central1/us-east1/us-west1.
TPU v5e (v5litepod-1), bfloat16 β complete sweep
| mode | batch | backbone chunk | compile (s) | frames/s (device) | frames/s (end to end) | ms / frame | $ / 1M frames |
|---|---|---|---|---|---|---|---|
| body | 8 | - | 57 | 53.9 | 51.2 | 19.5 | 2.05 |
| body | 16 | - | 61 | 49.9 | 47.7 | 21.0 | 2.20 |
| body | 32 | 32 | 50 | 50.6 | 48.5 | 20.6 | 2.16 |
| body | 64 | 32 | 45 | 50.3 | 48.4 | 20.7 | 2.17 |
| body | 128 | 32 | 46 | 50.4 | 49.1 | 20.3 | 2.13 |
| full | 8 | - | 146 | 17.4 | 16.5 | 60.7 | 6.36 |
| full | 16 | - | 144 | 16.5 | 15.3 | 65.3 | 6.85 |
| full | 32 | 32 | 128 | 16.6 | 16.1 | 62.3 | 6.53 |
| full | 64 | 32 | 124 | 16.6 | 16.3 | 61.5 | 6.45 |
| full | 128 | 32 | 127 | 16.6 | 16.3 | 61.2 | 6.41 |
Throughput is flat in the batch size: one v5e chip is saturated at batch 8, so pick the batch size for latency or
host convenience, not speed. backbone chunk is config.backbone_chunk, which runs the backbone over the batch
in lax.map chunks; without it the 64-person full pipeline (192 backbone images at once) drops to 13.5 frames/s
(bench/v5e_bf16_nochunk.json), with it large batches cost nothing.
Float32 on the same chip, for reference (bench/v5e_fp32.json): 16.4 frames/s body, 5.4 frames/s
full β bfloat16 is 3Γ faster.
TPU v6e (v6e-1, Trillium), bfloat16 β partial
Spot v6e capacity was preempted three times (after 11, 14 and 46 minutes) and then unavailable in every US zone tried, so there is no complete sweep of the released code on v6e. What was measured:
| build | mode | batch | compile (s) | frames/s (device) | frames/s (end to end) | $ / 1M frames |
|---|---|---|---|---|---|---|
| pre-release: float32 layers at the TPU's default (reduced) matmul precision | body | 8 | 43 | 139.8 | 127.4 | 1.39 |
| pre-release: same | full | 8 | 129 | 47.4 | 42.1 | 4.19 |
intermediate: highest matmul precision applied to all layers, bf16 included |
body | 8 / 32 / 64 | 55 | 91.9 / 81.6 / 81.3 | 86.8 / 78.0 / 77.9 | 2.04 β 2.27 |
| intermediate: same | full | 8 / 32 / 64 | 136 β 149 | 30.7 / 27.3 / 27.0 | 28.5 / 26.3 / 26.3 | 6.20 β 6.73 |
The released code sits between the two (bf16 layers at default precision like the first build, float32 heads and
rig at highest like the second), so on v6e expect roughly 80β127 frames/s body-only and 26β42 frames/s full,
i.e. $1.4β2.3 and $4.2β6.7 per million frames at the us-east1 Spot price. This is a bracket, not a measurement.
The same chip lists at $0.243/h Spot in us-east4, which would scale those costs by 0.38 β if you can get capacity.
Raw files: bench/v6e_smoke_bs8.json,
bench/v6e_bf16_allhighest_partial.json.
Cost per million frames
| setup | frames/s (full pipeline) | price / h | $ / 1M frames |
|---|---|---|---|
| PyTorch upstream, rented RTX 3090 (baseline supplied for this comparison, not re-measured here) | ~6.8 | $0.22 | ~$9.0 |
| this port, Spot TPU v5e, bf16, measured (batch 8 β 128) | 15.3 β 16.5 | $0.377 | $6.4 β 6.9 |
| this port, Spot TPU v6e, bf16, bracket from partial runs | 26 β 42 | $0.636 | $4.2 β 6.7 |
| this port, Spot TPU v5e, bf16, body-only (no hand refinement), measured | 48 β 51 | $0.377 | $2.1 β 2.2 |
Caveats for a like-for-like reading: the baseline is someone else's measurement of the dynamic PyTorch pipeline on real footage and includes whatever detector and I/O it used; the TPU rows are the model alone (boxes given), on synthetic frames, always running both hand passes, in bfloat16 (see the parity section for what that costs in accuracy). Compile time (about 1 minute body-only, 2β2.5 minutes full, per batch size) is paid once per process and is not included. Spot TPU capacity is not guaranteed, as the v6e attempt shows.
Reproduce on any machine with a TPU (or GPU):
python tools/bench_tpu.py --weights . --precision bf16 --batch-sizes 8,16,32,64,128 --modes body,full --out bench.json
python tools/summarize_bench.py --price 0.3773 bench.json
tools/tpu_vm.ps1, tools/tpu_startup.sh and tools/run_tpu_job.sh are the runner that produced these files: a
Spot TPU VM whose startup script pulls code, weights and fixtures from a GCS bucket (in/), runs the job scripts
found under jobs/, pushes results to out/ after every configuration (so a preempted VM loses nothing), and
deletes itself after a deadline. They are provided as-is: you need your own project, a bucket populated with
in/repo.tar, in/weights/, in/fixtures/, in/UPLOAD_DONE and jobs/*.sh, and a .tpu_vm.json of the form
{"project": "...", "bucket": "...", "vms": []} next to the README.
Licences
- Model code and converted weights: derivative of SAM 3D Body, Β© Meta Platforms, Inc., under the SAM License (reproduced unmodified), including its acceptable-use terms.
- MHR rig assets (
mhr_*.safetensors): from MHR, Apache-2.0. - DINOv3 backbone architecture: Β© Meta, DINOv3 License; the weights used are the ones inside the SAM 3D Body checkpoint.
- RoMa rotation conventions (re-implemented): MIT.
Details and the list of modifications are in NOTICE.
Related work
peabody124/Sam3dBodyEqx is an earlier JAX/Equinox port of SAM 3D
Body and worth knowing about if you work in Equinox. This repository was written independently from Meta's PyTorch
source and checkpoint only β no code or weights from that project were used β and aims at a different target:
Flax, Hugging Face safetensors, a fully static batched graph and measured TPU throughput.
Citation
Please cite the original work:
@article{yang2026sam3dbody,
title = {SAM 3D Body: Robust Full-Body Human Mesh Recovery},
author = {Yang, Xitong and Kukreja, Devansh and Pinkus, Don and Sagar, Anushka and Fan, Taosha and Park, Jinhyung and Shin, Soyong and Cao, Jinkun and Liu, Jiawei and Ugrinovic, Nicolas and Feiszli, Matt and Malik, Jitendra and Dollar, Piotr and Kitani, Kris},
journal = {arXiv preprint arXiv:2602.15989},
year = {2026}
}
- Downloads last month
- 15
Model tree for sleepyreapy/sam3d-body-jax
Base model
facebook/sam-3d-body-dinov3