Extensions/ComfyUI-VecShape
ComfyUI Extension

ComfyUI-VecShape

ComfyUI nodes for VecShape: single-image 3D mesh generation.

By visualbruno·Created 2 days ago·Updated 2 days ago· 1
visualbruno/ComfyUI-VecShape
Nodes—
On cloudLocal install
Stars1
Updated2 days ago
Readme

ComfyUI-VecShape

ComfyUI nodes for VecShape, which generates an untextured 3D mesh from a single image.

The meshes use ComfyUI's native MESH type, so they connect directly to core nodes such as Save 3D Model (SaveGLB, with an in-browser 3D preview), Decimate Mesh, Unwrap Mesh, Fill Holes and the texture-baking nodes.

Requirements

  • An NVIDIA GPU with FlashAttention 2 support. Peak VRAM is about 9 GB at the default settings.
  • About 10 GB of free system RAM. The DiT is loaded in FP16 (~7.5 GB), and the shape decoder takes ~2.4 GB.
  • flash-attn 2.x installed in the ComfyUI Python environment. On Windows, install a prebuilt wheel that matches your Python, torch and CUDA versions.
pip install -r requirements.txt

Models

Load VecShape Model lists the Hugging Face repository (wushuang98/VecShape). The repository's files go directly in ComfyUI/models/vecshape/ (model_index.json, dit/, vae_decoder/, …). The node uses them if they're already there. Otherwise it downloads the repository into that folder (~17 GB) the first time it runs, and an interrupted download resumes on the next run. Paths from extra_model_paths.yaml under the vecshape key are also checked, and new downloads go to the first one.

DINOv2-large (facebook/dinov2-large) and BiRefNet (ZhengPeng7/BiRefNet) download into the Hugging Face cache on first use. After that, they load from the cache without contacting the Hub.

Nodes

| Node | Purpose | | --- | --- | | Load VecShape Model | Loads the DiT and shape decoder, downloading them to models/vecshape/ if they're missing. Weights stay in system RAM, and each phase moves to the GPU only while it runs. | | VecShape Image to Mesh | Image (+ optional mask) → MESH, plus the conditioning_image the model actually saw. Each image in a batch produces one mesh (seed + i). | | VecShape Remove Background | Runs the BiRefNet segmentation that VecShape uses internally and outputs image + mask. Use it to inspect or edit the mask. |

Image to Mesh parameters

  • steps: 50 by default. 25 is roughly twice as fast with modest quality loss. Very low values (around 8) can produce incomplete shapes.
  • guidance_scale: classifier-free guidance. The default is 5.0, and 0 disables CFG.
  • num_latents: the number of shape tokens. The model was configured for 4096.
  • resolution: the surface-extraction grid. 512 is the model default. 1024 gives finer detail, but marching cubes needs several GB of RAM and the mesh is very dense.
  • target_faces: 0 keeps the full mesh, which is about 1.5–3M faces at 512. Any other value simplifies the mesh with pyfqmr and must be at least 10000.
  • fix_normals: flips the triangle winding when the mesh's signed volume is negative. The upstream pipeline's output is inside-out (its normals point inward), so leave this on unless you need the raw output.
  • mask: an optional foreground mask where white is the object. Without a mask, the node runs BiRefNet on the image. The MASK output of Load Image is inverted alpha, so pass it through Invert Mask before connecting it here.

The example workflow is in example_workflows/vecshape_image_to_mesh.json.

Notes

  • Without a mask, upstream VecShape conditions on an image with red and blue swapped. Its code keeps this deliberately ("kept the segmenter's RGB channel order") for parity with the original inference. The node reproduces this behaviour, and conditioning_image shows it. With a mask or an RGBA input, the colors are correct. The channel order affects the DINOv2 features, not the output's color, because the mesh is untextured.
  • The vecshape/ folder is vendored from the VecShape repository (commit d92b1cb) with two changes:
    • models/checkpoint.py streams the DiT weights and casts Linear layers to FP16 one tensor at a time, which halves peak RAM during loading.
    • schedulers/velocity_prediction_sampler.py accepts a per-step callback, which drives the ComfyUI progress bar and lets you cancel a run.

License

VecShape code is under the MIT license. The adapted FlashVDM portions keep the Tencent Hunyuan FlashVDM Community License. See LICENSE and NOTICE.