> ## Documentation Index
> Fetch the complete documentation index at: https://docs.comfy.org/llms.txt
> Use this file to discover all available pages before exploring further.

# TRELLIS.2 图像到模型 ComfyUI 工作流示例

> 使用 TRELLIS.2（微软的开源 4B 参数图像到 3D 模型），从单个图像生成具有完整 PBR 纹理的高保真 3D 模型。

**TRELLIS.2** 是微软研究院推出的开源图生3D模型，也是 TRELLIS 的继任者。它是一个 4B 参数模型，基于原生3D VAE 构建，具有 16× 空间压缩，并采用名为 O-Voxel 的稀疏体素表示，可从单张图像生成带有完整 PBR 材质的精细3D资产。

TRELLIS.2 与 Pixal3D 共享基础架构：两者使用相同的 DINOv3 图像编码器、相同的形状和纹理 VAE，以及相同的结构、形状和纹理生成阶段。只有主要的扩散模型和条件格式有所不同。如果你已经运行过 [Pixal3D 工作流](/zh/tutorials/3d/pixal3d)，模型设置几乎完全相同。

<h3 id="trellis2">
  TRELLIS.2：图像到模型
</h3>

上传单张图像。使用 TRELLIS.2 生成带有完整 PBR 纹理的高保真3D模型。

该工作流同时包含 Pixal3D 管线。要运行 TRELLIS.2,将 `Boolean (Switch to Trellis2)` 节点设为 `true`,工作流会自动切换到 TRELLIS.2 模型和条件。

<img src="https://raw.githubusercontent.com/Comfy-Org/workflow_templates/main/templates/3d_pixal3d_trellis2_image_to_model-1.webp" alt="TRELLIS.2 工作流预览" />

