-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Expand file tree
/
Copy pathshape_gen.py
More file actions
30 lines (25 loc) · 822 Bytes
/
shape_gen.py
File metadata and controls
30 lines (25 loc) · 822 Bytes
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
import time
import torch
from PIL import Image
from hy3dgen.rembg import BackgroundRemover
from hy3dgen.shapegen import Hunyuan3DDiTFlowMatchingPipeline
image_path = 'assets/demo.png'
image = Image.open(image_path).convert("RGBA")
if image.mode == 'RGB':
rembg = BackgroundRemover()
image = rembg(image)
pipeline = Hunyuan3DDiTFlowMatchingPipeline.from_pretrained(
'tencent/Hunyuan3D-2',
subfolder='hunyuan3d-dit-v2-0',
variant='fp16'
)
start_time = time.time()
mesh = pipeline(image=image,
num_inference_steps=50,
octree_resolution=380,
num_chunks=20000,
generator=torch.manual_seed(12345),
output_type='trimesh'
)[0]
print("--- %s seconds ---" % (time.time() - start_time))
mesh.export(f'demo.glb')