forked from Tencent-Hunyuan/Hunyuan3D-2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathminimal_vae_demo.py
More file actions
32 lines (28 loc) · 805 Bytes
/
Copy pathminimal_vae_demo.py
File metadata and controls
32 lines (28 loc) · 805 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
31
32
import torch
from hy3dgen.shapegen.models.autoencoders import ShapeVAE
from hy3dgen.shapegen.surface_loaders import SharpEdgeSurfaceLoader
vae = ShapeVAE.from_pretrained(
'tencent/Hunyuan3D-2mini',
subfolder='hunyuan3d-vae-v2-mini-withencoder',
use_safetensors=False,
)
loader = SharpEdgeSurfaceLoader(
num_sharp_points=5120,
num_uniform_points=5120,
)
surface = loader('demo.glb').to('cuda', dtype=torch.float16)
latents = vae.encode(surface)
latents = vae.decode(latents)
mesh = vae.latents2mesh(
latents,
output_type='trimesh',
bounds=1.01,
mc_level=0.0,
num_chunks=20000,
octree_resolution=256,
mc_algo='mc',
enable_pbar=True
)
from hy3dgen.shapegen.pipelines import export_to_trimesh
mesh = export_to_trimesh(mesh)[0]
mesh.export('output.glb')