配置

硬件

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

软件

  • Python 3.11.6
  • CUDA 12.8
  • PyTorch 2.8.0+cu128

模型

没有在线 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 unyuan3D-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 的话进入虚拟环境操作即可。

参阅