<Tip>
  <Tabs>
    <Tab title="本地用户">
      请确保你的 ComfyUI 已经更新。

      * [ComfyUI 下载](https://www.comfy.org/download)
      * [ComfyUI 更新教程](/zh/installation/update_comfyui)

      本指南里的工作流可以在[工作流模板](/zh/interface/features/template)中找到。如果找不到，可能是 ComfyUI 没有更新。

      如果加载工作流时有节点缺失，可能原因有：

      1. 你用的不是最新版（每夜版）。
      2. 启动时有些节点导入失败。
    </Tab>

    <Tab title="云端用户">
      * [Cloud](https://cloud.comfy.org) 会在 ComfyUI 稳定版本发布后更新。

      所以，如果你发现本文档中有任何核心节点缺失，可能是因为新核心节点尚未在最新稳定版中发布。请等待下一个稳定版发布。
    </Tab>
  </Tabs>
</Tip>

<CardGroup cols={2}>
  <Card title="在 Comfy Cloud 上运行" icon="cloud" href="https://cloud.comfy.org/?template=3d_pixal3d_trellis2_image_to_model&utm_source=docs&utm_medium=referral&utm_campaign=trellis2">
    立即在 Comfy Cloud 上运行此工作流
  </Card>

  <Card title="下载工作流" icon="download" href="https://github.com/Comfy-Org/workflow_templates/blob/main/templates/3d_pixal3d_trellis2_image_to_model.json">
    下载 JSON，或在模板库中搜索“Pixal3D & TRELLIS.2: Image to Model”
  </Card>
</CardGroup>

**输入素材**

将此文件上传到 `LoadImage` 节点：

<CardGroup cols={1}>
  <Card title="viking_wolf_rune_axe.png" icon="image" href="https://raw.githubusercontent.com/Comfy-Org/workflow_templates/main/input/viking_wolf_rune_axe.png">
    `LoadImage` 节点 122 · `viking_wolf_rune_axe.png`
  </Card>
</CardGroup>

<div style={{display: 'grid', gridTemplateColumns: 'repeat(2, minmax(0, 1fr))', gap: '1rem', alignItems: 'start'}}>
  <img src="https://raw.githubusercontent.com/Comfy-Org/workflow_templates/main/input/viking_wolf_rune_axe.png" alt="输入图像" style={{width: '100%', height: 'auto', objectFit: 'contain'}} />
</div>

## 工作原理

TRELLIS.2 通过三个扩散阶段生成 3D 资产,然后运行完整的网格后处理管线:

1. **背景移除**: BiRefNet 移除输入图像的背景,工作流将主体裁剪到居中的 1024×1024 画布。可通过开关跳过背景移除
2. **切换到 TRELLIS.2 管线**:将 `Boolean (Switch to Trellis2)` 设为 `true`,工作流会自动加载 TRELLIS.2 模型
3. **结构生成**: 采样稀疏结构潜变量,解码为体素,再转换为粗略网格
4. **形状细化**: 形状阶段和上采样阶段将网格细化到目标分辨率(1536)
5. **纹理生成**: 纹理扩散阶段生成 PBR 材质体素(基色、金属度、粗糙度)
6. **后处理**: DC 网格重建、QEM 减面、UV 展开,以及将基色、法线和环境光遮蔽贴图烘焙到最终带纹理的网格

## 运行步骤

1. **加载图像**：使用 `LoadImage` 节点加载对象的单个图像
2. **将工作流加入队列**：按 Ctrl（macOS 上为 Cmd）+ Enter
3. **等待工作流执行**：结构、形状和纹理阶段依次运行，随后进行后处理
4. **查看结果**：在 `Preview3DAdvanced` 节点中检查网格。GLB 文件将保存到 `ComfyUI/output/3d/ComfyUI/`

## 模型下载

下载此工作流使用的模型。两个扩散模型都需要:开关会决定运行哪一个。放到对应的 `models/` 子目录中。

<CardGroup cols={2}>
  <Card title="TRELLIS.2 UNet 模型" icon="download" href="https://huggingface.co/Comfy-Org/TRELLIS.2/blob/main/diffusion_models/trellis_2_int8_convrot.safetensors">
    trellis\_2\_int8\_convrot.safetensors: TRELLIS.2 扩散模型(开关设为 `true` 时加载)
  </Card>

  <Card title="Pixal3D UNet 模型" icon="download" href="https://huggingface.co/Comfy-Org/Pixal3D/blob/main/diffusion_models/pixal3d_int8_convrot.safetensors">
    pixal3d\_int8\_convrot.safetensors: Pixal3D 扩散模型(默认加载)
  </Card>

  <Card title="形状 VAE" icon="download" href="https://huggingface.co/Comfy-Org/TRELLIS.2/blob/main/vae/trellis_2_shape_vae_bf16.safetensors">
    trellis\_2\_shape\_vae\_bf16.safetensors: 用于结构和形状解码的 VAE
  </Card>

  <Card title="纹理 VAE" icon="download" href="https://huggingface.co/Comfy-Org/TRELLIS.2/blob/main/vae/trellis_2_texture_vae_bf16.safetensors">
    trellis\_2\_texture\_vae\_bf16.safetensors: 用于纹理解码的 VAE
  </Card>

  <Card title="DINOv3 CLIP 视觉编码器" icon="download" href="https://huggingface.co/Comfy-Org/Pixal3D/blob/main/clip_vision/dino_v3_L_naf_fp32.safetensors">
    dino\_v3\_L\_naf\_fp32.safetensors: 用于图像条件的 CLIP 视觉编码器。TRELLIS.2 仓库中等价的 dino\_v3\_vit\_l.safetensors 同样可用
  </Card>

  <Card title="BiRefNet 背景移除" icon="download" href="https://huggingface.co/Comfy-Org/BiRefNet/blob/main/background_removal/birefnet.safetensors">
    birefnet.safetensors: 用于预处理的背景移除模型
  </Card>
</CardGroup>

### 模型存储位置

```
📂 ComfyUI/
├── 📂 models/
│   ├── 📂 diffusion_models/
│   │      ├── pixal3d_int8_convrot.safetensors
│   │      └── trellis_2_int8_convrot.safetensors
│   ├── 📂 vae/
│   │      ├── trellis_2_shape_vae_bf16.safetensors
│   │      └── trellis_2_texture_vae_bf16.safetensors
│   ├── 📂 clip_vision/
│   │      └── dino_v3_L_naf_fp32.safetensors
│   └── 📂 background_removal/
│          └── birefnet.safetensors
```
