-
Notifications
You must be signed in to change notification settings - Fork 769
/
Copy pathfast_shape_gen_with_flashvdm.py
46 lines (36 loc) · 1.13 KB
/
fast_shape_gen_with_flashvdm.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
41
42
43
44
45
46
# HY3DGEN_DEBUG=1 USE_SAGEATTN=1 python3 examples/fast_shape_gen_with_flashvdm.py
# HY3DGEN_DEBUG=1 USE_SAGEATTN=0 python3 examples/fast_shape_gen_with_flashvdm.py
import os
import time
import torch
from PIL import Image
from hy3dgen.rembg import BackgroundRemover
from hy3dgen.shapegen import Hunyuan3DDiTFlowMatchingPipeline
pipeline = Hunyuan3DDiTFlowMatchingPipeline.from_pretrained(
'tencent/Hunyuan3D-2',
subfolder='hunyuan3d-dit-v2-0-turbo',
use_safetensors=True,
)
pipeline.enable_flashvdm()
# pipeline.compile()
image_path = 'assets/demo.png'
image = Image.open(image_path).convert("RGBA")
if image.mode == 'RGB':
rembg = BackgroundRemover()
image = rembg(image)
def run():
return pipeline(
image=image,
num_inference_steps=5,
octree_resolution=380,
num_chunks=200000,
generator=torch.manual_seed(12345),
output_type='trimesh'
)[0]
save_dir = 'tmp/results/'
os.makedirs(save_dir, exist_ok=True)
for it in range(2):
start_time = time.time()
mesh = run()
print("--- %s seconds ---" % (time.time() - start_time))
mesh.export(f'{save_dir}/run_{it}.glb')