TLDR;在本文中,我们提供了微调脚本和容器,用于在您的 3D 资产上微调 TRELLIS.2(一个流行的 3D 模型),该方案既可在本地运行,也可在 Hugging Face Jobs 上运行。如果您对微调感兴趣,您可以使用我们的脚本并只需调整少量参数(假设您已将数据集更新到 Hugging Face Hub),或者自行通过此仓库进行调试。如果您想了解更多,我们将详细介绍脚本的工作原理。让我们开始吧!
简介
3D 生成在机器人技术、模拟、媒体和娱乐等领域有着广泛的用途。在这些领域中,使生成的对象遵守严格规则并标准化模型和数据表示是非常困难的。存在多种文件格式,例如 GLB 和 PLY 。此外,还有多种表示方法,例如神经辐射场(NeRFs)和 3D 高斯溅射(3DGS)。每种方法都有其各自的优缺点。
TRELLIS 引入了一种通用的内部表示,称为统一潜在表示(unified latent representation)。其解码器将此表示转换为所需输出格式的 3D 模型。因此,您无需为每种表示格式使用不同的模型。
随后,同一团队发布了 TRELLIS.2,该版本改进了模型对 3D 结构的表示能力。但是,这两个模型都没有提供将其适应特定任务的简便方法。
我们要改进什么
通用模型(如 TRELLIS.2)可能会在特定应用中重要的细节上出现错误。例如,用户可能需要家具模型的精确几何结构。如果没有针对该任务进行微调,预训练模型生成的几何结构可能精度不足。我们在实验中使用了包含 188 个鞋类对象的 GSO 子集。在初步测试中,预训练模型通常生成的鞋子看起来是正确的,但鞋底部分不正确。我们测试 LoRA 是否能使鞋底更加准确。
我们的目标是利用 Google Scanned Objects (GSO) 数据集来提高 TRELLIS.2 在特定对象类别上的性能。我们将解释在训练期间应微调哪些流水线组件,以及应保持不变的组件。该流水线将结构、详细几何结构和材质分离开来。因此,我们仅微调对我们任务重要的组件。
选择冻结哪些部分与选择微调哪些部分同样重要。
我们将使用什么?
LoRA
LoRA(低秩自适应)通过训练小型适配器矩阵来微调模型,同时保持原始权重冻结。这减少了可训练参数的数量以及用于梯度和优化器状态的内存需求。我们使用 Hugging Face 的 PEFT 库来添加和训练这些适配器。更多信息,请参阅我们的 LoRA 指南 。
Hugging Face Jobs
Hugging Face Jobs 在云端硬件上运行容器化工作负载。我们将其用于预处理和训练。若要改用您自己的 GPU,请参阅下面的本地 Docker 命令。在开始之前,请确保您具备:
一个 HF_TOKEN,您可以从这里获取
您的 Hugging Face 账户必须有权访问 DINOv3 ,因为 DINOv3 是一个受限访问模型
如果您使用自己的数据集,请在开始前将其网格上传到 Hub。
TRELLIS.2 的工作原理
在训练之前,让我们看看 TRELLIS.2 如何生成 3D 对象,以及我们将在哪里添加 LoRA 适配器。
TRELLIS.2 有五个主要阶段:去除图像背景、编码图像、预测粗略结构、生成详细几何结构和生成材质。随后,流水线将结果导出为带纹理的网格(textured mesh)。
编码输入图像
首先,BiRefNet 从输入图像中去除背景。然后,DINOv3-L 将图像编码为特征标记(feature tokens)。生成模型使用这些标记来引导 3D 对象的生成。
稀疏结构生成(Sparse Structure Flow)
稀疏结构流 DiT 预测物体的粗略形状。它是一种扩散变换器(DiT),生成一个尺寸为 16³ × 8 的小潜变量。随后,变分自编码器(VAE)解码器将该潜变量转换为 64 × 64 × 64 的占据网格。网格中的每个体素表示该位置是否属于物体的一部分。体素是三维空间中的像素。由于该模型的输出指导了几何阶段,我们向其中添加了 LoRA 适配器。
O-Voxel 与结构化潜变量
O-Voxel 是 TRELLIS.2 的 3D 格式。它是一种稀疏体素网格,仅保留物体表面上的体素。每个体素保留局部几何信息(如网格顶点)和材质属性。由于该格式体积小巧,CPU 可在数秒内将网格转换为 O-Voxel,而 GPU 也可在数秒内将 O-Voxel 还原为网格。
结构化稀疏潜变量源自 TRELLIS。它们将 3D 数据存储在稀疏张量中,从而加快计算速度。该模型仅使用网格中约 10% 的体素,因此不会在空体素上浪费计算资源。因此,形状流 DiT 和纹理流 DiT 均为稀疏变换器。而稀疏结构流 DiT 则是密集变换器。
几何生成(形状流)
形状流 DiT 利用占据网格和 DINOv3 特征令牌生成潜变量。另一个 VAE 解码器随后将该潜变量转换为分辨率为 512 × 512 × 512 的 O-Voxel 几何结构。
在此阶段,我们向 DiT 添加 LoRA 适配器,因为它控制着物体的形状。
材质生成与网格创建
在最后阶段,纹理流 DiT 以形状潜变量和 DINOv3 特征作为输入。它定义了表面几何体的材质和纹理。随后,VAE 解码器将潜变量转换为每个体素的基色、金属度、粗糙度和透明度值。我们未向此阶段添加 LoRA 适配器。我们的数据集包含漫反射颜色贴图,但缺乏该训练阶段所需的独立材质贴图。此外,我们的问题核心在于鞋子的形状。基础模型已经能生成良好的颜色和纹理。
最后,该流程将几何属性与材质属性结合,生成带纹理的网格,并将其导出为 GLB 文件。
规划
微调哪些组件
我们仅向稀疏结构流 DiT 和形状流 DiT 添加 LoRA 适配器。这些 DiT 控制着物体的形状和几何结构。我们冻结纹理流 DiT,以保持其现有能力。
我们的数据集包含包含烘焙光照效果的漫反射颜色贴图。要训练纹理流 DiT,我们需要独立的材质贴图。数据集中的颜色贴图将表面颜色与光照混合在一起,因此它们不是此训练的合适目标。
如果在这些贴图上训练纹理流 DiT,它可能会学会将光照显示为表面属性。它还可能会遗忘之前学到的知识,即出现灾难性遗忘问题。
为何使用 LoRA
我们的子集包含 GSO 中 1,030 个物体中的 188 双鞋子。对于如此小的数据集,LoRA 是比全量微调更好的选择。全量微调成本高昂得多,而且可能会覆盖模型已经表现良好的部分(即其学习到的先验知识)。我们的配置为两个目标 DiT 总共训练约 930 万个适配器参数。我们在稀疏结构流 DiT 的注意力层和前馈(MLP)层中使用秩为 8 的适配器。在形状流 DiT 的注意力层中,我们使用秩为 16 的适配器。秩决定了适配器矩阵的大小。更高的秩允许适配器学习更多内容。
你将运行什么
3D 模型设置可能需要许多依赖项和安装步骤。我们提供两个 Docker 镜像(你可以在 Jobs 或自己的机器上运行),其中包含必要的软件。一个用于预处理,另一个用于微调。
要训练你的 LoRA 适配器并将其上传至 Hub:
让容器访问你的数据。
设置任务参数。
运行预处理容器。
运行微调容器。
接下来,我们将解释微调脚本、其设置以及每个设置如何影响训练过程。
实验概述
我们将分三个部分介绍该实验:
准备数据。将 GLB 或 OBJ 网格转换为 TRELLIS.2 训练所使用的潜在表示,并渲染输入图像。
训练适配器。为每个 DiT 运行一个作业,使用准备好的数据集和 LoRA 配置。
解释代码。检查容器如何加载数据、添加适配器以及训练模型。
我们保存预处理后的数据集,以便所有训练任务都能重复使用它。
逐步指南
在 Hugging Face Jobs 上运行
预处理
预处理容器使用 Blender 渲染每个物体的 16 个视角。LoRA 训练将使用这些视角作为条件图像。Blender 通过 xvfb-run 工具在无显示器的情况下运行。该容器还通过预处理管道处理每个物体。请参阅此处的鞋类数据集示例以查看中间输出。对于我们的 188 个物体,整个运行在 a100-large 作业上耗时约 1 小时。预处理管道的精简版本也可在此配套仓库中获得。
export HF_TOKEN=hf_xxx
hf jobs run -d --flavor a100-large -- timeout 6h --secrets HF_TOKEN \
cr.hf.co/suvadityamuk/trellis2-finetuning-prep:latest \
trellis2-prep \
--meshes your-username/my-meshes \
--push-to your-username/my-meshes-trellis2 \
--private --holdout 0.05 \
--views 16 --workers 8
对于 Hugging Face Jobs,我们传递以下参数:
标志
含义
-d
分离模式:打印作业 ID 和 URL,然后返回。若要跟踪作业,请运行 hf jobs logs -f
--flavor a100-large
硬件配置。我们使用 a100-large(80 GB)。要查看所有选项,请运行 hf jobs hardware
--timeout 6h
作业在此时间后停止。两个命令均可恢复。预处理会跳过已完成的物体。训练将从 --push-to 中的最新检查点继续
--secrets HF_TOKEN
将你的令牌(来自 HF_TOKEN 或 hf auth login)作为加密的环境变量发送给作业。令牌不会写入镜像
cr.hf.co/...:latest
要运行的镜像。其后的所有文本均为在容器中运行的命令
此容器接受更多参数(无论是在 Hugging Face Jobs 上运行还是使用 Docker),你可以在这里找到相关文档。预处理管道中执行的步骤将在后文这一部分中记录。
LoRA 微调
训练容器加载准备好的数据集和配置预设或文件。它使用 Trackio 记录训练指标。请使用 Trackio 仪表板监控运行状态。
我们使用“ss”和“shape”来表示我们用于训练 LoRA 的两种模式。“ss”模式仅微调稀疏结构流 DiT(Sparse-Structure Flow DiT),而“shape”模式则微调形状流 DiT(Shape Flow DiT)。在底层,它们只是引用不同的 config.json 文件以用于各个阶段。有关该过程的更多详细信息可在后文这一部分中找到。
export HF_TOKEN=hf_xxx
hf jobs run -d --flavor a100-large -- timeout 12h --secrets HF_TOKEN \
cr.hf.co/suvadityamuk/trellis2-finetuning-train:latest \
trellis2-train --config ss \
--latents your-username/my-meshes-trellis2 \
--push-to your-username/my-trellis2-lora \
--run-name ss_lora \
--push-path ss_lora \
--trackio-space your-username/trellis2-trackio
hf jobs run -d --flavor a100-large -- timeout 12h --secrets HF_TOKEN \
cr.hf.co/suvadityamuk/trellis2-finetuning-train:latest \
trellis2-train --config shape \
--latents your-username/my-meshes-trellis2 \
--push-to your-username/my-trellis2-lora \
--run-name shape_lora \
--push-path shape_lora \
--trackio-space your-username/trellis2-trackio \
-- set max_steps=3000 i_save=500
如果你设置了 --push-to,容器会将适配器检查点上传至 Hub。为简洁起见,该容器接受的参数也在此处有文档说明。同一仓库中也提供了精简脚本。
如果你想尝试使用我们已经处理好的数据集进行微调,请随意使用以下命令集。
export HF_TOKEN=hf_xxx
hf jobs run -d --flavor a100-large -- timeout 12h --secrets HF_TOKEN \
cr.hf.co/suvadityamuk/trellis2-finetuning-train:latest \
trellis2-train \
--config ss \
--latents suvadityamuk/gso-footwear-trellis2-latents \
--push-to your-username/trellis2-footwear-lora \
--run-name ss_lora \
--push-path ss_lora \
--trackio-space your-username/trellis2-trackio \
-- set max_steps=3000 i_save=500
hf jobs run -d --flavor a100-large -- timeout 12h --secrets HF_TOKEN \
cr.hf.co/suvadityamuk/trellis2-finetuning-train:latest \
trellis2-train \
--config shape \
--latents suvadityamuk/gso-footwear-trellis2-latents \
--push-to your-username/trellis2-footwear-lora \
--run-name shape_lora \
--push-path shape_lora \
--trackio-space your-username/trellis2-trackio \
-- set max_steps=3000 i_save=500
在本地使用 Docker 运行
预处理
命令和标志与 Hugging Face Jobs 相同。仅 Docker 选项不同。
docker run --gpus all -- rm --shm-size 16g -e HF_TOKEN=hf_xxx \
-v hf-cache:/root/.cache/huggingface -v " $PWD /work" :/workspace/work \
cr.hf.co/suvadityamuk/trellis2-finetuning-prep:latest \
trellis2-prep --meshes your-username/my-meshes --push-to your-username/my-meshes-trellis2
LoRA 微调
docker run --gpus all -- rm --shm-size 16g \
-v hf-cache:/root/.cache/huggingface -v " $PWD /work" :/workspace/work \
cr.hf.co/suvadityamuk/trellis2-finetuning-train:latest \
trellis2-train --config ss --latents your-username/my-meshes-trellis2 \
--push-to your-username/my-trellis2-lora --trackio-space your-username/trellis2-trackio
docker run --gpus all -- rm --shm-size 16g \
-v hf-cache:/root/.cache/huggingface -v " $PWD /work" :/workspace/work \
cr.hf.co/suvadityamuk/trellis2-finetuning-train:latest \
trellis2-train --config shape --latents your-username/my-meshes-trellis2 \
--push-to your-username/my-trellis2-lora --trackio-space your-username/trellis2-trackio
如果您希望在本地机器上使用我们已预处理的数据集,请使用以下命令:
export HF_TOKEN=hf_xxx
docker run --gpus all -- rm --shm-size 16g -e HF_TOKEN \
-v hf-cache:/root/.cache/huggingface \
-v " $PWD /work" :/workspace/work \
cr.hf.co/suvadityamuk/trellis2-finetuning-train:latest \
trellis2-train \
--config ss \
--latents suvadityamuk/gso-footwear-trellis2-latents \
--push-to your-username/trellis2-footwear-lora \
--trackio-space your-username/trellis2-trackio \
-- set max_steps=3000 i_save=500
docker run --gpus all -- rm --shm-size 16g -e HF_TOKEN \
-v hf-cache:/root/.cache/huggingface \
-v " $PWD /work" :/workspace/work \
cr.hf.co/suvadityamuk/trellis2-finetuning-train:latest \
trellis2-train \
--config shape \
--latents suvadityamuk/gso-footwear-trellis2-latents \
--push-to your-username/trellis2-footwear-lora \
--trackio-space your-username/trellis2-trackio \
-- set max_steps=3000 i_save=500
我们训练好的 LoRA 适配器位于此仓库中:suvadityamuk/trellis-2-finetune-gso
在训练管道内部
将数据预处理为潜变量
我们使用 TRELLIS.2 的冻结编码器将输入网格转换为训练潜变量。我们保存这些潜变量,以便后续运行无需再次对网格进行编码。
我们还使用 Blender 渲染每个对象的 16 个视图。在训练期间,我们为每个样本随机选择一个视图作为条件图像。我们保留 188 个对象中的 9 个用于评估,并在其余 179 个对象上进行训练。这些被剔除的对象展示了适配器是否在模型训练过程中未见过的对象上有效。
Blender 为某个对象渲染的部分视图
第一个代码片段设置数据。FLOW 选择要训练的流 DiT(ss 或 shape),STEPS 设置优化器步数。批量大小为 4,梯度累积步数为 4,有效批量大小为 16。然后,该片段加载所选流 DiT 的 LoRA 配置文件,以 TRELLIS.2 格式创建数据集,移除被剔除的对象,并为微调创建数据加载器。
cfg = json.load(
open (
{
"ss" : "/workspace/TRELLIS.2/configs/lora/ss_flow_lora_gso.json" ,
"shape" : "/workspace/TRELLIS.2/configs/lora/slat_flow_img2shape_lora_gso.json" ,
}[FLOW]
)
)
key, latents = {
"ss" : ( "ss_latent" , "ss_latents/ss_enc_conv3d_16l8_fp16_64" ),
"shape" : ( "shape_latent" , "shape_latents/shape_enc_next_dc_f16c32_fp16_512"
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!
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.
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.
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.
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.
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 .
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.
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.
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.
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.
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.
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.
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 material attributes into a textured mesh and exports it as a GLB file.
Planning
Which components to fine-tune
We add LoRA adapters only to the sparse-structure flow DiT and the shape flow DiT. These DiTs control the object's shape and geometry. We freeze the texture flow DiT to keep its current capabilities.
Our dataset contains diffuse color maps that include baked lighting effects. To train the texture flow DiT, we need separate material maps. The color maps in our dataset mix surface color with lighting. Thus, they are not correct targets for this training.
If we train the texture flow DiT on these maps, it can learn to show lighting as a surface property. It can also forget what it learned before, a problem called catastrophic forgetting.
Why use LoRA
Our subset has 188 shoes from the 1,030 objects in GSO. For a dataset this small, LoRA is a better choice than full fine-tuning. Full fine-tuning costs much more. It can also overwrite what the model already does well (its learned priors). Our configuration trains approximately 9.3 million adapter parameters in total for both targeted DiTs. We use rank 8 adapters in the attention and feed-forward (MLP) layers of the sparse-structure flow DiT. We use rank 16 adapters in the attention layers of the shape flow DiT. The rank sets the size of the adapter matrices. A higher rank lets the adapter learn more.
What you’ll run
A 3D model setup can need many dependencies and installation steps. We supply two Docker images (that you can run on Jobs or your own machine) with the necessary software. One image is for preprocessing, and one is for fine-tuning.
To train your LoRA adapters and upload them to the Hub:
Give the containers access to your data.
Set the parameters for your task.
Run the preprocessing container.
Run the fine-tuning container.
Then we explain the fine-tuning script, its settings, and how each setting affects training.
Experiment overview
We’ll walk through three parts of the experiment:
Prepare the data. Convert GLB or OBJ meshes into the latent representations TRELLIS.2 uses for training, and render the input images.
Train the adapters. Run one job for each DiT, with the prepared dataset and a LoRA configuration.
Explain the code. Examine how the containers load the data, add adapters, and train the models.
We save the preprocessed dataset so that all training runs can reuse it.
Walkthrough
Running on Hugging Face Jobs
Preprocessing
The preprocessing container uses Blender to render 16 views of each object. LoRA training will use these views as conditioning images. Blender runs without a display, through the xvfb-run utility. The container also processes each object through the preprocessing pipeline . See the footwear dataset here for an example intermediate output. For our 188 objects, the full run took approximately 1 hour on an a100-large job. A compact version of the preprocessing pipeline is also available in this companion repository .
export HF_TOKEN=hf_xxx
hf jobs run -d --flavor a100-large -- timeout 6h --secrets HF_TOKEN \
cr.hf.co/suvadityamuk/trellis2-finetuning-prep:latest \
trellis2-prep \
--meshes your-username/my-meshes \
--push-to your-username/my-meshes-trellis2 \
--private --holdout 0.05 \
--views 16 --workers 8
For Hugging Face Jobs, we pass the following arguments:
flag
meaning
-d
Detach: print the job ID and URL, then return. To follow the job, run hf jobs logs -f
--flavor a100-large
The hardware. We use a100-large (80 GB). To see all options, run hf jobs hardware
--timeout 6h
The job stops after this time. Both commands resume. Preprocessing skips finished objects. Training continues from the newest checkpoint in --push-to
--secrets HF_TOKEN
Send your token (from HF_TOKEN or hf auth login) to the job as an encrypted environment variable. The token is not written into the image
cr.hf.co/...:latest
The image to run. All text after it is the command that runs in the container
This container accepts a few more arguments (regardless of being run on Hugging Face Jobs or with Docker), that you can find documented over here . The steps taken in the preprocessing pipeline are documented in this section later.
LoRA Fine-tuning
The training container loads the prepared dataset and a configuration preset or file. It records training metrics with Trackio. Use the Trackio dashboard to monitor the run.
We use ‘ss’ and ‘shape’ to indicate the two modes we have for training the LoRAs. The ‘ss’ mode will finetune only the Sparse-Structure Flow DiT, whereas the ‘shape’ mode will finetune the Shape Flow DiT. Under the hood, they simply reference different config.json files to use for each stage. More details about the process is available in this section later.
export HF_TOKEN=hf_xxx
hf jobs run -d --flavor a100-large -- timeout 12h --secrets HF_TOKEN \
cr.hf.co/suvadityamuk/trellis2-finetuning-train:latest \
trellis2-train --config ss \
--latents your-username/my-meshes-trellis2 \
--push-to your-username/my-trellis2-lora \
--run-name ss_lora \
--push-path ss_lora \
--trackio-space your-username/trellis2-trackio
hf jobs run -d --flavor a100-large -- timeout 12h --secrets HF_TOKEN \
cr.hf.co/suvadityamuk/trellis2-finetuning-train:latest \
trellis2-train --config shape \
--latents your-username/my-meshes-trellis2 \
--push-to your-username/my-trellis2-lora \
--run-name shape_lora \
--push-path shape_lora \
--trackio-space your-username/trellis2-trackio \
-- set max_steps=3000 i_save=500
If you set --push-to , the container uploads adapter checkpoints to the Hub. The container accepts parameters that are also documented here for brevity . A compact script is also available in the same repository .
If you want to play around and fine-tune with the already-processed dataset we have , feel free to use the following set of commands.
export HF_TOKEN=hf_xxx
hf jobs run -d --flavor a100-large -- timeout 12h --secrets HF_TOKEN \
cr.hf.co/suvadityamuk/trellis2-finetuning-train:latest \
trellis2-train \
--config ss \
--latents suvadityamuk/gso-footwear-trellis2-latents \
--push-to your-username/trellis2-footwear-lora \
--run-name ss_lora \
--push-path ss_lora \
--trackio-space your-username/trellis2-trackio \
-- set max_steps=3000 i_save=500
hf jobs run -d --flavor a100-large -- timeout 12h --secrets HF_TOKEN \
cr.hf.co/suvadityamuk/trellis2-finetuning-train:latest \
trellis2-train \
--config shape \
--latents suvadityamuk/gso-footwear-trellis2-latents \
--push-to your-username/trellis2-footwear-lora \
--run-name shape_lora \
--push-path shape_lora \
--trackio-space your-username/trellis2-trackio \
-- set max_steps=3000 i_save=500
Running locally with Docker
Preprocessing
The commands and flags are the same as for Hugging Face Jobs. Only the Docker options are different.
docker run --gpus all -- rm --shm-size 16g -e HF_TOKEN=hf_xxx \
-v hf-cache:/root/.cache/huggingface -v " $PWD /work" :/workspace/work \
cr.hf.co/suvadityamuk/trellis2-finetuning-prep:latest \
trellis2-prep --meshes your-username/my-meshes --push-to your-username/my-meshes-trellis2
LoRA Fine-tuning
docker run --gpus all -- rm --shm-size 16g \
-v hf-cache:/root/.cache/huggingface -v " $PWD /work" :/workspace/work \
cr.hf.co/suvadityamuk/trellis2-finetuning-train:latest \
trellis2-train --config ss --latents your-username/my-meshes-trellis2 \
--push-to your-username/my-trellis2-lora --trackio-space your-username/trellis2-trackio
docker run --gpus all -- rm --shm-size 16g \
-v hf-cache:/root/.cache/huggingface -v " $PWD /work" :/workspace/work \
cr.hf.co/suvadityamuk/trellis2-finetuning-train:latest \
trellis2-train --config shape --latents your-username/my-meshes-trellis2 \
--push-to your-username/my-trellis2-lora --trackio-space your-username/trellis2-trackio
If you want to use our already-preprocessed dataset locally on your machine of choice, use the following commands:
export HF_TOKEN=hf_xxx
docker run --gpus all -- rm --shm-size 16g -e HF_TOKEN \
-v hf-cache:/root/.cache/huggingface \
-v " $PWD /work" :/workspace/work \
cr.hf.co/suvadityamuk/trellis2-finetuning-train:latest \
trellis2-train \
--config ss \
--latents suvadityamuk/gso-footwear-trellis2-latents \
--push-to your-username/trellis2-footwear-lora \
--trackio-space your-username/trellis2-trackio \
-- set max_steps=3000 i_save=500
docker run --gpus all -- rm --shm-size 16g -e HF_TOKEN \
-v hf-cache:/root/.cache/huggingface \
-v " $PWD /work" :/workspace/work \
cr.hf.co/suvadityamuk/trellis2-finetuning-train:latest \
trellis2-train \
--config shape \
--latents suvadityamuk/gso-footwear-trellis2-latents \
--push-to your-username/trellis2-footwear-lora \
--trackio-space your-username/trellis2-trackio \
-- set max_steps=3000 i_save=500
Our trained LoRA adapters are in this repository: suvadityamuk/trellis-2-finetune-gso
Inside the training pipeline
Preprocessing into latents
We use TRELLIS.2’s frozen encoders to convert the input meshes into training latents. We save these latents, so later runs do not have to encode the meshes again.
We also render 16 views of each object in Blender. During training, we select one random view for each sample as the conditioning image. We keep 9 of the 188 objects for evaluation and train on the other 179. These held-out objects show whether the adapters work on objects unseen by the model during training.
Some of the views that Blender rendered for one object
The first snippet sets up the data. FLOW selects the flow DiT to train ( ss or shape ), and STEPS sets the number of optimizer steps. A batch size of 4 with 4 gradient accumulation steps gives an effective batch size of 16. Then, the snippet loads the LoRA config file for the selected flow DiT, makes the dataset in the TRELLIS.2 format, removes the held-out objects, and makes the data loader for fine-tuning.
cfg = json.load(
open (
{
"ss" : "/workspace/TRELLIS.2/configs/lora/ss_flow_lora_gso.json" ,
"shape" : "/workspace/TRELLIS.2/configs/lora/slat_flow_img2shape_lora_gso.json" ,
}[FLOW]
)
)
key, latents = {
"ss" : ( "ss_latent" , "ss_latents/ss_enc_conv3d_16l8_fp16_64" ),
"shape" : ( "shape_latent" , "shape_latents/shape_enc_next_dc_f16c32_fp16_512"
首次收录 · 2026-11-13 · 9.95 分