TRELLIS.2 installation with compatibility patches and documentation. Ubuntu 22.04 Bare-metal build.
1
stars
5
commits
Python
primary language
Dec 19, 2025
updated

https://github.com/user-attachments/assets/63b43a7e-acc7-4c81-a900-6da450527d8f
(Compressed version due to GitHub size limits. See the full-quality video on our project page!)
TRELLIS.2 is a state-of-the-art large 3D generative model (4B parameters) designed for high-fidelity image-to-3D generation. It leverages a novel "field-free" sparse voxel structure termed O-Voxel to reconstruct and generate arbitrary 3D assets with complex topologies, sharp features, and full PBR materials.
Our 4B-parameter model generates high-resolution fully textured assets with exceptional fidelity and efficiency using vanilla DiTs. It utilizes a Sparse 3D VAE with 16× spatial downsampling to encode assets into a compact latent space.
| Resolution | Total Time* | Breakdown (Shape + Mat) |
|---|---|---|
| 512³ | ~3s | 2s + 1s |
| 1024³ | ~17s | 10s + 7s |
| 1536³ | ~60s | 35s + 25s |
*Tested on NVIDIA H100 GPU.
The O-Voxel representation breaks the limits of iso-surface fields. It robustly handles complex structures without lossy conversion:
Beyond basic colors, TRELLIS.2 models arbitrary surface attributes including Base Color, Roughness, Metallic, and Opacity, enabling photorealistic rendering and transparency support.
Data processing is streamlined for instant conversions that are fully rendering-free and optimization-free.
Clone the repo:
git clone -b main https://github.com/microsoft/TRELLIS.2.git --recursive
cd TRELLIS.2
Install the dependencies:
Before running the following command there are somethings to note:
--new-env, a new conda environment named trellis2 will be created. If you want to use an existing conda environment, please remove this flag.trellis2 environment will use pytorch 2.6.0 with CUDA 12.4. If you want to use a different version of CUDA, you can remove the --new-env flag and manually install the required dependencies. Refer to PyTorch for the installation command.CUDA_HOME should be set to the correct version before running the command. For example, if you have CUDA Toolkit 12.4 and 13.0 installed, you can run export CUDA_HOME=/usr/local/cuda-12.4 before running the command.flash-attn backend for attention. For GPUs do not support flash-attn (e.g., NVIDIA V100), you can install xformers manually and set the ATTN_BACKEND environment variable to xformers before running the code. See the Minimal Example for more details.Create a new conda environment named trellis2 and install the dependencies:
. ./setup.sh --new-env --basic --flash-attn --nvdiffrast --nvdiffrec --cumesh --o-voxel --flexgemm
The detailed usage of setup.sh can be found by running . ./setup.sh --help.
Usage: setup.sh [OPTIONS]
Options:
-h, --help Display this help message
--new-env Create a new conda environment
--basic Install basic dependencies
--flash-attn Install flash-attention
--cumesh Install cumesh
--o-voxel Install o-voxel
--flexgemm Install flexgemm
--nvdiffrast Install nvdiffrast
--nvdiffrec Install nvdiffrec
The pretrained model TRELLIS.2-4B is available on Hugging Face. Please refer to the model card there for more details.
| Model | Parameters | Resolution | Link |
|---|---|---|---|
| TRELLIS.2-4B | 4 Billion | 512³ - 1536³ | Hugging Face |
Here is an example of how to use the pretrained models for 3D asset generation.
import os
os.environ['OPENCV_IO_ENABLE_OPENEXR'] = '1'
os.environ["PYTORCH_CUDA_ALLOC_CONF"] = "expandable_segments:True" # Can save GPU memory
import cv2
import imageio
from PIL import Image
import torch
from trellis2.pipelines import Trellis2ImageTo3DPipeline
from trellis2.utils import render_utils
from trellis2.renderers import EnvMap
import o_voxel
# 1. Setup Environment Map
envmap = EnvMap(torch.tensor(
cv2.cvtColor(cv2.imread('assets/hdri/forest.exr', cv2.IMREAD_UNCHANGED), cv2.COLOR_BGR2RGB),
dtype=torch.float32, device='cuda'
))
# 2. Load Pipeline
pipeline = Trellis2ImageTo3DPipeline.from_pretrained("microsoft/TRELLIS.2-4B")
pipeline.cuda()
# 3. Load Image & Run
image = Image.open("assets/example_image/T.png")
mesh = pipeline.run(image)[0]
mesh.simplify(16777216) # nvdiffrast limit
# 4. Render Video
video = render_utils.make_pbr_vis_frames(render_utils.render_video(mesh, envmap=envmap))
imageio.mimsave("sample.mp4", video, fps=15)
# 5. Export to GLB
glb = o_voxel.postprocess.to_glb(
vertices = mesh.vertices,
faces = mesh.faces,
attr_volume = mesh.attrs,
coords = mesh.coords,
attr_layout = mesh.layout,
voxel_size = mesh.voxel_size,
aabb = [[-0.5, -0.5, -0.5], [0.5, 0.5, 0.5]],
decimation_target = 1000000,
texture_size = 4096,
remesh = True,
remesh_band = 1,
remesh_project = 0,
verbose = True
)
glb.export("sample.glb", extension_webp=True)
Upon execution, the script generates the following files:
sample.mp4: A video visualizing the generated 3D asset with PBR materials and environmental lighting.sample.glb: The extracted PBR-ready 3D asset in GLB format.Note: The .glb file is exported in OPAQUE mode by default. Although the alpha channel is preserved within the texture map, it is not active initially. To enable transparency, import the asset into your 3D software and manually connect the texture's alpha channel to the material's opacity or alpha input.
app.py provides a simple web demo for image to 3D asset generation. you can run the demo with the following command:
python app.py
Then, you can access the demo at the address shown in the terminal.
Will be released soon. Please stay tuned!
TRELLIS.2 is built upon several specialized high-performance packages developed by our team:
This model and code are released under the MIT License.
Please note that certain dependencies operate under separate license terms:
nvdiffrast: Utilized for rendering generated 3D assets. This package is governed by its own License.
nvdiffrec: Implements the split-sum renderer for PBR materials. This package is governed by its own License.
If you find this model useful for your research, please cite our work:
@article{
xiang2025trellis2,
title={Native and Compact Structured Latents for 3D Generation},
author={Xiang, Jianfeng and Chen, Xiaoxue and Xu, Sicheng and Wang, Ruicheng and Lv, Zelong and Deng, Yu and Zhu, Hongyuan and Dong, Yue and Zhao, Hao and Yuan, Nicholas Jing and Yang, Jiaolong},
journal={Tech report},
year={2025}
}
4 commits
1 commits
Python
78.3%
C++
14.5%
Cuda
5.7%
TRELLIS.2 installation with compatibility patches and documentation. Ubuntu 22.04 Bare-metal build.
1
stars
5
commits
Python
primary language
Dec 19, 2025
updated

