Spaces:
Running
on
Zero
Running
on
Zero
Merge branch 'main' of https://huggingface.co/spaces/Stable-X/Hi3DGen
Browse files- README.md +3 -3
- requirements.txt +6 -5
- trellis/renderers/mesh_renderer.py +1 -1
- trellis/representations/mesh/cube2mesh.py +2 -1
- trellis/utils/render_utils.py +16 -6
README.md
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
---
|
2 |
-
title:
|
3 |
emoji: 🏢
|
4 |
colorFrom: indigo
|
5 |
colorTo: blue
|
@@ -8,9 +8,9 @@ sdk_version: 4.44.1
|
|
8 |
app_file: app.py
|
9 |
pinned: false
|
10 |
license: mit
|
11 |
-
short_description:
|
12 |
---
|
13 |
|
14 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
15 |
|
16 |
-
Paper:
|
|
|
1 |
---
|
2 |
+
title: Hi3DGen
|
3 |
emoji: 🏢
|
4 |
colorFrom: indigo
|
5 |
colorTo: blue
|
|
|
8 |
app_file: app.py
|
9 |
pinned: false
|
10 |
license: mit
|
11 |
+
short_description: High-fidelity 3D Geometry Generation from images
|
12 |
---
|
13 |
|
14 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
15 |
|
16 |
+
Paper:
|
requirements.txt
CHANGED
@@ -1,9 +1,10 @@
|
|
1 |
--extra-index-url https://download.pytorch.org/whl/cu121
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
|
|
7 |
torch==2.4.0
|
8 |
torchvision==0.19.0
|
9 |
pillow==10.4.0
|
|
|
1 |
--extra-index-url https://download.pytorch.org/whl/cu121
|
2 |
+
huggingface_hub==0.25.0
|
3 |
+
diffusers==0.28.0
|
4 |
+
accelerate==1.2.1
|
5 |
+
kornia==0.8.0
|
6 |
+
timm==0.6.7
|
7 |
+
|
8 |
torch==2.4.0
|
9 |
torchvision==0.19.0
|
10 |
pillow==10.4.0
|
trellis/renderers/mesh_renderer.py
CHANGED
@@ -64,7 +64,7 @@ class MeshRenderer:
|
|
64 |
mesh : MeshExtractResult,
|
65 |
extrinsics: torch.Tensor,
|
66 |
intrinsics: torch.Tensor,
|
67 |
-
return_types = ["mask", "normal", "depth"]
|
68 |
) -> edict:
|
69 |
"""
|
70 |
Render the mesh.
|
|
|
64 |
mesh : MeshExtractResult,
|
65 |
extrinsics: torch.Tensor,
|
66 |
intrinsics: torch.Tensor,
|
67 |
+
return_types = ["mask", "normal", "depth", "color"]
|
68 |
) -> edict:
|
69 |
"""
|
70 |
Render the mesh.
|
trellis/representations/mesh/cube2mesh.py
CHANGED
@@ -10,7 +10,8 @@ from ...modules.sparse import SparseTensor
|
|
10 |
from easydict import EasyDict as edict
|
11 |
from .utils_cube import *
|
12 |
from .flexicube import FlexiCubes
|
13 |
-
|
|
|
14 |
|
15 |
class MeshExtractResult:
|
16 |
def __init__(self,
|
|
|
10 |
from easydict import EasyDict as edict
|
11 |
from .utils_cube import *
|
12 |
from .flexicube import FlexiCubes
|
13 |
+
import numpy as np
|
14 |
+
import trimesh
|
15 |
|
16 |
class MeshExtractResult:
|
17 |
def __init__(self,
|
trellis/utils/render_utils.py
CHANGED
@@ -83,18 +83,28 @@ def render_frames(sample, extrinsics, intrinsics, options={}, colors_overwrite=N
|
|
83 |
else:
|
84 |
res = renderer.render(sample, extr, intr)
|
85 |
if 'normal' not in rets: rets['normal'] = []
|
|
|
|
|
86 |
rets['normal'].append(np.clip(res['normal'].detach().cpu().numpy().transpose(1, 2, 0) * 255, 0, 255).astype(np.uint8))
|
87 |
return rets
|
88 |
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
93 |
yaws = yaws.tolist()
|
94 |
pitch = pitch.tolist()
|
95 |
extrinsics, intrinsics = yaw_pitch_r_fov_to_extrinsics_intrinsics(yaws, pitch, r, fov)
|
96 |
-
|
97 |
-
|
|
|
|
|
98 |
|
99 |
def render_multiview(sample, resolution=512, nviews=30):
|
100 |
r = 2
|
|
|
83 |
else:
|
84 |
res = renderer.render(sample, extr, intr)
|
85 |
if 'normal' not in rets: rets['normal'] = []
|
86 |
+
if 'color' not in rets: rets['color'] = []
|
87 |
+
rets['color'].append(np.clip(res['color'].detach().cpu().numpy().transpose(1, 2, 0) * 255, 0, 255).astype(np.uint8))
|
88 |
rets['normal'].append(np.clip(res['normal'].detach().cpu().numpy().transpose(1, 2, 0) * 255, 0, 255).astype(np.uint8))
|
89 |
return rets
|
90 |
|
91 |
+
def render_video(sample, resolution=512, ssaa=4, bg_color=(0, 0, 0), num_frames=300, r=2, fov=40,
|
92 |
+
inverse_direction=False, pitch=-1, device="cuda", **kwargs):
|
93 |
+
if inverse_direction:
|
94 |
+
yaws = torch.linspace(3.1415, -3.1415, num_frames)
|
95 |
+
else:
|
96 |
+
yaws = torch.linspace(0, 2 * 3.1415, num_frames)
|
97 |
+
if pitch != -1:
|
98 |
+
pitch = pitch * torch.ones(num_frames)
|
99 |
+
else:
|
100 |
+
pitch = 0.25 + 0.5 * torch.sin(torch.linspace(0, 2 * 3.1415, num_frames))
|
101 |
yaws = yaws.tolist()
|
102 |
pitch = pitch.tolist()
|
103 |
extrinsics, intrinsics = yaw_pitch_r_fov_to_extrinsics_intrinsics(yaws, pitch, r, fov)
|
104 |
+
|
105 |
+
res = render_frames(sample, extrinsics, intrinsics, {'resolution': resolution, 'bg_color': bg_color, 'ssaa': ssaa}, device=device, **kwargs)
|
106 |
+
res.update({'extrinsics': extrinsics, 'intrinsics': intrinsics})
|
107 |
+
return res
|
108 |
|
109 |
def render_multiview(sample, resolution=512, nviews=30):
|
110 |
r = 2
|