Skip to content

Add Stable Fast 3D example (native MLX single-image-to-3D-mesh) - #1444

Open
bahaehmimdi wants to merge 1 commit into
ml-explore:mainfrom
bahaehmimdi:add-stable-fast-3d
Open

Add Stable Fast 3D example (native MLX single-image-to-3D-mesh)#1444
bahaehmimdi wants to merge 1 commit into
ml-explore:mainfrom
bahaehmimdi:add-stable-fast-3d

Conversation

@bahaehmimdi

Copy link
Copy Markdown

Follow-up to #1443.

Adds a stable_fast_3d/ example: Stable Fast 3D (single-image -> textured 3D mesh), reimplemented natively in MLX. No PyTorch anywhere in the pipeline.

Why

The official PyTorch implementation is slow on Apple Silicon via MPS (~7-9 min/generation on an M1 Pro, full model reload every call, no Mac-specific optimization). This port brings that down to ~12.4s end-to-end (~34-44x faster), with both the neural forward pass and mesh finishing (UV unwrap, texture baking, previously PyTorch/CPU) running in 100% MLX/numpy. See stable_fast_3d/README.md for the full speed table and validation methodology.

⚠️ Licensing — please read before merging

This is the one thing I want explicit maintainer sign-off on. stable_fast_3d/ is a Derivative Work of Stability AI's stable-fast-3d source (module-by-module hand-port, not an independent reimplementation from the paper alone), so it's covered by the Stability AI Community License, which is non-sublicensable. I can't relicense it under this repo's root MIT license per CONTRIBUTING.md.

So this folder carries its own LICENSE (Stability AI Community License text) and a NOTICE.md explaining the exception, exactly as flagged in #1443 before opening this PR. No model weights are redistributed — weights.py downloads and converts the checkpoint from the gated stabilityai/stable-fast-3d HF repo at runtime (same gated-access pattern as the official repo), and downloads one small fixed data file (160_tets.npz, a geometric grid definition, not a trained weight) from the upstream GitHub repo.

If a per-folder license exception isn't something you're willing to carry in this repo, totally understand — happy to close this and just leave the standalone repo linked from #1443 instead.

What's included

  • stable_fast_3d/stable_fast_3d/: camera embedder, DINOv2 tokenizer + AdaLN modulation, two-stream transformer backbone, post-processor, triplane decoder (camera_embedder.py, dinov2.py, backbone.py, post_processor.py, decoder.py, bicubic.py), plus mesh finishing (isosurface.py, uv_unwrap.py, texture_baker.py), tied together in pipeline.py's StableFast3D class.
  • image_to_3d.py: CLI entry point, mirrors the style of other examples here (e.g. stable_diffusion/txt2image.py).
  • Formatted with black + isort --profile=black per CONTRIBUTING.md.

Testing

Ran the actual package end-to-end (not just reviewed the diff): loaded the real checkpoint, generated a mesh from a test image, produced a valid textured GLB (11,422 verts / 17,520 faces) in 9.9s on an M1 Pro. Each neural module was separately validated against the original PyTorch model's intermediate tensors to float32 tolerance during development (max-abs-diff < 1e-4 throughout) — full validation scripts and history in the standalone repo linked in NOTICE.md, kept out of this PR to keep it focused on the example itself.

Related: standalone development repo at https://github.com/bahaehmimdi/stable-fast-3d-mlx, upstream issue at Stability-AI/stable-fast-3d#89.

Native MLX port of Stability AI's stable-fast-3d: camera embedder, DINOv2
tokenizer with AdaLN modulation, two-stream transformer backbone,
post-processor, and triplane decoder, plus MLX/numpy mesh finishing
(marching-tetrahedra isosurface, UV unwrap, texture baking). No PyTorch.

Weights and the fixed tetrahedra grid are fetched at runtime (from Hugging
Face and the upstream repo respectively), not redistributed here.

Note: this folder carries its own LICENSE (Stability AI Community License)
as an explicit exception to the repo-wide MIT default, per NOTICE.md,
since the underlying model's license is non-sublicensable. Flagged in the
tracking issue (ml-explore#1443) before this PR for maintainer visibility.

Validated end-to-end against a live run: ~9.9s neural pass + mesh
finishing on an M1 Pro, producing a valid textured GLB (11422 verts,
17520 faces) from a test image.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant