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|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!-- ## **Hunyuan3D-1.0** -->
|
2 |
+
|
3 |
+
<p align="center">
|
4 |
+
<img src="./assets/logo.png" height=200>
|
5 |
+
</p>
|
6 |
+
|
7 |
+
# Tencent Hunyuan3D-1.0: A Unified Framework for Text-to-3D and Image-to-3D Generation
|
8 |
+
|
9 |
+
<div align="center">
|
10 |
+
<a href="https://github.com/tencent/Hunyuan3D-1"><img src="https://img.shields.io/static/v1?label=Code&message=Github&color=blue&logo=github-pages"></a>  
|
11 |
+
<a href="https://3d.hunyuan.tencent.com"><img src="https://img.shields.io/static/v1?label=Homepage&message=Tencent Hunyuan3D&color=blue&logo=github-pages"></a>  
|
12 |
+
<a href="https://arxiv.org/pdf/2411.02293"><img src="https://img.shields.io/static/v1?label=Tech Report&message=Arxiv&color=red&logo=arxiv"></a>  
|
13 |
+
<a href="https://huggingface.co/Tencent/Hunyuan3D-1"><img src="https://img.shields.io/static/v1?label=Checkpoints&message=HuggingFace&color=yellow"></a>  
|
14 |
+
<a href="https://huggingface.co/spaces/Tencent/Hunyuan3D-1"><img src="https://img.shields.io/static/v1?label=Demo&message=HuggingFace&color=yellow"></a>  
|
15 |
+
</div>
|
16 |
+
|
17 |
+
|
18 |
+
## 🔥🔥🔥 News!!
|
19 |
+
|
20 |
+
* Nov 5, 2024: 💬 We support demo running image_to_3d generation now. Please check the [script](#using-gradio) below.
|
21 |
+
* Nov 5, 2024: 💬 We support demo running text_to_3d generation now. Please check the [script](#using-gradio) below.
|
22 |
+
|
23 |
+
|
24 |
+
## 📑 Open-source Plan
|
25 |
+
|
26 |
+
- [x] Inference
|
27 |
+
- [x] Checkpoints
|
28 |
+
- [ ] Baking related
|
29 |
+
- [ ] Training
|
30 |
+
- [ ] ComfyUI
|
31 |
+
- [ ] Distillation Version
|
32 |
+
- [ ] TensorRT Version
|
33 |
+
|
34 |
+
|
35 |
+
|
36 |
+
## **Abstract**
|
37 |
+
<p align="center">
|
38 |
+
<img src="./assets/teaser.png" height=450>
|
39 |
+
</p>
|
40 |
+
|
41 |
+
While 3D generative models have greatly improved artists' workflows, the existing diffusion models for 3D generation suffer from slow generation and poor generalization. To address this issue, we propose a two-stage approach named Hunyuan3D-1.0 including a lite version and a standard version, that both support text- and image-conditioned generation.
|
42 |
+
|
43 |
+
In the first stage, we employ a multi-view diffusion model that efficiently generates multi-view RGB in approximately 4 seconds. These multi-view images capture rich details of the 3D asset from different viewpoints, relaxing the tasks from single-view to multi-view reconstruction. In the second stage, we introduce a feed-forward reconstruction model that rapidly and faithfully reconstructs the 3D asset given the generated multi-view images in approximately 7 seconds. The reconstruction network learns to handle noises and in-consistency introduced by the multi-view diffusion and leverages the available information from the condition image to efficiently recover the 3D structure.
|
44 |
+
|
45 |
+
Our framework involves the text-to-image model, i.e., Hunyuan-DiT, making it a unified framework to support both text- and image-conditioned 3D generation. Our standard version has 3x more parameters than our lite and other existing model. Our Hunyuan3D-1.0 achieves an impressive balance between speed and quality, significantly reducing generation time while maintaining the quality and diversity of the produced assets.
|
46 |
+
|
47 |
+
|
48 |
+
## 🎉 **Hunyuan3D-1 Architecture**
|
49 |
+
|
50 |
+
<p align="center">
|
51 |
+
<img src="./assets/overview_3.png" height=400>
|
52 |
+
</p>
|
53 |
+
|
54 |
+
|
55 |
+
## 📈 Comparisons
|
56 |
+
|
57 |
+
We have evaluated Hunyuan3D-1.0 with other open-source 3d-generation methods, our Hunyuan3D-1.0 received the highest user preference across 5 metrics. Details in the picture on the lower left.
|
58 |
+
|
59 |
+
The lite model takes around 10 seconds to produce a 3D mesh from a single image on an NVIDIA A100 GPU, while the standard model takes roughly 25 seconds. The plot laid out in the lower right demonstrates that Hunyuan3D-1.0 achieves an optimal balance between quality and efficiency.
|
60 |
+
|
61 |
+
<p align="center">
|
62 |
+
<img src="./assets/radar.png" height=300>
|
63 |
+
<img src="./assets/runtime.png" height=300>
|
64 |
+
</p>
|
65 |
+
|
66 |
+
## Get Started
|
67 |
+
|
68 |
+
#### Begin by cloning the repository:
|
69 |
+
|
70 |
+
```shell
|
71 |
+
git clone https://github.com/tencent/Hunyuan3D-1
|
72 |
+
cd Hunyuan3D-1
|
73 |
+
```
|
74 |
+
|
75 |
+
#### Installation Guide for Linux
|
76 |
+
|
77 |
+
We provide an env_install.sh script file for setting up environment.
|
78 |
+
|
79 |
+
```
|
80 |
+
# step 1, create conda env
|
81 |
+
conda create -n hunyuan3d-1 python=3.9 or 3.10 or 3.11 or 3.12
|
82 |
+
conda activate hunyuan3d-1
|
83 |
+
|
84 |
+
# step 2. install torch realated package
|
85 |
+
which pip # check pip corresponds to python
|
86 |
+
|
87 |
+
# modify the cuda version according to your machine (recommended)
|
88 |
+
pip install torch torchvision --index-url https://download.pytorch.org/whl/cu121
|
89 |
+
|
90 |
+
# step 3. install other packages
|
91 |
+
bash env_install.sh
|
92 |
+
```
|
93 |
+
<details>
|
94 |
+
<summary>💡Other tips for envrionment installation</summary>
|
95 |
+
|
96 |
+
Optionally, you can install xformers or flash_attn to acclerate computation:
|
97 |
+
|
98 |
+
```
|
99 |
+
pip install xformers --index-url https://download.pytorch.org/whl/cu121
|
100 |
+
```
|
101 |
+
```
|
102 |
+
pip install flash_attn
|
103 |
+
```
|
104 |
+
|
105 |
+
Most environment errors are caused by a mismatch between machine and packages. You can try manually specifying the version, as shown in the following successful cases:
|
106 |
+
```
|
107 |
+
# python3.9
|
108 |
+
pip install torch==2.0.1 torchvision==0.15.2 --index-url https://download.pytorch.org/whl/cu118
|
109 |
+
```
|
110 |
+
|
111 |
+
when install pytorch3d, the gcc version is preferably greater than 9, and the gpu driver should not be too old.
|
112 |
+
|
113 |
+
</details>
|
114 |
+
|
115 |
+
#### Download Pretrained Models
|
116 |
+
|
117 |
+
The models are available at [https://huggingface.co/tencent/Hunyuan3D-1](https://huggingface.co/tencent/Hunyuan3D-1):
|
118 |
+
|
119 |
+
+ `Hunyuan3D-1/lite`, lite model for multi-view generation.
|
120 |
+
+ `Hunyuan3D-1/std`, standard model for multi-view generation.
|
121 |
+
+ `Hunyuan3D-1/svrm`, sparse-view reconstruction model.
|
122 |
+
|
123 |
+
|
124 |
+
To download the model, first install the huggingface-cli. (Detailed instructions are available [here](https://huggingface.co/docs/huggingface_hub/guides/cli).)
|
125 |
+
|
126 |
+
```shell
|
127 |
+
python3 -m pip install "huggingface_hub[cli]"
|
128 |
+
```
|
129 |
+
|
130 |
+
Then download the model using the following commands:
|
131 |
+
|
132 |
+
```shell
|
133 |
+
mkdir weights
|
134 |
+
huggingface-cli download tencent/Hunyuan3D-1 --local-dir ./weights
|
135 |
+
|
136 |
+
mkdir weights/hunyuanDiT
|
137 |
+
huggingface-cli download Tencent-Hunyuan/HunyuanDiT-v1.1-Diffusers-Distilled --local-dir ./weights/hunyuanDiT
|
138 |
+
```
|
139 |
+
|
140 |
+
#### Inference
|
141 |
+
For text to 3d generation, we supports bilingual Chinese and English, you can use the following command to inference.
|
142 |
+
```python
|
143 |
+
python3 main.py \
|
144 |
+
--text_prompt "a lovely rabbit" \
|
145 |
+
--save_folder ./outputs/test/ \
|
146 |
+
--max_faces_num 90000 \
|
147 |
+
--do_texture_mapping \
|
148 |
+
--do_render
|
149 |
+
```
|
150 |
+
|
151 |
+
For image to 3d generation, you can use the following command to inference.
|
152 |
+
```python
|
153 |
+
python3 main.py \
|
154 |
+
--image_prompt "/path/to/your/image" \
|
155 |
+
--save_folder ./outputs/test/ \
|
156 |
+
--max_faces_num 90000 \
|
157 |
+
--do_texture_mapping \
|
158 |
+
--do_render
|
159 |
+
```
|
160 |
+
We list some more useful configurations for easy usage:
|
161 |
+
|
162 |
+
| Argument | Default | Description |
|
163 |
+
|:------------------:|:---------:|:---------------------------------------------------:|
|
164 |
+
|`--text_prompt` | None |The text prompt for 3D generation |
|
165 |
+
|`--image_prompt` | None |The image prompt for 3D generation |
|
166 |
+
|`--t2i_seed` | 0 |The random seed for generating images |
|
167 |
+
|`--t2i_steps` | 25 |The number of steps for sampling of text to image |
|
168 |
+
|`--gen_seed` | 0 |The random seed for generating 3d generation |
|
169 |
+
|`--gen_steps` | 50 |The number of steps for sampling of 3d generation |
|
170 |
+
|`--max_faces_numm` | 90000 |The limit number of faces of 3d mesh |
|
171 |
+
|`--save_memory` | False |module will move to cpu automatically|
|
172 |
+
|`--do_texture_mapping` | False |Change vertex shadding to texture shading |
|
173 |
+
|`--do_render` | False |render gif |
|
174 |
+
|
175 |
+
|
176 |
+
We have also prepared scripts with different configurations for reference
|
177 |
+
- Inference Std-pipeline requires 30GB VRAM (24G VRAM with --save_memory).
|
178 |
+
- Inference Lite-pipeline requires 22GB VRAM (18G VRAM with --save_memory).
|
179 |
+
- Note: --save_memory will increase inference time
|
180 |
+
|
181 |
+
```bash
|
182 |
+
bash scripts/text_to_3d_std.sh
|
183 |
+
bash scripts/text_to_3d_lite.sh
|
184 |
+
bash scripts/image_to_3d_std.sh
|
185 |
+
bash scripts/image_to_3d_lite.sh
|
186 |
+
```
|
187 |
+
|
188 |
+
If your gpu memory is 16G, you can try to run modules in pipeline seperately:
|
189 |
+
```bash
|
190 |
+
bash scripts/text_to_3d_std_separately.sh 'a lovely rabbit' ./outputs/test # >= 16G
|
191 |
+
bash scripts/text_to_3d_lite_separately.sh 'a lovely rabbit' ./outputs/test # >= 14G
|
192 |
+
bash scripts/image_to_3d_std_separately.sh ./demos/example_000.png ./outputs/test # >= 16G
|
193 |
+
bash scripts/image_to_3d_lite_separately.sh ./demos/example_000.png ./outputs/test # >= 10G
|
194 |
+
```
|
195 |
+
|
196 |
+
#### Using Gradio
|
197 |
+
|
198 |
+
We have prepared two versions of multi-view generation, std and lite.
|
199 |
+
|
200 |
+
```shell
|
201 |
+
# std
|
202 |
+
python3 app.py
|
203 |
+
python3 app.py --save_memory
|
204 |
+
|
205 |
+
# lite
|
206 |
+
python3 app.py --use_lite
|
207 |
+
python3 app.py --use_lite --save_memory
|
208 |
+
```
|
209 |
+
|
210 |
+
Then the demo can be accessed through http://0.0.0.0:8080. It should be noted that the 0.0.0.0 here needs to be X.X.X.X with your server IP.
|
211 |
+
|
212 |
+
## Camera Parameters
|
213 |
+
|
214 |
+
Output views are a fixed set of camera poses:
|
215 |
+
|
216 |
+
+ Azimuth (relative to input view): `+0, +60, +120, +180, +240, +300`.
|
217 |
+
|
218 |
+
|
219 |
+
## Citation
|
220 |
+
|
221 |
+
If you found this repository helpful, please cite our report:
|
222 |
+
```bibtex
|
223 |
+
@misc{yang2024tencent,
|
224 |
+
title={Tencent Hunyuan3D-1.0: A Unified Framework for Text-to-3D and Image-to-3D Generation},
|
225 |
+
author={Xianghui Yang and Huiwen Shi and Bowen Zhang and Fan Yang and Jiacheng Wang and Hongxu Zhao and Xinhai Liu and Xinzhou Wang and Qingxiang Lin and Jiaao Yu and Lifu Wang and Zhuo Chen and Sicong Liu and Yuhong Liu and Yong Yang and Di Wang and Jie Jiang and Chunchao Guo},
|
226 |
+
year={2024},
|
227 |
+
eprint={2411.02293},
|
228 |
+
archivePrefix={arXiv},
|
229 |
+
primaryClass={cs.CV}
|
230 |
+
}
|
231 |
+
```
|