Skip to content

Commit baab8ba

Browse files
committed
release turbo and flashvdm
1 parent db3ca6e commit baab8ba

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+1177
-497
lines changed

README.md

+45-19
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,13 @@
2525

2626
<br>
2727

28-
> 🔥🔥🔥 **New**: Release 🤗 [Hunyuan3D-2mv](https://huggingface.co/spaces/tencent/Hunyuan3D-2mv) and
28+
29+
> 🔥🔥🔥 **New**:
30+
>
31+
> Release 🤗 [Hunyuan3D-2-Turbo](https://huggingface.co/tencent/Hunyuan3D-2/tree/main/hunyuan3d-dit-v2-0-turbo) and
32+
> 🤗[Hunyuan3D-2mini-Turbo](https://huggingface.co/tencent/Hunyuan3D-2mini/tree/main/hunyuan3d-dit-v2-mini-turbo).
33+
>
34+
> Release 🤗 [Hunyuan3D-2mv](https://huggingface.co/tencent/Hunyuan3D-2mv) and
2935
> 🤗[Hunyuan3D-2mini](https://huggingface.co/tencent/Hunyuan3D-2mini).
3036
3137
> Join our **[Wechat](#)** and **[Discord](https://discord.gg/dNBrdrGGMa)** group to discuss and find help from us.
@@ -42,6 +48,7 @@
4248

4349
## 🔥 News
4450

51+
- Mar 19, 2025: 🤗 Release turbo model [Hunyuan3D-2-Turbo](https://huggingface.co/tencent/Hunyuan3D-2/), [Hunyuan3D-2mini-Turbo](https://huggingface.co/tencent/Hunyuan3D-2mini/) and [FlashVDM](https://github.com/Tencent/FlashVDM).
4552
- Mar 18, 2025: 🤗 Release multiview shape model [Hunyuan3D-2mv](https://huggingface.co/tencent/Hunyuan3D-2mv) and 0.6B
4653
shape model [Hunyuan3D-2mini](https://huggingface.co/tencent/Hunyuan3D-2mini).
4754
- Feb 14, 2025: 🛠️ Release texture enhancement module, please obtain high-definition textures
@@ -117,29 +124,34 @@ Generation results of Hunyuan3D 2.0:
117124

118125
## 🎁 Models Zoo
119126

120-
It takes 6 GB VRAM for shape generation and 12 GB for shape and texture generation in total with cpu offloading.
127+
It takes 6 GB VRAM for shape generation and 24.5 GB for shape and texture generation in total.
121128

122129
Hunyuan3D-2mini Series
123130

124-
| Model | Description | Date | Size | Huggingface |
125-
|--------------------------|--------------------------------|------------|------|------------------------------------------------------------------------------------------|
126-
| Hunyuan3D-DiT-v2-mini | Mini Image to Shape Model | 2025-03-18 | 0.6B | [Download](https://huggingface.co/tencent/Hunyuan3D-2mini/tree/main/hunyuan3d-dit-v2-mini) |
131+
| Model | Description | Date | Size | Huggingface |
132+
|-----------------------------|-------------------------------|------------|------|--------------------------------------------------------------------------------------------------|
133+
| Hunyuan3D-DiT-v2-mini-Turbo | Step Distillation Version | 2025-03-19 | 0.6B | [Download](https://huggingface.co/tencent/Hunyuan3D-2mini/tree/main/hunyuan3d-dit-v2-mini-turbo) |
134+
| Hunyuan3D-DiT-v2-mini-Fast | Guidance Distillation Version | 2025-03-18 | 0.6B | [Download](https://huggingface.co/tencent/Hunyuan3D-2mini/tree/main/hunyuan3d-dit-v2-mini-fast) |
135+
| Hunyuan3D-DiT-v2-mini | Mini Image to Shape Model | 2025-03-18 | 0.6B | [Download](https://huggingface.co/tencent/Hunyuan3D-2mini/tree/main/hunyuan3d-dit-v2-mini) |
136+
127137

128138
Hunyuan3D-2mv Series
129139

130-
| Model | Description | Date | Size | Huggingface |
131-
|--------------------------|--------------------------------|------------|------|------------------------------------------------------------------------------------------|
132-
| Hunyuan3D-DiT-v2-mv-Fast | Guidance Distillation Version | 2025-03-18 | 1.1B | [Download](https://huggingface.co/tencent/Hunyuan3D-2mv/tree/main/hunyuan3d-dit-v2-mv-fast) |
133-
| Hunyuan3D-DiT-v2-mv | Multiview Image to Shape Model | 2025-03-18 | 1.1B | [Download](https://huggingface.co/tencent/Hunyuan3D-2mv/tree/main/hunyuan3d-dit-v2-mv) |
140+
| Model | Description | Date | Size | Huggingface |
141+
|---------------------------|--------------------------------|------------|------|----------------------------------------------------------------------------------------------|
142+
| Hunyuan3D-DiT-v2-mv-Turbo | Step Distillation Version | 2025-03-19 | 1.1B | [Download](https://huggingface.co/tencent/Hunyuan3D-2mv/tree/main/hunyuan3d-dit-v2-mv-turbo) |
143+
| Hunyuan3D-DiT-v2-mv-Fast | Guidance Distillation Version | 2025-03-18 | 1.1B | [Download](https://huggingface.co/tencent/Hunyuan3D-2mv/tree/main/hunyuan3d-dit-v2-mv-fast) |
144+
| Hunyuan3D-DiT-v2-mv | Multiview Image to Shape Model | 2025-03-18 | 1.1B | [Download](https://huggingface.co/tencent/Hunyuan3D-2mv/tree/main/hunyuan3d-dit-v2-mv) |
134145

135146
Hunyuan3D-2 Series
136147

137-
| Model | Description | Date | Size | Huggingface |
138-
|--------------------------|--------------------------------|------------|------|------------------------------------------------------------------------------------------|
139-
| Hunyuan3D-DiT-v2-0-Fast | Guidance Distillation Model | 2025-02-03 | 1.1B | [Download](https://huggingface.co/tencent/Hunyuan3D-2/tree/main/hunyuan3d-dit-v2-0-fast) |
140-
| Hunyuan3D-DiT-v2-0 | Image to Shape Model | 2025-01-21 | 1.1B | [Download](https://huggingface.co/tencent/Hunyuan3D-2/tree/main/hunyuan3d-dit-v2-0) |
141-
| Hunyuan3D-Paint-v2-0 | Texture Generation Model | 2025-01-21 | 1.3B | [Download](https://huggingface.co/tencent/Hunyuan3D-2/tree/main/hunyuan3d-paint-v2-0) |
142-
| Hunyuan3D-Delight-v2-0 | Image Delight Model | 2025-01-21 | 1.3B | [Download](https://huggingface.co/tencent/Hunyuan3D-2/tree/main/hunyuan3d-delight-v2-0) |
148+
| Model | Description | Date | Size | Huggingface |
149+
|--------------------------|-----------------------------|------------|------|-------------------------------------------------------------------------------------------|
150+
| Hunyuan3D-DiT-v2-0-Turbo | Step Distillation Model | 2025-03-19 | 1.1B | [Download](https://huggingface.co/tencent/Hunyuan3D-2/tree/main/hunyuan3d-dit-v2-0-turbo) |
151+
| Hunyuan3D-DiT-v2-0-Fast | Guidance Distillation Model | 2025-02-03 | 1.1B | [Download](https://huggingface.co/tencent/Hunyuan3D-2/tree/main/hunyuan3d-dit-v2-0-fast) |
152+
| Hunyuan3D-DiT-v2-0 | Image to Shape Model | 2025-01-21 | 1.1B | [Download](https://huggingface.co/tencent/Hunyuan3D-2/tree/main/hunyuan3d-dit-v2-0) |
153+
| Hunyuan3D-Paint-v2-0 | Texture Generation Model | 2025-01-21 | 1.3B | [Download](https://huggingface.co/tencent/Hunyuan3D-2/tree/main/hunyuan3d-paint-v2-0) |
154+
| Hunyuan3D-Delight-v2-0 | Image Delight Model | 2025-01-21 | 1.3B | [Download](https://huggingface.co/tencent/Hunyuan3D-2/tree/main/hunyuan3d-delight-v2-0) |
143155

144156
## 🤗 Get Started with Hunyuan3D 2.0
145157

@@ -196,20 +208,34 @@ pipeline = Hunyuan3DPaintPipeline.from_pretrained('tencent/Hunyuan3D-2')
196208
mesh = pipeline(mesh, image='assets/demo.png')
197209
```
198210

199-
Please visit [examples](examples) folder for more advanced usage, such as **multiview image to 3D generation** and **texture generation
211+
Please visit [examples](examples) folder for more advanced usage, such as **multiview image to 3D generation** and *
212+
*texture generation
200213
for handcrafted mesh**.
201214

202215
### Gradio App
203216

204217
You could also host a [Gradio](https://www.gradio.app/) App in your own computer via:
205218

219+
Standard Version
220+
221+
```bash
222+
# Hunyuan3D-2mini
223+
python3 gradio_app.py --model_path tencent/Hunyuan3D-2mini --subfolder hunyuan3d-dit-v2-mini --texgen_model_path tencent/Hunyuan3D-2 --low_vram_mode
224+
# Hunyuan3D-2mv
225+
python3 gradio_app.py --model_path tencent/Hunyuan3D-2mv --subfolder hunyuan3d-dit-v2-mv --texgen_model_path tencent/Hunyuan3D-2 --low_vram_mode
226+
# Hunyuan3D-2
227+
python3 gradio_app.py --model_path tencent/Hunyuan3D-2 --subfolder hunyuan3d-dit-v2-0 --texgen_model_path tencent/Hunyuan3D-2 --low_vram_mode
228+
```
229+
230+
Turbo Version
231+
206232
```bash
207233
# Hunyuan3D-2mini
208-
python3 gradio_app.py --model_path tencent/Hunyuan3D-2mini --subfolder hunyuan3d-dit-v2-mini --texgen_model_path tencent/Hunyuan3D-2
234+
python3 gradio_app.py --model_path tencent/Hunyuan3D-2mini --subfolder hunyuan3d-dit-v2-mini-turbo --texgen_model_path tencent/Hunyuan3D-2 --low_vram_mode --enable_flashvdm
209235
# Hunyuan3D-2mv
210-
python3 gradio_app.py --model_path tencent/Hunyuan3D-2mv --subfolder hunyuan3d-dit-v2-mv --texgen_model_path tencent/Hunyuan3D-2
236+
python3 gradio_app.py --model_path tencent/Hunyuan3D-2mv --subfolder hunyuan3d-dit-v2-mv-turbo --texgen_model_path tencent/Hunyuan3D-2 --low_vram_mode --enable_flashvdm
211237
# Hunyuan3D-2
212-
python3 gradio_app.py --model_path tencent/Hunyuan3D-2 --subfolder hunyuan3d-dit-v2-0 --texgen_model_path tencent/Hunyuan3D-2
238+
python3 gradio_app.py --model_path tencent/Hunyuan3D-2 --subfolder hunyuan3d-dit-v2-0-turbo --texgen_model_path tencent/Hunyuan3D-2 --low_vram_mode --enable_flashvdm
213239
```
214240

215241
### API Server

api_server.py

+60-17
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
# Hunyuan 3D is licensed under the TENCENT HUNYUAN NON-COMMERCIAL LICENSE AGREEMENT
2+
# except for the third-party components listed below.
3+
# Hunyuan 3D does not impose any additional limitations beyond what is outlined
4+
# in the repsective licenses of these third-party components.
5+
# Users must comply with all terms and conditions of original licenses of these third-party
6+
# components and must ensure that the usage of the third party components adheres to
7+
# all relevant laws and regulations.
8+
9+
# For avoidance of doubts, Hunyuan 3D means the large language models and
10+
# their software and algorithms, including trained model weights, parameters (including
11+
# optimizer states), machine-learning model code, inference-enabling code, training-enabling code,
12+
# fine-tuning enabling code and other elements of the foregoing made publicly available
13+
# by Tencent in accordance with TENCENT HUNYUAN COMMUNITY LICENSE AGREEMENT.
14+
115
"""
216
A model worker executes the model.
317
"""
@@ -22,7 +36,8 @@
2236
from fastapi.responses import JSONResponse, FileResponse
2337

2438
from hy3dgen.rembg import BackgroundRemover
25-
from hy3dgen.shapegen import Hunyuan3DDiTFlowMatchingPipeline, FloaterRemover, DegenerateFaceRemover, FaceReducer
39+
from hy3dgen.shapegen import Hunyuan3DDiTFlowMatchingPipeline, FloaterRemover, DegenerateFaceRemover, FaceReducer, \
40+
MeshSimplifier
2641
from hy3dgen.texgen import Hunyuan3DPaintPipeline
2742
from hy3dgen.text2image import HunyuanDiTPipeline
2843

@@ -129,17 +144,31 @@ def load_image_from_base64(image):
129144

130145

131146
class ModelWorker:
132-
def __init__(self, model_path='tencent/Hunyuan3D-2', device='cuda'):
147+
def __init__(self,
148+
model_path='tencent/Hunyuan3D-2mini',
149+
tex_model_path='tencent/Hunyuan3D-2',
150+
subfolder='hunyuan3d-dit-v2-mini-turbo',
151+
device='cuda',
152+
enable_tex=False):
133153
self.model_path = model_path
134154
self.worker_id = worker_id
135155
self.device = device
136156
logger.info(f"Loading the model {model_path} on worker {worker_id} ...")
137157

138158
self.rembg = BackgroundRemover()
139-
self.pipeline = Hunyuan3DDiTFlowMatchingPipeline.from_pretrained(model_path, device=device)
140-
self.pipeline_t2i = HunyuanDiTPipeline('Tencent-Hunyuan/HunyuanDiT-v1.1-Diffusers-Distilled',
141-
device=device)
142-
self.pipeline_tex = Hunyuan3DPaintPipeline.from_pretrained(model_path)
159+
self.pipeline = Hunyuan3DDiTFlowMatchingPipeline.from_pretrained(
160+
model_path,
161+
subfolder=subfolder,
162+
use_safetensors=True,
163+
device=device,
164+
)
165+
self.pipeline.enable_flashvdm()
166+
# self.pipeline_t2i = HunyuanDiTPipeline(
167+
# 'Tencent-Hunyuan/HunyuanDiT-v1.1-Diffusers-Distilled',
168+
# device=device
169+
# )
170+
if enable_tex:
171+
self.pipeline_tex = Hunyuan3DPaintPipeline.from_pretrained(tex_model_path)
143172

144173
def get_queue_length(self):
145174
if model_semaphore is None:
@@ -174,31 +203,42 @@ def generate(self, uid, params):
174203
else:
175204
seed = params.get("seed", 1234)
176205
params['generator'] = torch.Generator(self.device).manual_seed(seed)
177-
params['octree_resolution'] = params.get("octree_resolution", 256)
178-
params['num_inference_steps'] = params.get("num_inference_steps", 30)
179-
params['guidance_scale'] = params.get('guidance_scale', 7.5)
180-
params['mc_algo'] = 'mc'
206+
params['octree_resolution'] = params.get("octree_resolution", 128)
207+
params['num_inference_steps'] = params.get("num_inference_steps", 5)
208+
params['guidance_scale'] = params.get('guidance_scale', 5.0)
209+
params['mc_algo'] = 'dmc'
210+
import time
211+
start_time = time.time()
181212
mesh = self.pipeline(**params)[0]
213+
logger.info("--- %s seconds ---" % (time.time() - start_time))
182214

183215
if params.get('texture', False):
184216
mesh = FloaterRemover()(mesh)
185217
mesh = DegenerateFaceRemover()(mesh)
186218
mesh = FaceReducer()(mesh, max_facenum=params.get('face_count', 40000))
187219
mesh = self.pipeline_tex(mesh, image)
188220

189-
with tempfile.NamedTemporaryFile(suffix='.glb', delete=False) as temp_file:
221+
type = params.get('type', 'glb')
222+
with tempfile.NamedTemporaryFile(suffix=f'.{type}', delete=True) as temp_file:
190223
mesh.export(temp_file.name)
191224
mesh = trimesh.load(temp_file.name)
192-
temp_file.close()
193-
os.unlink(temp_file.name)
194-
save_path = os.path.join(SAVE_DIR, f'{str(uid)}.glb')
225+
save_path = os.path.join(SAVE_DIR, f'{str(uid)}.{type}')
195226
mesh.export(save_path)
196227

197228
torch.cuda.empty_cache()
198229
return save_path, uid
199230

200231

201232
app = FastAPI()
233+
from fastapi.middleware.cors import CORSMiddleware
234+
235+
app.add_middleware(
236+
CORSMiddleware,
237+
allow_origins=["*"], # 你可以指定允许的来源
238+
allow_credentials=True,
239+
allow_methods=["*"], # 允许所有方法
240+
allow_headers=["*"], # 允许所有头部
241+
)
202242

203243

204244
@app.post("/generate")
@@ -260,14 +300,17 @@ async def status(uid: str):
260300
if __name__ == "__main__":
261301
parser = argparse.ArgumentParser()
262302
parser.add_argument("--host", type=str, default="0.0.0.0")
263-
parser.add_argument("--port", type=int, default=8081)
264-
parser.add_argument("--model_path", type=str, default='tencent/Hunyuan3D-2')
303+
parser.add_argument("--port", type=str, default="8081")
304+
parser.add_argument("--model_path", type=str, default='tencent/Hunyuan3D-2mini')
305+
parser.add_argument("--tex_model_path", type=str, default='tencent/Hunyuan3D-2')
265306
parser.add_argument("--device", type=str, default="cuda")
266307
parser.add_argument("--limit-model-concurrency", type=int, default=5)
308+
parser.add_argument('--enable_tex', action='store_true')
267309
args = parser.parse_args()
268310
logger.info(f"args: {args}")
269311

270312
model_semaphore = asyncio.Semaphore(args.limit_model_concurrency)
271313

272-
worker = ModelWorker(model_path=args.model_path, device=args.device)
314+
worker = ModelWorker(model_path=args.model_path, device=args.device, enable_tex=args.enable_tex,
315+
tex_model_path=args.tex_model_path)
273316
uvicorn.run(app, host=args.host, port=args.port, log_level="info")

blender_addon.py

+14
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
# Hunyuan 3D is licensed under the TENCENT HUNYUAN NON-COMMERCIAL LICENSE AGREEMENT
2+
# except for the third-party components listed below.
3+
# Hunyuan 3D does not impose any additional limitations beyond what is outlined
4+
# in the repsective licenses of these third-party components.
5+
# Users must comply with all terms and conditions of original licenses of these third-party
6+
# components and must ensure that the usage of the third party components adheres to
7+
# all relevant laws and regulations.
8+
9+
# For avoidance of doubts, Hunyuan 3D means the large language models and
10+
# their software and algorithms, including trained model weights, parameters (including
11+
# optimizer states), machine-learning model code, inference-enabling code, training-enabling code,
12+
# fine-tuning enabling code and other elements of the foregoing made publicly available
13+
# by Tencent in accordance with TENCENT HUNYUAN COMMUNITY LICENSE AGREEMENT.
14+
115
bl_info = {
216
"name": "Hunyuan3D-2 Generator",
317
"author": "Tencent Hunyuan3D",

examples/fast_shape_gen_multiview.py

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import time
2+
3+
import torch
4+
from PIL import Image
5+
6+
from hy3dgen.rembg import BackgroundRemover
7+
from hy3dgen.shapegen import Hunyuan3DDiTFlowMatchingPipeline
8+
9+
images = {
10+
"front": "assets/example_mv_images/1/front.png",
11+
"left": "assets/example_mv_images/1/left.png",
12+
"back": "assets/example_mv_images/1/back.png"
13+
}
14+
15+
for key in images:
16+
image = Image.open(images[key]).convert("RGBA")
17+
if image.mode == 'RGB':
18+
rembg = BackgroundRemover()
19+
image = rembg(image)
20+
images[key] = image
21+
22+
pipeline = Hunyuan3DDiTFlowMatchingPipeline.from_pretrained(
23+
'tencent/Hunyuan3D-2mv',
24+
subfolder='hunyuan3d-dit-v2-mv-turbo',
25+
variant='fp16'
26+
)
27+
pipeline.enable_flashvdm()
28+
start_time = time.time()
29+
mesh = pipeline(
30+
image=images,
31+
num_inference_steps=5,
32+
octree_resolution=380,
33+
num_chunks=20000,
34+
generator=torch.manual_seed(12345),
35+
output_type='trimesh'
36+
)[0]
37+
print("--- %s seconds ---" % (time.time() - start_time))
38+
mesh.export(f'demo_mv3.glb')
+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# HY3DGEN_DEBUG=1 USE_SAGEATTN=1 python3 examples/fast_shape_gen_with_flashvdm.py
2+
# HY3DGEN_DEBUG=1 USE_SAGEATTN=0 python3 examples/fast_shape_gen_with_flashvdm.py
3+
4+
import os
5+
import time
6+
7+
import torch
8+
from PIL import Image
9+
10+
from hy3dgen.rembg import BackgroundRemover
11+
from hy3dgen.shapegen import Hunyuan3DDiTFlowMatchingPipeline
12+
13+
pipeline = Hunyuan3DDiTFlowMatchingPipeline.from_pretrained(
14+
'tencent/Hunyuan3D-2',
15+
subfolder='hunyuan3d-dit-v2-0-turbo',
16+
use_safetensors=True,
17+
)
18+
pipeline.enable_flashvdm()
19+
# pipeline.compile()
20+
21+
image_path = 'assets/demo.png'
22+
image = Image.open(image_path).convert("RGBA")
23+
if image.mode == 'RGB':
24+
rembg = BackgroundRemover()
25+
image = rembg(image)
26+
27+
28+
def run():
29+
return pipeline(
30+
image=image,
31+
num_inference_steps=5,
32+
octree_resolution=380,
33+
num_chunks=200000,
34+
generator=torch.manual_seed(12345),
35+
output_type='trimesh'
36+
)[0]
37+
38+
39+
save_dir = 'tmp/results/'
40+
os.makedirs(save_dir, exist_ok=True)
41+
42+
for it in range(2):
43+
start_time = time.time()
44+
mesh = run()
45+
print("--- %s seconds ---" % (time.time() - start_time))
46+
mesh.export(f'{save_dir}/run_{it}.glb')

0 commit comments

Comments
 (0)