Spaces:
Running
on
Zero
Running
on
Zero
fix: Add color render
Browse files
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
|