https://github.com/user-attachments/assets/63b43a7e-acc7-4c81-a900-6da450527d8f
(Compressed version due to GitHub size limits. See the full-quality video on our project page!)
TRELLIS.2 is a state-of-the-art large 3D generative model (4B parameters) designed for high-fidelity image-to-3D generation. It leverages a novel "field-free" sparse voxel structure termed O-Voxel to reconstruct and generate arbitrary 3D assets with complex topologies, sharp features, and full PBR materials.
Our 4B-parameter model generates high-resolution fully textured assets with exceptional fidelity and efficiency using vanilla DiTs. It utilizes a Sparse 3D VAE with 16× spatial downsampling to encode assets into a compact latent space.
| Resolution | Total Time* | Breakdown (Shape + Mat) |
|---|---|---|
| 512³ | ~3s | 2s + 1s |
| 1024³ | ~17s | 10s + 7s |
| 1536³ | ~60s | 35s + 25s |
*Tested on NVIDIA H100 GPU.
The O-Voxel representation breaks the limits of iso-surface fields. It robustly handles complex structures without lossy conversion:
Beyond basic colors, TRELLIS.2 models arbitrary surface attributes including Base Color, Roughness, Metallic, and Opacity, enabling photorealistic rendering and transparency support.
Data processing is streamlined for instant conversions that are fully rendering-free and optimization-free.
Clone the repo:
git clone -b main https://github.com/microsoft/TRELLIS.2.git --recursive
cd TRELLIS.2
Install the dependencies:
Before running the following command there are somethings to note:
--new-env, a new conda environment named trellis2 will be created. If you want to use an existing conda environment, please remove this flag.trellis2 environment will use pytorch 2.6.0 with CUDA 12.4. If you want to use a different version of CUDA, you can remove the --new-env flag and manually install the required dependencies. Refer to PyTorch for the installation command.CUDA_HOME should be set to the correct version before running the command. For example, if you have CUDA Toolkit 12.4 and 13.0 installed, you can run export CUDA_HOME=/usr/local/cuda-12.4 before running the command.flash-attn backend for attention. For GPUs do not support flash-attn (e.g., NVIDIA V100), you can install xformers manually and set the ATTN_BACKEND environment variable to xformers before running the code. See the Minimal Example for more details.Create a new conda environment named trellis2 and install the dependencies:
. ./setup.sh --new-env --basic --flash-attn --nvdiffrast --nvdiffrec --cumesh --o-voxel --flexgemm
The detailed usage of setup.sh can be found by running . ./setup.sh --help.
Usage: setup.sh [OPTIONS]
Options:
-h, --help Display this help message
--new-env Create a new conda environment
--basic Install basic dependencies
--flash-attn Install flash-attention
--cumesh Install cumesh
--o-voxel Install o-voxel
--flexgemm Install flexgemm
--nvdiffrast Install nvdiffrast
--nvdiffrec Install nvdiffrec
The pretrained model TRELLIS.2-4B is available on Hugging Face. Please refer to the model card there for more details.
| Model | Parameters | Resolution | Link |
|---|---|---|---|
| TRELLIS.2-4B | 4 Billion | 512³ - 1536³ | Hugging Face |
Here is an example of how to use the pretrained models for 3D asset generation.
import os
os.environ['OPENCV_IO_ENABLE_OPENEXR'] = '1'
os.environ["PYTORCH_CUDA_ALLOC_CONF"] = "expandable_segments:True" # Can save GPU memory
import cv2
import imageio
from PIL import Image
import torch
from trellis2.pipelines import Trellis2ImageTo3DPipeline
from trellis2.utils import render_utils
from trellis2.renderers import EnvMap
import o_voxel
# 1. Setup Environment Map
envmap = EnvMap(torch.tensor(
cv2.cvtColor(cv2.imread('assets/hdri/forest.exr', cv2.IMREAD_UNCHANGED), cv2.COLOR_BGR2RGB),
dtype=torch.float32, device='cuda'
))
# 2. Load Pipeline
pipeline = Trellis2ImageTo3DPipeline.from_pretrained("microsoft/TRELLIS.2-4B")
pipeline.cuda()
# 3. Load Image & Run
image = Image.open("assets/example_image/T.png")
mesh = pipeline.run(image)[0]
mesh.simplify(16777216) # nvdiffrast limit
# 4. Render Video
video = render_utils.make_pbr_vis_frames(render_utils.render_video(mesh, envmap=envmap))
imageio.mimsave("sample.mp4", video, fps=15)
# 5. Export to GLB
glb = o_voxel.postprocess.to_glb(
vertices = mesh.vertices,
faces = mesh.faces,
attr_volume = mesh.attrs,
coords = mesh.coords,
attr_layout = mesh.layout,
voxel_size = mesh.voxel_size,
aabb = [[-0.5, -0.5, -0.5], [0.5, 0.5, 0.5]],
decimation_target = 1000000,
texture_size = 4096,
remesh = True,
remesh_band = 1,
remesh_project = 0,
verbose = True
)
glb.export("sample.glb", extension_webp=True)
Upon execution, the script generates the following files:
sample.mp4: A video visualizing the generated 3D asset with PBR materials and environmental lighting.sample.glb: The extracted PBR-ready 3D asset in GLB format.Note: The .glb file is exported in OPAQUE mode by default. Although the alpha channel is preserved within the texture map, it is not active initially. To enable transparency, import the asset into your 3D software and manually connect the texture's alpha channel to the material's opacity or alpha input.
app.py provides a simple web demo for image to 3D asset generation. you can run the demo with the following command:
python app.py
Then, you can access the demo at the address shown in the terminal.
Will be released soon. Please stay tuned!
TRELLIS.2 is built upon several specialized high-performance packages developed by our team:
This model and code are released under the MIT License.
Please note that certain dependencies operate under separate license terms:
nvdiffrast: Utilized for rendering generated 3D assets. This package is governed by its own License.
nvdiffrec: Implements the split-sum renderer for PBR materials. This package is governed by its own License.
If you find this model useful for your research, please cite our work:
@article{
xiang2025trellis2,
title={Native and Compact Structured Latents for 3D Generation},
author={Xiang, Jianfeng and Chen, Xiaoxue and Xu, Sicheng and Wang, Ruicheng and Lv, Zelong and Deng, Yu and Zhu, Hongyuan and Dong, Yue and Zhao, Hao and Yuan, Nicholas Jing and Yang, Jiaolong},
journal={Tech report},
year={2025}
}
4 commits
1 commits
Python
78.3%
C++
14.5%
Cuda
5.7%