The Definitive Fine-Tuning Guide for 3D Generation Models

本文为原文前 6,000 字符的节选翻译,完整内容请查看原文。

The Definitive Fine-Tuning Guide for 3D Generation Models

Title: The Definitive Fine-Tuning Guide for 3D Generation Models

标题:3D生成模型微调权威指南

TLDR; In this blog, we provide fine-tuning scripts and containers to fine-tune TRELLIS.2, a popular 3D model on your 3D assets, that can run both locally and on Hugging Face Jobs. If you are interested in fine-tuning, you can use our scripts with few arguments (assuming you updated your dataset to Hugging Face Hub) or tinker with them yourself with this repository. If you want to learn more, we go through how the script works. Let’s go!

简而言之,在本篇博客中,我们提供了用于微调 TRELLIS.2(一种流行的 3D 模型)的脚本和容器,支持在本地或 Hugging Face Jobs 上运行。如果您对微调感兴趣,可以使用我们的脚本并传入少量参数(前提是您已将数据集上传至 Hugging Face Hub),或者通过此存储库自行修改。如果您想了解更多信息,我们将详细介绍脚本的工作原理。让我们开始吧!

Introduction: 3D generation has many uses in robotics, simulation, media, and entertainment. In these fields, it is difficult to make generated objects obey strict rules and standardize model and data representations. There are many file formats, such as GLB and PLY. There are also many representations, such as neural radiance fields (NeRFs) and 3D Gaussian splatting (3DGS). Each one has different advantages and disadvantages.

引言:3D 生成在机器人、仿真、媒体和娱乐领域有着广泛的应用。在这些领域中,让生成的对象遵循严格的规则并标准化模型与数据表示非常困难。目前存在许多文件格式,如 GLB 和 PLY;也有许多表示方法,如神经辐射场 (NeRF) 和 3D 高斯溅射 (3DGS)。每种方法都有其优缺点。

TRELLIS introduced a common internal representation, called a unified latent representation. Its decoders convert this representation into 3D models in the required output format. Thus, you do not have to use different models for each representation format. The same team then released TRELLIS.2, which improves the model’s representation of 3D structure. But neither model gives an easy way to adapt it to a specific task.

TRELLIS 引入了一种通用的内部表示,称为统一潜在表示。其解码器可将此表示转换为所需输出格式的 3D 模型。因此,您无需为每种表示格式使用不同的模型。随后,同一团队发布了 TRELLIS.2,改进了模型对 3D 结构的表示能力。但这两个模型都没有提供一种简便的方法来使其适应特定任务。

What we want to improve: A general-purpose model, such as TRELLIS.2, can make errors in details that are important for a specific application. For example, a user may need accurate geometry for furniture models. Without fine-tuning for that task, the pretrained model can produce geometry that is insufficiently accurate. We use a subset of GSO that has 188 footwear objects for our experiment. In our initial tests, the pretrained model usually produced shoes that looked correct, but the soles were incorrect. We test whether a LoRA can make the soles more accurate.

我们想要改进的地方:像 TRELLIS.2 这样的通用模型在特定应用的关键细节上可能会出错。例如,用户可能需要家具模型的精确几何结构。如果不针对该任务进行微调,预训练模型生成的几何结构可能不够准确。我们在实验中使用了包含 188 个鞋类对象的 GSO 子集。在初步测试中,预训练模型生成的鞋子外观通常正确,但鞋底却不准确。我们正在测试 LoRA 是否能使鞋底更加精确。

Our goal is to use the Google Scanned Objects (GSO) dataset to improve the performance of TRELLIS.2 on a specific object category. We will explain which pipeline components to fine-tune and which to leave unchanged during training. The pipeline separates structure, detailed geometry, and materials. Thus, we will fine-tune only the components that are important for our task. Choosing what to freeze matters as much as choosing what to fine-tune.

我们的目标是利用 Google 扫描对象 (GSO) 数据集来提升 TRELLIS.2 在特定对象类别上的性能。我们将解释在训练过程中哪些流水线组件需要微调,哪些应保持不变。该流水线将结构、详细几何结构和材质分离开来。因此,我们仅微调对任务至关重要的组件。选择冻结哪些部分与选择微调哪些部分同样重要。

What will we use? LoRA: LoRA, short for low-rank adaptation, fine-tunes a model by training small adapter matrices while keeping the original weights frozen. This reduces the number of trainable parameters and the memory needed for their gradients and optimizer state. We use Hugging Face’s PEFT library to add and train these adapters. For more information, read our LoRA guide.

我们将使用什么?LoRA:LoRA(低秩自适应的缩写)通过训练小型适配器矩阵并保持原始权重冻结来微调模型。这减少了可训练参数的数量,以及梯度和优化器状态所需的内存。我们使用 Hugging Face 的 PEFT 库来添加和训练这些适配器。欲了解更多信息,请阅读我们的 LoRA 指南。

Hugging Face Jobs: Hugging Face Jobs runs containerized workloads on cloud hardware. We use it for preprocessing and for training. To use your own GPU instead, see the local Docker commands below. Before you start, make sure that you have: A HF_TOKEN that you can obtain from here; Your Hugging Face account must have access to DINOv3, because DINOv3 is a gated model; If you use your own dataset, upload its meshes to the Hub before you start.

