Tencent Hunyuan3D-1 安装与配置指南
1. 项目基础介绍
Tencent Hunyuan3D-1 是腾讯开源的一个统一框架,用于文本到3D和图像到3D的生成。该框架通过两个阶段的生成方法,提供快速且高质量的3D资产生成。主要编程语言为 Python。
2. 项目使用的关键技术和框架
- 多视角扩散模型:在第一阶段,使用多视角扩散模型生成多视角RGB图像,捕获3D资产从不同视角的丰富细节。
- 前馈重建模型:在第二阶段,引入前馈重建模型,快速且忠实地将生成的多视角图像重建为3D资产。
- 文本到图像模型:集成了 Hunyuan-DiT 文本到图像模型,支持文本和图像条件的3D生成。
- 关键框架:使用 PyTorch 和 PyTorch3D 等框架。
3. 项目安装和配置
准备工作
在开始安装之前,请确保你的系统满足以下要求:
- Python 3.9 或更高版本
- NVIDIA GPU(推荐 VRAM 22GB 或以上)
- CUDA 11.1 或更高版本
- GCC 版本大于 9
安装步骤
-
克隆项目仓库
首先,克隆 Hunyuan3D-1 仓库到本地环境:
git clone https://github.com/tencent/Hunyuan3D-1.git cd Hunyuan3D-1
-
创建虚拟环境并安装依赖
创建一个虚拟环境,并安装必要的依赖:
conda create -n hunyuan3d-1 python=3.9 conda activate hunyuan3d-1 pip3 install torch torchvision --index-url https://download.pytorch.org/whl/cu121 bash env_install.sh
或者直接安装所有依赖:
pip3 install -r requirements.txt --index-url https://download.pytorch.org/whl/cu121
-
安装额外的依赖
安装 PyTorch3D 和 nvdiffrast:
pip3 install git+https://github.com/facebookresearch/pytorch3d@stable pip3 install git+https://github.com/NVlabs/nvdiffrast
-
安装 Dust3r(可选)
如果需要使用 Dust3r,请执行以下命令:
cd third_party git clone --recursive https://github.com/naver/dust3r.git cd ../third_party/weights wget https://download.europe.naverlabs.com/ComputerVision/DUSt3R/DUSt3R_ViTLarge_BaseDecoder_512_dpt.pth
-
下载预训练模型
从 Hugging Face 下载预训练模型:
mkdir weights huggingface-cli download tencent/Hunyuan3D-1 --local-dir ./weights mkdir weights/hunyuanDiT huggingface-cli download Tencent-Hunyuan/HunyuanDiT-v1.1-Diffusers-Distilled --local-dir ./weights/hunyuanDiT
-
运行示例脚本
运行以下任一脚本来进行文本到3D或图像到3D的生成:
bash scripts/text_to_3d_std.sh bash scripts/image_to_3d_std.sh
如果 GPU 内存较小,可以使用以下脚本分步运行:
bash scripts/text_to_3d_std_separately.sh 'a lovely rabbit' ./outputs/test bash scripts/image_to_3d_std_separately.sh ./demos/example_000.png ./outputs/test
确保按照以上步骤操作,你将能够成功安装并运行 Tencent Hunyuan3D-1 项目。