TripoSG ONNX

ONNX builds of TripoSG, 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/image_encoder.onnx 609.2 MB d5118332f5e0 F-score@0.01 vs the original's mesh: mean 0.955, worst 0.927 (original bf16 vs fp16: 0.892 / 0.721); 161 s per mesh (CUDA; original 66 s)
fp16 fp16/pipeline.py 8.9 kB a6868c05ec6b F-score@0.01 vs the original's mesh: mean 0.955, worst 0.927 (original bf16 vs fp16: 0.892 / 0.721); 161 s per mesh (CUDA; original 66 s)
fp16 fp16/transformer.onnx 0.9 MB 973a888cd66d F-score@0.01 vs the original's mesh: mean 0.955, worst 0.927 (original bf16 vs fp16: 0.892 / 0.721); 161 s per mesh (CUDA; original 66 s)
fp16 fp16/transformer.onnx.data 2.88 GB 6f00e3964291 F-score@0.01 vs the original's mesh: mean 0.955, worst 0.927 (original bf16 vs fp16: 0.892 / 0.721); 161 s per mesh (CUDA; original 66 s)
fp16 fp16/vae_query.onnx 25.3 MB f19c0eee94b9 F-score@0.01 vs the original's mesh: mean 0.955, worst 0.927 (original bf16 vs fp16: 0.892 / 0.721); 161 s per mesh (CUDA; original 66 s)
fp16 fp16/vae_tokens.onnx 403.3 MB a082aae733d4 F-score@0.01 vs the original's mesh: mean 0.955, worst 0.927 (original bf16 vs fp16: 0.892 / 0.721); 161 s per mesh (CUDA; original 66 s)
int8 int8/image_encoder.onnx 311.3 MB 96a437dc2f35 below threshold (experimental): transformer 8-bit: mean 0.841, worst 0.540; 163 s per mesh (CUDA)
int8 int8/pipeline.py 8.9 kB a6868c05ec6b below threshold (experimental): transformer 8-bit: mean 0.841, worst 0.540; 163 s per mesh (CUDA)
int8 int8/transformer.onnx 1.0 MB aefa74a487c8 below threshold (experimental): transformer 8-bit: mean 0.841, worst 0.540; 163 s per mesh (CUDA)
int8 int8/transformer.onnx.data 1.56 GB 8f1494d1dc78 below threshold (experimental): transformer 8-bit: mean 0.841, worst 0.540; 163 s per mesh (CUDA)
int8 int8/vae_query.onnx 25.3 MB f19c0eee94b9 below threshold (experimental): transformer 8-bit: mean 0.841, worst 0.540; 163 s per mesh (CUDA)
int8 int8/vae_tokens.onnx 203.0 MB d15d71fe54f8 below threshold (experimental): transformer 8-bit: mean 0.841, worst 0.540; 163 s per mesh (CUDA)
int4 int4/image_encoder.onnx 311.3 MB 96a437dc2f35 below threshold (experimental): transformer 4-bit: mean 0.554, worst 0.397; 165 s per mesh (CUDA)
int4 int4/pipeline.py 8.9 kB a6868c05ec6b below threshold (experimental): transformer 4-bit: mean 0.554, worst 0.397; 165 s per mesh (CUDA)
int4 int4/transformer.onnx 1.0 MB 46fed9ae739d below threshold (experimental): transformer 4-bit: mean 0.554, worst 0.397; 165 s per mesh (CUDA)
int4 int4/transformer.onnx.data 858.9 MB 31be31282554 below threshold (experimental): transformer 4-bit: mean 0.554, worst 0.397; 165 s per mesh (CUDA)
int4 int4/vae_query.onnx 25.3 MB f19c0eee94b9 below threshold (experimental): transformer 4-bit: mean 0.554, worst 0.397; 165 s per mesh (CUDA)
int4 int4/vae_tokens.onnx 203.0 MB d15d71fe54f8 below threshold (experimental): transformer 4-bit: mean 0.554, worst 0.397; 165 s per mesh (CUDA)

How to run

