SAM 3D Objects ONNX

ONNX builds of SAM 3D Objects, made by Moonbox for on-device use with ONNX Runtime (CPU, CUDA, DirectML). Each precision is one folder holding the graphs and a small Python pipeline.py that does the rest (image preprocessing, the sampling loop, mesh extraction); what the graphs take and return is under How to run.

Files

The last column is the benchmark against the original PyTorch model (details under How to run): how closely each mesh matches the original's, made from the same pictures and the same starting noise.

Precision File Size sha256 Benchmark
fp16 fp16/LICENSE-FlexiCubes.txt 11.6 kB 49bbe9114e49 teacher forced (human_object / animal / kidsroom): point map rel. error 0.15 / 0.06 / 0.63 % (floor 0.15 / 0.06 / 0.62), structure SNR 55.8 / 41.8 / 40.1 dB (floor 57.8 / 32.9 / 40.8), voxel IoU 1.000 / 0.998 / 0.997 (floor 1.000 / 0.993 / 0.997), pose within 0.04 degrees / 0.06 %, latent SNR 51.2 / 52.6 / 48.3 dB (floor 51.3 / 52.5 / 48.3), mesh F-score@0.005 1.000 / 1.000 / 0.957 (the original's mesh against itself resampled: 0.957); end to end F-score 1.000 / 0.996 / 0.928 (the original in fp32: 0.970 / 0.997 / -); 45-50 s per object (84 s for the 30 MP kidsroom), ~7 GB peak
fp16 fp16/LICENSE-SAM.txt 8.2 kB b3a5a0e2d973 (the same build: numbers in its first row)
fp16 fp16/LICENSE-TRELLIS.txt 1.2 kB 9906940f61b1 (the same build: numbers in its first row)
fp16 fp16/dino.onnx 0.3 MB 4abdace1d245 (the same build: numbers in its first row)
fp16 fp16/dino.onnx.data 1.22 GB 7dac4b145524 (the same build: numbers in its first row)
fp16 fp16/flexicubes_tables.npz 2.6 kB 1d22bf7f2ec2 (the same build: numbers in its first row)
fp16 fp16/mesh_conv.onnx 26.4 kB 011ad908aa43 (the same build: numbers in its first row)
fp16 fp16/mesh_conv.onnx.data 1.0 MB b039cb6b1cc1 (the same build: numbers in its first row)
fp16 fp16/mesh_dec.onnx 0.9 MB 4f251f0f0f15 (the same build: numbers in its first row)
fp16 fp16/mesh_dec.onnx.data 180.3 MB 747c4ef56d3d (the same build: numbers in its first row)
fp16 fp16/mesh_gn.onnx 3.1 kB 9f14e6e0daee (the same build: numbers in its first row)
fp16 fp16/mesh_out.onnx 27.6 kB 81d16b8a1ae1 (the same build: numbers in its first row)
fp16 fp16/mesh_out.onnx.data 0.6 MB 7464356dda05 (the same build: numbers in its first row)
fp16 fp16/moge.onnx 0.5 MB bed5a78f547f (the same build: numbers in its first row)
fp16 fp16/moge.onnx.data 1.25 GB 63bcec2af547 (the same build: numbers in its first row)
fp16 fp16/moge_pos_embed.npy 5.6 MB 73231693ad7d (the same build: numbers in its first row)
fp16 fp16/pipeline.py 19.8 kB ca2737d2c700 (the same build: numbers in its first row)
fp16 fp16/pipeline_tables.py 11.5 kB e8b782170511 (the same build: numbers in its first row)
fp16 fp16/sam3d.json 0.7 kB 053f9eb79812 (the same build: numbers in its first row)
fp16 fp16/slat_flow.onnx 2.0 MB 934a9a3c9f14 (the same build: numbers in its first row)
fp16 fp16/slat_flow.onnx.data 1.20 GB a7604b23aaf5 (the same build: numbers in its first row)
fp16 fp16/slat_fuse.onnx 8.3 kB 7046a06fe344 (the same build: numbers in its first row)
fp16 fp16/slat_fuse.onnx.data 69.2 MB 12e4f839d54f (the same build: numbers in its first row)
fp16 fp16/ss_dec.onnx 38.7 kB c972c9067577 (the same build: numbers in its first row)
fp16 fp16/ss_dec.onnx.data 294.7 MB cd5672e0eed7 (the same build: numbers in its first row)
fp16 fp16/ss_flow.onnx 2.9 MB 8c6f3de387ea (the same build: numbers in its first row)
fp16 fp16/ss_flow.onnx.data 1.94 GB d27cd65f3313 (the same build: numbers in its first row)
fp16 fp16/ss_fuse.onnx 57.2 kB e17b0b21223e (the same build: numbers in its first row)
fp16 fp16/ss_fuse.onnx.data 103.0 MB 147c69c12555 (the same build: numbers in its first row)
fp16 fp16/vendor/LICENSE-MoGe.txt 12.7 kB be23f97f4a4a (the same build: numbers in its first row)
fp16 fp16/vendor/moge_min.py 5.6 kB 56086fe43c6b (the same build: numbers in its first row)
fp16 fp16/vendor/pytorch3d/LICENSE-pytorch3d.txt 1.6 kB 60fa54e4d132 (the same build: numbers in its first row)
fp16 fp16/vendor/pytorch3d/__init__.py 0.1 kB c9cb6d0dda3b (the same build: numbers in its first row)
fp16 fp16/vendor/pytorch3d/common/__init__.py 0.1 kB 2e9a6555cb74 (the same build: numbers in its first row)
fp16 fp16/vendor/pytorch3d/common/datatypes.py 1.8 kB ebb59bb050d6 (the same build: numbers in its first row)
fp16 fp16/vendor/pytorch3d/common/workaround/__init__.py 0.3 kB 3fa9e1e8e8cb (the same build: numbers in its first row)
fp16 fp16/vendor/pytorch3d/common/workaround/symeig3x3.py 12.5 kB 47cc34d41be1 (the same build: numbers in its first row)
fp16 fp16/vendor/pytorch3d/common/workaround/utils.py 0.9 kB 3a4f12c4f79b (the same build: numbers in its first row)
fp16 fp16/vendor/pytorch3d/transforms/__init__.py 1.1 kB e8e77a00cba6 (the same build: numbers in its first row)
fp16 fp16/vendor/pytorch3d/transforms/math.py 3.1 kB 40591113fdfd (the same build: numbers in its first row)
fp16 fp16/vendor/pytorch3d/transforms/rotation_conversions.py 21.0 kB 50bcdf2ca096 (the same build: numbers in its first row)
fp16 fp16/vendor/pytorch3d/transforms/se3.py 8.2 kB 8b90c901c3ee (the same build: numbers in its first row)
fp16 fp16/vendor/pytorch3d/transforms/so3.py 8.9 kB bf0408ea6712 (the same build: numbers in its first row)
fp16 fp16/vendor/pytorch3d/transforms/transform3d.py 33.5 kB f0dc0a909f38 (the same build: numbers in its first row)
fp16 fp16/vendor/sam3d_objects/LICENSE-SAM.txt 8.3 kB 315341214aa8 (the same build: numbers in its first row)
fp16 fp16/vendor/sam3d_objects/__init__.py 0.0 kB e3b0c44298fc (the same build: numbers in its first row)
fp16 fp16/vendor/sam3d_objects/data/__init__.py 0.0 kB e3b0c44298fc (the same build: numbers in its first row)
fp16 fp16/vendor/sam3d_objects/data/dataset/__init__.py 0.0 kB e3b0c44298fc (the same build: numbers in its first row)
fp16 fp16/vendor/sam3d_objects/data/dataset/tdfy/__init__.py 0.0 kB e3b0c44298fc (the same build: numbers in its first row)
fp16 fp16/vendor/sam3d_objects/data/dataset/tdfy/img_and_mask_transforms.py 36.6 kB 469e11797e1e (the same build: numbers in its first row)
fp16 fp16/vendor/sam3d_objects/data/dataset/tdfy/img_processing.py 6.2 kB e6a77adaacfb (the same build: numbers in its first row)
fp16 fp16/vendor/sam3d_objects/data/dataset/tdfy/pose_target.py 33.3 kB bfcf87545266 (the same build: numbers in its first row)
fp16 fp16/vendor/sam3d_objects/data/dataset/tdfy/preprocessor.py 8.7 kB 7385dbbc0393 (the same build: numbers in its first row)
fp16 fp16/vendor/sam3d_objects/data/dataset/tdfy/transforms_3d.py 1.6 kB afe324382897 (the same build: numbers in its first row)
fp16 fp16/vendor/sam3d_objects/data/utils.py 1.0 kB 91be95cec3b8 (the same build: numbers in its first row)
fp16 fp16/vendor/sam3d_objects/model/__init__.py 0.0 kB e3b0c44298fc (the same build: numbers in its first row)
fp16 fp16/vendor/sam3d_objects/model/backbone/__init__.py 0.0 kB e3b0c44298fc (the same build: numbers in its first row)
fp16 fp16/vendor/sam3d_objects/model/backbone/dit/__init__.py 0.0 kB e3b0c44298fc (the same build: numbers in its first row)
fp16 fp16/vendor/sam3d_objects/model/backbone/dit/embedder/__init__.py 0.0 kB e3b0c44298fc (the same build: numbers in its first row)
fp16 fp16/vendor/sam3d_objects/model/backbone/dit/embedder/point_remapper.py 2.9 kB d64b1304c3aa (the same build: numbers in its first row)
fp16 fp16/vendor/sam3d_objects/pipeline/__init__.py 0.0 kB e3b0c44298fc (the same build: numbers in its first row)
fp16 fp16/vendor/sam3d_objects/pipeline/inference_utils.py 9.7 kB 24e9f20e3f68 (the same build: numbers in its first row)
int8 int8/LICENSE-FlexiCubes.txt 11.6 kB 49bbe9114e49 experimental: flows 8-bit: structure SNR 33.0 / 22.6 / 25.9 dB, voxel IoU 0.998 / 0.956 / 0.981, pose rotation 0.36 / 0.31 / 0.63 degrees, latent SNR 33.7 / 33.9 / 32.9 dB; end to end F-score 0.932 / 0.972 / 0.907
int8 int8/LICENSE-SAM.txt 8.2 kB b3a5a0e2d973 (the same build: numbers in its first row)
int8 int8/LICENSE-TRELLIS.txt 1.2 kB 9906940f61b1 (the same build: numbers in its first row)
int8 int8/dino.onnx 0.3 MB 4abdace1d245 (the same build: numbers in its first row)
int8 int8/dino.onnx.data 1.22 GB 7dac4b145524 (the same build: numbers in its first row)
int8 int8/flexicubes_tables.npz 2.6 kB 1d22bf7f2ec2 (the same build: numbers in its first row)
int8 int8/mesh_conv.onnx 26.4 kB 011ad908aa43 (the same build: numbers in its first row)
int8 int8/mesh_conv.onnx.data 1.0 MB b039cb6b1cc1 (the same build: numbers in its first row)
int8 int8/mesh_dec.onnx 0.9 MB 4f251f0f0f15 (the same build: numbers in its first row)
int8 int8/mesh_dec.onnx.data 180.3 MB 747c4ef56d3d (the same build: numbers in its first row)
int8 int8/mesh_gn.onnx 3.1 kB 9f14e6e0daee (the same build: numbers in its first row)
int8 int8/mesh_out.onnx 27.6 kB 81d16b8a1ae1 (the same build: numbers in its first row)
int8 int8/mesh_out.onnx.data 0.6 MB 7464356dda05 (the same build: numbers in its first row)
int8 int8/moge.onnx 0.5 MB bed5a78f547f (the same build: numbers in its first row)
int8 int8/moge.onnx.data 1.25 GB 63bcec2af547 (the same build: numbers in its first row)
int8 int8/moge_pos_embed.npy 5.6 MB 73231693ad7d (the same build: numbers in its first row)
int8 int8/pipeline.py 19.8 kB ca2737d2c700 (the same build: numbers in its first row)
int8 int8/pipeline_tables.py 11.5 kB e8b782170511 (the same build: numbers in its first row)
int8 int8/sam3d.json 0.7 kB 053f9eb79812 (the same build: numbers in its first row)
int8 int8/slat_flow.onnx 2.0 MB c930ecc4a1f4 (the same build: numbers in its first row)
int8 int8/slat_flow.onnx.data 677.8 MB c0171fc2ada1 (the same build: numbers in its first row)
int8 int8/slat_fuse.onnx 8.3 kB 7046a06fe344 (the same build: numbers in its first row)
int8 int8/slat_fuse.onnx.data 69.2 MB 12e4f839d54f (the same build: numbers in its first row)
int8 int8/ss_dec.onnx 38.7 kB c972c9067577 (the same build: numbers in its first row)
int8 int8/ss_dec.onnx.data 294.7 MB cd5672e0eed7 (the same build: numbers in its first row)
int8 int8/ss_flow.onnx 3.0 MB cc314370ada7 (the same build: numbers in its first row)
int8 int8/ss_flow.onnx.data 1.04 GB c1b2ab353447 (the same build: numbers in its first row)
int8 int8/ss_fuse.onnx 57.2 kB e17b0b21223e (the same build: numbers in its first row)
int8 int8/ss_fuse.onnx.data 103.0 MB 147c69c12555 (the same build: numbers in its first row)
int8 int8/vendor/LICENSE-MoGe.txt 12.7 kB be23f97f4a4a (the same build: numbers in its first row)
int8 int8/vendor/moge_min.py 5.6 kB 56086fe43c6b (the same build: numbers in its first row)
int8 int8/vendor/pytorch3d/LICENSE-pytorch3d.txt 1.6 kB 60fa54e4d132 (the same build: numbers in its first row)
int8 int8/vendor/pytorch3d/__init__.py 0.1 kB c9cb6d0dda3b (the same build: numbers in its first row)
int8 int8/vendor/pytorch3d/common/__init__.py 0.1 kB 2e9a6555cb74 (the same build: numbers in its first row)
int8 int8/vendor/pytorch3d/common/datatypes.py 1.8 kB ebb59bb050d6 (the same build: numbers in its first row)
int8 int8/vendor/pytorch3d/common/workaround/__init__.py 0.3 kB 3fa9e1e8e8cb (the same build: numbers in its first row)
int8 int8/vendor/pytorch3d/common/workaround/symeig3x3.py 12.5 kB 47cc34d41be1 (the same build: numbers in its first row)
int8 int8/vendor/pytorch3d/common/workaround/utils.py 0.9 kB 3a4f12c4f79b (the same build: numbers in its first row)
int8 int8/vendor/pytorch3d/transforms/__init__.py 1.1 kB e8e77a00cba6 (the same build: numbers in its first row)
int8 int8/vendor/pytorch3d/transforms/math.py 3.1 kB 40591113fdfd (the same build: numbers in its first row)
int8 int8/vendor/pytorch3d/transforms/rotation_conversions.py 21.0 kB 50bcdf2ca096 (the same build: numbers in its first row)
int8 int8/vendor/pytorch3d/transforms/se3.py 8.2 kB 8b90c901c3ee (the same build: numbers in its first row)
int8 int8/vendor/pytorch3d/transforms/so3.py 8.9 kB bf0408ea6712 (the same build: numbers in its first row)
int8 int8/vendor/pytorch3d/transforms/transform3d.py 33.5 kB f0dc0a909f38 (the same build: numbers in its first row)
int8 int8/vendor/sam3d_objects/LICENSE-SAM.txt 8.3 kB 315341214aa8 (the same build: numbers in its first row)
int8 int8/vendor/sam3d_objects/__init__.py 0.0 kB e3b0c44298fc (the same build: numbers in its first row)
int8 int8/vendor/sam3d_objects/data/__init__.py 0.0 kB e3b0c44298fc (the same build: numbers in its first row)
int8 int8/vendor/sam3d_objects/data/dataset/__init__.py 0.0 kB e3b0c44298fc (the same build: numbers in its first row)
int8 int8/vendor/sam3d_objects/data/dataset/tdfy/__init__.py 0.0 kB e3b0c44298fc (the same build: numbers in its first row)
int8 int8/vendor/sam3d_objects/data/dataset/tdfy/img_and_mask_transforms.py 36.6 kB 469e11797e1e (the same build: numbers in its first row)
int8 int8/vendor/sam3d_objects/data/dataset/tdfy/img_processing.py 6.2 kB e6a77adaacfb (the same build: numbers in its first row)
int8 int8/vendor/sam3d_objects/data/dataset/tdfy/pose_target.py 33.3 kB bfcf87545266 (the same build: numbers in its first row)
int8 int8/vendor/sam3d_objects/data/dataset/tdfy/preprocessor.py 8.7 kB 7385dbbc0393 (the same build: numbers in its first row)
int8 int8/vendor/sam3d_objects/data/dataset/tdfy/transforms_3d.py 1.6 kB afe324382897 (the same build: numbers in its first row)
int8 int8/vendor/sam3d_objects/data/utils.py 1.0 kB 91be95cec3b8 (the same build: numbers in its first row)
int8 int8/vendor/sam3d_objects/model/__init__.py 0.0 kB e3b0c44298fc (the same build: numbers in its first row)
int8 int8/vendor/sam3d_objects/model/backbone/__init__.py 0.0 kB e3b0c44298fc (the same build: numbers in its first row)
int8 int8/vendor/sam3d_objects/model/backbone/dit/__init__.py 0.0 kB e3b0c44298fc (the same build: numbers in its first row)
int8 int8/vendor/sam3d_objects/model/backbone/dit/embedder/__init__.py 0.0 kB e3b0c44298fc (the same build: numbers in its first row)
int8 int8/vendor/sam3d_objects/model/backbone/dit/embedder/point_remapper.py 2.9 kB d64b1304c3aa (the same build: numbers in its first row)
int8 int8/vendor/sam3d_objects/pipeline/__init__.py 0.0 kB e3b0c44298fc (the same build: numbers in its first row)
int8 int8/vendor/sam3d_objects/pipeline/inference_utils.py 9.7 kB 24e9f20e3f68 (the same build: numbers in its first row)

How to run

SAM 3D Objects (Meta: one picture plus a mask of an object in it, to the object's 3D mesh with colours and its pose in the camera) as ONNX graphs plus pipeline.py, a numpy runtime that reproduces the official InferencePipelinePointMap.run (github.com/facebookresearch/sam-3d-objects) as its notebook calls it.

What runs. SAM 3D works on sparse voxels. The stages:

  • Point map: MoGe-v1 (ViT-L, the depth model the official pipeline.yaml names) gives every pixel of the whole picture a 3D point and the camera's focal length.
  • Image features: DINOv2-L/14 with registers encodes four 518 x 518 pictures: the object's crop, the whole picture, and the mask of each. The checkpoints' four towers are the same frozen weights, so one graph serves all four passes.
  • Conditions: two fusers turn those tokens into each stage's condition. The structure stage's also embeds the object's point map, in patches.
  • Structure and pose: a mixture-of-transformers flow (964M) samples a 16^3 x 8 shape latent together with the object's pose: 6D rotation, translation and scale. It runs 25 Euler steps with classifier-free guidance 7 over the first half. A convolutional decoder turns the latent into a 64^3 occupancy grid, and the original's own pruning and downsampling keep its surface voxels (typically 4-30 thousand). The pose decoder puts the object in the camera.
  • Latent: a sparse flow transformer (TRELLIS v1 layout, 626M) samples 8 features per voxel in 25 steps.
  • Mesh: the mesh decoder (TRELLIS v1 sparse Swin) subdivides the voxels twice, to 256^3, and predicts FlexiCubes features with vertex colours. The mesh is extracted from those features in numpy.

Not included:

  • the Gaussian-splat decoder;
  • the original's mesh post-processing and texture baking (with_mesh_postprocess, with_texture_baking: off in the notebook's call too);
  • the layout post-optimisation (with_layout_postprocess, which renders the mesh against the point map with pytorch3d).

The mesh has its colour per vertex (save_mesh writes a GLB). The pose comes back as the original returns it: rotation quaternion, translation and scale in the camera's frame (PyTorch3D convention), with the camera intrinsics from MoGe.

The graphs. ONNX has no sparse operations, so pipeline.py builds index tables from the voxel coordinates in numpy and the graphs use them:

  • a submanifold 3x3x3 convolution (spconv in the original) is 27 gathers of neighbour features times the kernel slices, summed in fp32;
  • the latent flow's and the mesh decoder's windowed attention runs over gathered windows (the mesh decoder's in eight groups of windows, one after another, to bound memory);
  • the mesh decoder runs as four graphs: up to 128^3 in one; its last block, at 256^3, chunk by chunk over the voxels (262,144 at a time), with the GroupNorm statistics of all voxels computed in numpy between two passes. The 256^3 convolution gathers straight from each voxel's 128^3 parent instead of copying its features 8 times.
Graph Inputs Output
moge.onnx image14 [1, 3, h, w] (resized, normalised), pos_embed, uv0 ... uv3 (built in numpy for the picture's size) points and mask at the network's resolution
dino.onnx pixels [B, 3, 518, 518] in [0, 1] norm_tokens [B, 1370, 1024], prenorm_tokens [B, 1374, 1024]
ss_fuse.onnx the four token sets, pointmap / rgb_pointmap [B, 3, 518, 518] cond [B, 7528, 1024]
ss_flow.onnx shape [B, 4096, 8], rotation6d [B, 1, 6], translation [B, 1, 3], scale [B, 1, 3], translation_scale [B, 1, 1], t [B] (1000 t), d [B], cond the five velocities
ss_dec.onnx z [1, 8, 16, 16, 16] occupancy logits [1, 1, 64, 64, 64]
slat_fuse.onnx the four prenorm token sets cond [B, 5496, 1024]
slat_flow.onnx feats [N, 8], t [1], cond, index tables velocity [N, 8]
mesh_dec.onnx slat [N, 8], window and neighbour tables h128 / x128 [8 N, 192] (the last block's normed / raw input)
mesh_conv.onnx h: h128, nbr [C, 27] (the neighbours' parents) first convolution [C, 96]
mesh_gn.onnx f: that, mean / rstd [32] (over all voxels) GroupNorm + SiLU [C, 96]
mesh_out.onnx g: the normed features [64 N, 96], nbr [C, 27], xs: x128, par [C] FlexiCubes features [C, 101]
import sys
sys.path.insert(0, "fp16")
import pipeline
from PIL import Image
p = pipeline.Sam3DObjects("fp16", "cuda")
verts, faces, attrs, pose, K = p(Image.open("photo.png"), Image.open("mask.png"), seed=42)
pipeline.save_mesh("object.glb", verts, faces, attrs)          # y-up, vertex colours

Or python fp16/pipeline.py photo.png mask.png object.glb --seed 42. The mask is a picture of the same size: any non-zero pixel (or alpha) is the object. It needs numpy, scipy, Pillow and onnxruntime-gpu, plus torch and torchvision on the CPU: the preprocessing and the pose decoding run the original's own code (vendor/). trimesh writes the GLB.

Ported as the original behaves.

  • Point map: MoGeModel.infer at resolution level 9 (2,500 tokens): the same resizes, the focal length and depth shift recovered by the same solver (vendor/moge_min.py, MoGe's code), the points turned into PyTorch3D's camera axes as compute_pointmap does.
  • Preprocessing: the original's crop around the mask, resizes, padding and point-map normalisation (vendor/sam3d_objects, copied from the repository with only the imports edited).
  • Sampler: pipeline.yaml's settings: structure 25 steps with the time rescaled by 3 and guidance 7 while 1000 t <= 500 (the unconditional pass with the condition zeroed); latent 25 steps, no rescale, guidance 1.
  • Voxels and pose: the original's prune_sparse_structure, downsample_sparse_structure and pose_decoder ("ScaleShiftInvariant"), run as they are.
  • Mesh: FlexiCubes in numpy over the candidate cubes only (a port of TRELLIS's FlexiCubes, which SAM 3D uses unchanged): the original builds a dense 256^3 grid, which needs over 10 GB here once a structure has more than about 25 thousand voxels.
  • Noise: a seed draws the latents with torch's CPU generator in the original's order. The original draws on the GPU, so the same seed gives a different (equally valid) sample than the original's.
  • Graph optimization: sessions use the basic level and are loaded one at a time; the CUDA memory arena grows only by what each graph asks for.

Running it.

  • Memory: about 7 GB of system memory at the peak on Windows (GPU allocations count toward it) for the 6720 x 4480 kidsroom photo, whose structure has 26 thousand voxels; about 5 GB for the smaller examples. Graphs are loaded one at a time. The original needed about 10 GB here for that photo's mesh decoding alone.
  • Time: on an RTX 3080 Laptop GPU, 45-50 s per object from the picture with fp16/ or int8/ for the smaller examples (4-6 thousand voxels), 84 s for the kidsroom photo, loading each graph as its stage starts. The structure stage takes 26-30 s; the latent stage and the mesh grow with the voxel count (kidsroom: 28 s and 26 s).

Precisions.

  • fp16/ (6.3 GB): the two flows' matrix products and the decoders in fp16, as the original runs them (it keeps fp32 weights under fp16 autocast); the flows' residual stream, the norms and the convolutions' sums in fp32. MoGe, DINOv2, the condition fusers and the structure decoder stay fp32.
  • int8/ (4.9 GB), experimental: the two flows' MatMuls 8-bit MatMulNBits (block 32; 99.5 % and 93 % of their weights), the rest as fp16/. Below the pass mark on the structure and latent stages (below); end to end its meshes stay close (F-score 0.91-0.97), and its pose rotations are 0.3-0.6 degrees off the original's.
  • No int4: tried (the flows 4-bit) and far below the pass mark (structure SNR 8-16 dB; on the kidsroom it keeps 74 % of the voxels and the pose turns by 5 degrees). No bf16: fp16 passes.

Benchmark.

  • Pictures: three of the official repository's example images (notebook/images) with one of their masks each: human_object (mask 0: the bench, 1600 x 898), the animal at a waterhole (id3_shutterstock_WildAnimal_Waterhole, mask 0) and the stylish kids room (shutterstock_stylish_kidsroom, mask 14, 6720 x 4480); seed 42.
  • Original: InferencePipelinePointMap (GitHub @ f91db41, checkpoints facebook/sam-3d-objects @ 2e73555) run on Windows stage by stage with every intermediate saved: as it runs (fp32 weights under fp16 autocast), spconv, attention through PyTorch SDPA; the mesh from its decoder's features with the same numpy FlexiCubes as here (its dense 256^3 FlexiCubes doesn't fit at 26 thousand voxels).
  • Teacher forced: each stage is fed the original's own inputs (picture, preprocessed inputs, noise, voxels, latent) and scored against the original's output:
    • point map: relative error of the points (where both are finite) and the focal length;
    • structure: SNR of the shape latent, IoU of the voxels, and the pose (translation, rotation, scale);
    • latent: SNR;
    • mesh: F-score at 0.005 on 200k surface samples.
  • Pass mark: each stage at least as close as the original's own fp32 run of that stage, on the same inputs (the mean over the pictures).
point map: rel. error structure: SNR / voxel IoU pose: rotation latent: SNR mesh: F-score end to end: voxel IoU / F-score
original in fp32 (the floor) 0.15 / 0.06 / 0.62 % 57.8 / 32.9 / 40.8 dB, 1.000 / 0.993 / 0.997 0 / 0 / 0 degrees 51.3 / 52.5 / 48.3 dB 1.000 / 1.000 / (0.957) 1.000 / 0.997 / -, 0.970 / 0.997 / -
fp16/ 0.15 / 0.06 / 0.63 % 55.8 / 41.8 / 40.1 dB, 1.000 / 0.998 / 0.997 0 / 0 / 0.04 degrees 51.2 / 52.6 / 48.3 dB 1.000 / 1.000 / 0.957 1.000 / 0.998 / 0.994, 1.000 / 0.996 / 0.928
int8/ (experimental) (as fp16/) 33.0 / 22.6 / 25.9 dB, 0.998 / 0.956 / 0.981 0.36 / 0.31 / 0.63 degrees 33.7 / 33.9 / 32.9 dB (as fp16/) 0.996 / 0.957 / 0.979, 0.932 / 0.972 / 0.907
int4 (not published) (as fp16/) 15.5 / 12.2 / 8.3 dB, 0.902 / 0.756 / 0.739 1.5 / 2.8 / 5.2 degrees 9.4 / 10.5 / 9.0 dB (as fp16/) 0.901 / 0.757 / 0.738, 0.843 / 0.772 / 0.540

Columns are human_object / animal / kidsroom.

  • The kidsroom mesh and end-to-end floors: the original's fp32 mesh decoder doesn't fit in this machine's memory for the kidsroom. Its mesh is large (977 thousand faces), so 200k samples are sparse at the 0.005 tolerance: the original's own mesh scored against itself with another sampling gives 0.957, the score in brackets. fp16/'s mesh has exactly the original's 488,474 vertices.
  • End to end: from the picture and mask, with the original's structure noise (and its latent noise when the voxels come out the same). The floor is the original fully in fp32 from the picture. On human_object fp16/ gives the original's voxels and mesh exactly; on the animal 99.8 % of its voxels.
  • Pose: translation and scale agree to 0.01-0.06 % in every teacher-forced fp16 run (0.1-0.6 % end to end).

Before the benchmark each graph was checked against its PyTorch module on real inputs (cosine): MoGe 0.99999999 (the network's points against the original's fp32 forward); DINOv2 0.999998; the fusers 0.999997-0.999998; the structure flow 0.999999 (against the original's autocast arithmetic); the structure decoder 0.99999999; the latent flow 0.999997; the mesh decoder's four graphs, run in chunks as pipeline.py runs them, 0.99999 against the original decoder on 3,000 voxels.

License. SAM 3D Objects (code and weights) is under the SAM License (LICENSE-SAM.txt): it allows use and redistribution, and anyone redistributing it must pass the licence on with it. The vendored helpers keep their own licences, each next to its code: pytorch3d (BSD), MoGe (MIT; the MoGe-v1 weights Ruicheng/moge-vitl are MIT too), TRELLIS (MIT) and NVIDIA FlexiCubes (Apache-2.0).

How these were made

From SAM 3D Objects at revision 2e73555018. The graphs were exported from the original PyTorch modules with torch.onnx (opset 17 / 18) and checked against them. Weight-only quantization: int8 is a per-output-channel int8 weight behind DequantizeLinear, int4 is ONNX Runtime's MatMulNBits (block 32). Each card above says which precision every graph uses. Every precision was benchmarked against the original before upload (the pass mark is under How to run), and the sha256 column above is what the files must hash to.

License

SAM License (Meta). These files are a derivative of the original model and carry its license: it is copied in this repository, and it governs your use of these files. The original model card follows unchanged.


Original model card

When requesting access (IMPORTANT) : Please be sure to provide your full legal name, date of birth, and full organization name with all corporate identifiers. Avoid the use of acronyms and special characters. Failure to follow these instructions may prevent you from accessing this model and others on Hugging Face. You will not have the ability to edit this form after submission, so please ensure all information is accurate.

SAM 3D

SAM 3D Objects is one part of SAM 3D, a pair of models for object and human mesh reconstruction. If you’re looking for SAM 3D Body, click here.

SAM 3D Objects

SAM 3D Team, Xingyu Chen*, Fu-Jen Chu*, Pierre Gleize*, Kevin J Liang*, Alexander Sax*, Hao Tang*, Weiyao Wang*, Michelle Guo, Thibaut Hardin, Xiang Li⚬, Aohan Lin, Jia-Wei Liu, Ziqi Ma⚬, Anushka Sagar, Bowen Song⚬, Xiaodong Wang, Jianing Yang⚬, Bowen Zhang⚬, Piotr Dollár†, Georgia Gkioxari†, Matt Feiszli†§, Jitendra Malik†§

Meta Superintelligence Labs

*Core contributor (Alphabetical, Equal Contribution), ⚬Intern, †Project leads, §Equal Contribution

[Paper] [Code] [Website] [Demo] [Blog] [BibTeX] [Roboflow]

SAM 3D Objects is a foundation model that reconstructs full 3D shape geometry, texture, and layout from a single image, excelling in real-world scenarios with occlusion and clutter by using progressive training and a data engine with human feedback. It outperforms prior 3D generation models in human preference tests on real-world objects and scenes. We released code, weights, online demo, and a new challenging benchmark.


Latest updates

11/19/2025 - Checkpoints Launched, Web Demo and Paper are out.

Installation

Follow the setup steps before running the following.

Single or Multi-Object 3D Generation

SAM 3D Objects can convert masked objects in an image, into 3D models with pose.

For a quick start, use the the following lines of code:

import sys

# import inference code
sys.path.append("notebook")
from inference import Inference, load_image, load_single_mask

# load model
tag = "hf"
config_path = f"checkpoints/{tag}/pipeline.yaml"
inference = Inference(config_path, compile=False)

# load image (RGBA only, mask is embedded in the alpha channel)
image = load_image("notebook/images/shutterstock_stylish_kidsroom_1640806567/image.png")
mask = load_single_mask("notebook/images/shutterstock_stylish_kidsroom_1640806567", index=14)

# run model
output = inference(image, mask, seed=42)

# export gaussian splat
output["gs"].save_ply(f"splat.ply")

For more details and multi-object reconstruction, please take a look at out two jupyter notebooks:

SAM 3D Body

SAM 3D Body (3DB) is a robust promptable foundation model for single-image 3D human mesh recovery (HMR).

As a way to combine the strengths of both SAM 3D Objects and SAM 3D Body, we provide an example notebook that demonstrates how to combine the results of both models such that they are aligned in the same frame of reference. Check it out here.

License

The SAM 3D Objects model checkpoints and code are licensed under SAM License.

Contributing

See contributing and the code of conduct.

Contributors

The SAM 3D Objects project was made possible with the help of many contributors.

Robbie Adkins, Paris Baptiste, Karen Bergan, Kai Brown, Michelle Chan, Ida Cheng, Khadijat Durojaiye, Patrick Edwards, Daniella Factor, Facundo Figueroa, Rene de la Fuente, Eva Galper, Cem Gokmen, Alex He, Enmanuel Hernandez, Dex Honsa, Leonna Jones, Arpit Kalla, Kris Kitani, Helen Klein, Kei Koyama, Robert Kuo, Vivian Lee, Alex Lende, Jonny Li, Kehan Lyu, Faye Ma, Mallika Malhotra, Sasha Mitts, William Ngan, George Orlin, Peter Park, Don Pinkus, Roman Radle, Nikhila Ravi, Azita Shokrpour, Jasmine Shone, Zayida Suber, Phillip Thomas, Tatum Turner, Joseph Walker, Meng Wang, Claudette Ward, Andrew Westbury, Lea Wilken, Nan Yang, Yael Yungster

Citing SAM 3D Objects

If you use SAM 3D Objects in your research, please use the following BibTeX entry.

@article{sam3dteam2025sam3d3dfyimages,
      title={SAM 3D: 3Dfy Anything in Images}, 
      author={SAM 3D Team and Xingyu Chen and Fu-Jen Chu and Pierre Gleize and Kevin J Liang and Alexander Sax and Hao Tang and Weiyao Wang and Michelle Guo and Thibaut Hardin and Xiang Li and Aohan Lin and Jiawei Liu and Ziqi Ma and Anushka Sagar and Bowen Song and Xiaodong Wang and Jianing Yang and Bowen Zhang and Piotr Dollár and Georgia Gkioxari and Matt Feiszli and Jitendra Malik},
      year={2025},
      eprint={2511.16624},
      archivePrefix={arXiv},
      primaryClass={cs.CV},
      url={https://arxiv.org/abs/2511.16624}, 
}
Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for moonbox-dev/sam-3d-objects-ONNX

Quantized
(1)
this model

Paper for moonbox-dev/sam-3d-objects-ONNX