配置

硬件

  • i7-11700@2.50GHz
  • 64GB RAM
  • RTX 3060
    • 12GB

软件

模型

没有在线 Interface,本地部署使用。每个模型使用独立的虚拟环境运行。

1
2
python -m venv venv
.\venv\Scripts\activate

SF3D

1
2
3
# code
git clone https://github.com/Stability-AI/stable-fast-3d.git
cd stable-fast-3d

依赖安装报错,把 requirement.txt 里的 texture_baker 和 uv_unwrapper 删除,手动安装

1
2
3
4
5
6
7
8
9
10
11
12
# dependencies
cd texture_baker
python setup.py install
cd ../uv_unwrapper
python setup.py install
cd ..
pip install -r requirements.txt
pip install -r requirements-demo.txt
pip install -U gradio gradio_client # gradio-litmodel3d incompatible 暂时不管

# interface
python gradio_app.py

TripoSR

1
2
3
4
5
6
7
8
9
10
11
# code
git clone https://github.com/VAST-AI-Research/TripoSR.git
cd TripoSR

# dependencies
pip install -r requirements.txt
pip install onnxruntime
pip install -U gradio transformers tokenizers

# interface
python gradio_app.py --listen

Hunyuan3D

1
2
3
4
5
6
7
8
9
10
11
# code
git clone https://github.com/Tencent-Hunyuan/Hunyuan3D-2.git
cd Hunyuan3D-2

# dependencies
pip install -r requirements.txt
pip install -e .
cd hy3dgen/texgen/custom_rasterizer
python setup.py install
cd ../differentiable_renderer
python setup.py install

直接运行的话路由有问题,需修改 gradio_app.py

1
app = gr.mount_gradio_app(app, demo, path="") # 删除 /
1
2
# image-to-3d
python gradio_app.py --model_path tencent/Hunyuan3D-2 --subfolder hunyuan3d-dit-v2-0 --texgen_model_path tencent/Hunyuan3D-2 --low_vram_mode

启用 text-to-3d 需要加个 patch,在项目根目录新建 fix_lazy_loading.py

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import sys
import importlib

def patch_t5_tokenizer():
"""Force proper loading of T5 tokenizer"""
try:
# Force import of T5 tokenizer module
import transformers.models.t5.tokenization_t5

# Ensure the module is properly loaded
if hasattr(transformers.models.t5.tokenization_t5, 'T5Tokenizer'):
print("T5Tokenizer successfully loaded")
return True
else:
print("T5Tokenizer not found in module")
return False
except Exception as e:
print(f"Failed to patch T5 tokenizer: {e}")
return False

def patch_transformers():
"""Apply patches to fix lazy loading"""
# Import transformers first
import transformers

# Force load tokenizer modules
from transformers import T5Tokenizer, T5TokenizerFast

# Monkey patch the lazy module if needed
import transformers.models.t5.tokenization_t5 as t5_tokenizer_module

# Ensure classes are properly exposed
if not hasattr(t5_tokenizer_module, 'T5Tokenizer'):
t5_tokenizer_module.T5Tokenizer = T5Tokenizer

print("Transformers patching complete")

if __name__ == "__main__":
patch_transformers()
patch_t5_tokenizer()

更新 gradio_app.py,导入 patch 文件

1
2
3
import logger
import fix_lazy_loading
fix_lazy_loading.patch_transformers()

启用 text-to-3d 需要在运行时添加命令行参数 --enable_t23d

1
2
3
4
5
# dependencies
pip install sentencepiece

# text-to-3d
python gradio_app.py --model_path tencent/Hunyuan3D-2 --subfolder hunyuan3d-dit-v2-0 --texgen_model_path tencent/Hunyuan3D-2 --low_vram_mode --enable_t23d

文本转模型相当慢,预计 40min 左右😂

TRELLIS

Windows 上直接跑各种问题(Setting Up Trellis on Windows #3),后面直接找了个现成的 IgorAherne/trellis-stable-projectorz installer,暂不支持 text-to-3d

修改 code/gradio_main.py ,绑定到 0.0.0.0

1
demo.launch(server_name="0.0.0.0") # 添加参数

解压后双击运行 run-gradio-fp16.bat,会自动创建虚拟环境。如果需要登录 huggingface 的话进入虚拟环境操作即可。

InstantMesh

1
2
3
4
5
6
7
8
9
10
11
# code
git clone https://github.com/TencentARC/InstantMesh.git
cd InstantMesh

# dependencies
pip install Ninja onnxruntime
pip install -r requirements.txt
pip install -U gradio tokenizers transformers diffusers

# interface
python app.py

Stable-Zero123

需要通过 threestudio 使用

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# model
git clone https://huggingface.co/stabilityai/stable-zero123
git clone https://github.com/threestudio-project/threestudio.git
cp stable-zero123/stable_zero123.ckpt threestudio/load/zero123/

# dependencies
cd threestudio
pip install ninja
# 注释 nerfacc envlight nvdiffrast tiny-cuda-nn
pip install -r requirements.txt
pip install nerfacc==0.5.2 envlight
pip install libigl==2.5.1
pip install huggingface_hub==0.25.*

git clone https://github.com/NVlabs/nvdiffrast.git
cd nvdiffrast
pip install .

python -m pip install pip==23.0.1
pip install git+https://github.com/NVlabs/tiny-cuda-nn/#subdirectory=bindings/torch

添加环境变量

1
D:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.44.35207\bin\Hostx64\x64

直接跑预估 68h,trainer.max_steps 配置为 600,改成 5 只需要半小时

1
python launch.py --config configs/stable-zero123.yaml --train --gpu 0 trainer.max_steps=5 data.image_path=./load/images/hamburger_rgba.png

但是导出模型报错,暂未解决(太难用了)

1
python launch.py --config "outputs/zero123-sai/[64, 128, 256]_hamburger_rgba.png@20250901-142614/configs/parsed.yaml" --export --gpu 0 resume="outputs/zero123-sai/[64, 128, 256]_hamburger_rgba.png@20250901-142614/ckpts/last.ckpt" system.exporter_type=mesh-exporter

参阅