TripoSG (VAST-AI: one image to a 3D mesh, a 1.5B rectified-flow transformer over a shape VAE's latents) as four ONNX graphs plus pipeline.py, a numpy runtime that reproduces the repository around them: prepare_image, TripoSGPipeline and hierarchical_extract_geometry.

  • image_encoder.onnx: DINOv2-L, pixel_values [1, 3, 224, 224] -> image_embeds [1, 257, 1024].
  • transformer.onnx: latents [B, 2048, 64], timestep [B], image_embeds [B, 257, 1024] -> velocity [B, 2048, 64]. B = 2 with classifier-free guidance; the unconditional row gets all-zero image embeddings.
  • vae_tokens.onnx: latents [1, 2048, 64] -> tokens [1, 2048, 1024], the VAE decoder's 16 self-attention blocks. It runs once per shape.
  • vae_query.onnx: points [1, M, 3], tokens -> occupancy logits [1, M, 1] (> 0 inside), for any points in [-1.005, 1.005]^3.

pipeline.py does the rest in numpy:

  • Input: an RGBA picture with the object matted (transparent background). The repository's script removes backgrounds with BRIA RMBG-1.4, a separately licensed model that is not included; any matting model works. The picture is composited on white, cropped to the alpha's bounding box and padded to a square with a 10 % margin.
  • Image features: DINOv2's resize (shortest edge 256, bicubic), centre crop to 224, ImageNet mean / std.
  • Sampling: 50 Euler steps of the rectified flow (sigma 1 -> 0) with guidance 7.
  • Mesh: occupancy on a 256^3 grid, re-queried at 512^3 in a band around the surface, then marching cubes, as the repository's hierarchical extraction does (including its float16 grid arithmetic).

It needs numpy, scipy, scikit-image, onnxruntime (or onnxruntime-gpu) and Pillow. trimesh saves the mesh. OpenCV (optional) downsizes inputs over 2000 px exactly as the original; Pillow's filter is used otherwise and differs slightly at edges.

import sys
from PIL import Image
sys.path.insert(0, "fp16")
import pipeline, trimesh
tg = pipeline.TripoSG("fp16", "cuda")
v, f = tg(Image.open("object_rgba.png"), steps=50, seed=42)
trimesh.Trimesh(v, f).export("object.glb")

The repository's default "flash" mesh decoder needs a CUDA extension (diso) and isn't ported. This runtime uses its other extraction path, the hierarchical one. Noise comes from numpy's generator, so a given seed doesn't reproduce the PyTorch pipeline's shape; pass noise= to supply your own. On Windows, give CUDA sessions the run option memory.enable_memory_arena_shrinkage = gpu:0, as pipeline.py does.

Precisions.

  • fp16/: every graph fp16. The transformer was exported from the float16 model, as the original runs; the other graphs do fp16 math with fp32 inputs / outputs.
  • int8/: the transformer's matmuls 8-bit MatMulNBits (block 32); the image encoder and vae_tokens weight-only int8. vae_query stays fp16: it is small and is called hundreds of times per mesh.
  • int4/: the transformer 4-bit, the rest as int8/.
  • No bf16: fp16 passes.

Benchmark.

  • Inputs: the repository's 8 example pictures, matted with BEN2 (MIT), so both sides take the alpha path and no background model is inside the comparison.
  • Settings: seed 42, 50 steps, guidance 7, the same starting noise and the same extraction for both sides.
  • Original: TripoSGPipeline in float16 on CUDA, as the repository's script runs it.
  • Score: F-score at 0.01 between each mesh and the original's, on 200k surface samples (the shapes span about 2 units). It is the share of each surface within 0.01 of the other, harmonic mean of both directions.
  • Pass mark: at least as close as the original's own bfloat16 run (same noise) is to its float16 run: mean 0.892. The float32 original doesn't fit this machine's memory.
  • Timing: seconds per mesh, RTX 3080 Laptop GPU (16 GB), whole pipeline.
F-score vs the original: mean worst of 8 seconds per mesh
original (PyTorch fp16, CUDA) - - 66
original in bf16 (PyTorch, CUDA) 0.892 0.721 66
fp16/ (CUDA) 0.955 0.927 161
int8/ (CUDA), below the pass mark: experimental 0.841 0.540 163
int4/ (CUDA), below the pass mark: experimental 0.554 0.397 165

In renders, every build gives the same object in the same pose. int8's lowest score is on the small bear figure, where the original's own bf16 run also scores lowest. int4 loses fine detail and shifts proportions slightly. The ONNX runtime is about 2.5 times slower than the original, because mesh extraction runs in numpy on the CPU (the original extracts on the GPU).

Before the benchmark, each graph was checked against the original modules (largest absolute difference).

  • Image encoder: 5e-5 of 15 (float32).
  • Transformer: 0.019 of 4.0 (float16 against the float16 model).
  • vae_tokens: 1.2e-3 of 248 (float32).
  • vae_query: 1.5e-4 of 11.7 (float32; the wrapper is identical to the VAE's own decode).

How these were made

From TripoSG at revision 2c1c516d22. 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

MIT. 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

TripoSG - High-Fidelity 3D Shape Synthesis using Large-Scale Rectified Flow Models

TripoSG is a state-of-the-art image-to-3D generation foundation model that leverages large-scale rectified flow transformers to produce high-fidelity 3D shapes from single images.

Model Description

Model Architecture

TripoSG utilizes a novel architecture combining:

  • Rectified Flow (RF) based Transformer for stable, linear trajectory modeling
  • Advanced VAE with SDF-based representation and hybrid geometric supervision
  • Cross-attention mechanism for image feature condition
  • 1.5B parameters operating on 2048 latent tokens

Intended Uses

This model is designed for:

  • Converting single images to high-quality 3D meshes
  • Creative and design applications
  • Gaming and VFX asset creation
  • Prototyping and visualization

Requirements

  • CUDA-capable GPU (>8GB VRAM)

Usage

For detailed usage instructions, please visit our GitHub repository.

About

TripoSG is developed by Tripo, VAST AI Research, pushing the boundaries of 3D Generative AI. For more information:

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/TripoSG-ONNX

Base model

VAST-AI/TripoSG
Quantized
(4)
this model

Paper for moonbox-dev/TripoSG-ONNX