Hugging Face Jobs:Hugging Face Jobs 在云端硬件上运行容器化工作负载。我们将其用于预处理和训练。若要改用您自己的 GPU,请参阅下方的本地 Docker 命令。在开始之前,请确保您拥有:一个可从此处获取的 HF_TOKEN;您的 Hugging Face 账户必须拥有访问 DINOv3 的权限,因为 DINOv3 是一个受限模型;如果您使用自己的数据集,请在开始前将其网格上传至 Hub。

How TRELLIS.2 works: Before we train, let’s look at how TRELLIS.2 generates a 3D object and where we’ll add LoRA adapters. TRELLIS.2 has five main stages: remove the image background, encode the image, predict the coarse structure, generate detailed geometry, and generate materials. The pipeline then exports the result as a textured mesh.

TRELLIS.2 的工作原理:在训练之前,让我们看看 TRELLIS.2 是如何生成 3D 对象的,以及我们将在何处添加 LoRA 适配器。TRELLIS.2 有五个主要阶段:去除图像背景、编码图像、预测粗略结构、生成详细几何结构以及生成材质。随后,流水线将结果导出为带纹理的网格。

Encoding the input image: First, BiRefNet removes the background from the input image. DINOv3-L then encodes the image into feature tokens. The generation models use these tokens to guide the 3D object.

编码输入图像:首先,BiRefNet 去除输入图像的背景。接着,DINOv3-L 将图像编码为特征标记。生成模型利用这些标记来引导 3D 对象的生成。

Sparse Structure Generation (Sparse Structure Flow): The sparse-structure flow DiT predicts the object’s coarse shape. It is a diffusion transformer (DiT) that makes a small latent of size 16³ × 8. A variational autoencoder (VAE) decoder then changes this latent into a 64 × 64 × 64 occupancy grid. Each voxel in the grid shows if that location is part of the object. A voxel is a pixel in three dimensions. We add LoRA adapters to this model because its output guides the geometry stage.

稀疏结构生成(稀疏结构流):稀疏结构流 DiT 预测对象的粗略形状。它是一个扩散变换器 (DiT),生成大小为 16³ × 8 的小型潜在表示。随后,变分自编码器 (VAE) 解码器将此潜在表示转换为 64 × 64 × 64 的占用网格。网格中的每个体素都显示该位置是否属于对象的一部分。体素即三维空间中的像素。我们在此模型中添加了 LoRA 适配器,因为其输出会引导几何阶段。

O-Voxel and Structured Latents: O-Voxel is the 3D format of TRELLIS.2. It is a sparse voxel grid. It keeps only the voxels on the object’s surface. Each voxel keeps local geometry, such as a mesh vertex, and material attributes. Because the format is small, a CPU changes a mesh into O-Voxel in seconds. A GPU changes O-Voxel back into a mesh in seconds. Structured sparse latents come from TRELLIS. They keep 3D data in sparse tensors, which makes computation faster. The model uses only approximately 10% of the voxels in the grid, so it does not spend compute on empty voxels. Thus, the shape flow DiT and the texture flow DiT are sparse transformers. The sparse-structure flow DiT is a dense transformer.

O-Voxel 与结构化潜在表示:O-Voxel 是 TRELLIS.2 的 3D 格式,它是一种稀疏体素网格,仅保留对象表面的体素。每个体素都保存局部几何信息(如网格顶点)和材质属性。由于该格式较小,CPU 可在几秒钟内将网格转换为 O-Voxel,GPU 也可在几秒钟内将 O-Voxel 转回网格。结构化稀疏潜在表示源自 TRELLIS,它们以稀疏张量形式保存 3D 数据,从而加快了计算速度。该模型仅使用网格中约 10% 的体素,因此不会在空体素上浪费计算资源。因此,形状流 DiT 和纹理流 DiT 是稀疏变换器,而稀疏结构流 DiT 是密集变换器。

Geometry Generation (Shape Flow): The shape flow DiT uses the occupancy grid and the DINOv3 feature tokens to make a latent. Another VAE decoder then changes this latent into O-Voxel geometry at a resolution of 512 × 512 × 512. We add LoRA adapters to the DiT at this stage because it controls the object’s shape.

几何生成(形状流):形状流 DiT 利用占用网格和 DINOv3 特征标记来生成潜在表示。随后,另一个 VAE 解码器将此潜在表示转换为分辨率为 512 × 512 × 512 的 O-Voxel 几何结构。我们在该阶段的 DiT 中添加了 LoRA 适配器,因为它控制着对象的形状。

Material Generation + Mesh Creation: In the last stage, the texture flow DiT uses the shape latent and the DINOv3 features as input. It defines the materials and textures of the geometry’s surface. A VAE decoder then changes the latent into base color, metallic, roughness, and alpha values for each voxel. We do not add LoRA adapters to this stage. Our dataset has diffuse color maps, but it lacks the separate material maps this stage needs for training. Also, our problem is the shoe’s shape. The base model already makes good colors and textures. Finally, the pipeline combines the geometry and.

材质生成与网格创建:在最后阶段,纹理流 DiT 以形状潜在表示和 DINOv3 特征作为输入,定义几何表面的材质和纹理。VAE 解码器随后将潜在表示转换为每个体素的基础颜色、金属度、粗糙度和 Alpha 值。我们没有在此阶段添加 LoRA 适配器。我们的数据集包含漫反射颜色贴图,但缺乏该阶段训练所需的独立材质贴图。此外,我们要解决的问题是鞋子的形状,而基础模型已经能生成良好的颜色和纹理。最后,流水线将几何结构与……结合起来。