arabago96 commited on
Commit
3d4a512
·
1 Parent(s): bdc0279

Restore UNLOCKED render config: r=2, fov=36, forest.exr HDRI, exact render_utils.py

Browse files
Files changed (2) hide show
  1. app.py +2 -2
  2. trellis2/utils/render_utils.py +2 -4
app.py CHANGED
@@ -173,7 +173,7 @@ def image_to_3d(
173
  mesh.simplify(16777216) # nvdiffrast limit
174
 
175
  # --- Render Video Preview (8 seconds at 10fps = 80 frames, transparent WebM) ---
176
- render_result = render_utils.render_video(mesh, num_frames=80, resolution=720, r=2, fov=40, envmap=envmap, verbose=False)
177
  shaded_frames = render_result['shaded'] # RGB
178
  alpha_frames = render_result['alpha'] # Grayscale alpha
179
 
@@ -184,7 +184,7 @@ def image_to_3d(
184
  rgba_frames.append(rgba)
185
 
186
  video_path = os.path.join(user_dir, 'sample.webm')
187
- imageio.mimsave(video_path, rgba_frames, fps=10, codec='libvpx-vp9', output_params=['-pix_fmt', 'yuva420p'])
188
 
189
  state = pack_state(latents)
190
 
 
173
  mesh.simplify(16777216) # nvdiffrast limit
174
 
175
  # --- Render Video Preview (8 seconds at 10fps = 80 frames, transparent WebM) ---
176
+ render_result = render_utils.render_video(mesh, num_frames=80, resolution=720, r=2, fov=36, envmap=envmap, verbose=False)
177
  shaded_frames = render_result['shaded'] # RGB
178
  alpha_frames = render_result['alpha'] # Grayscale alpha
179
 
 
184
  rgba_frames.append(rgba)
185
 
186
  video_path = os.path.join(user_dir, 'sample.webm')
187
+ imageio.mimsave(video_path, rgba_frames, fps=10, codec='libvpx-vp9', output_params=['-pix_fmt', 'yuva420p', '-b:v', '2M'])
188
 
189
  state = pack_state(latents)
190
 
trellis2/utils/render_utils.py CHANGED
@@ -78,10 +78,8 @@ def render_frames(sample, extrinsics, intrinsics, options={}, verbose=True, **kw
78
 
79
 
80
  def render_video(sample, resolution=1024, bg_color=(0, 0, 0), num_frames=120, r=2, fov=40, **kwargs):
81
- # Start at 135 degrees (45 + 90 more) and rotate from there
82
- start_angle = 3.1415 * 3 / 4 # 135 degrees in radians (45 + 90)
83
- yaws = torch.linspace(start_angle, 2 * 3.1415 + start_angle, num_frames) # Full rotation starting from 135 degrees
84
- pitch = torch.tensor([0.34] * num_frames) # Higher pitch for proper isometric view
85
  yaws = yaws.tolist()
86
  pitch = pitch.tolist()
87
  extrinsics, intrinsics = yaw_pitch_r_fov_to_extrinsics_intrinsics(yaws, pitch, r, fov)
 
78
 
79
 
80
  def render_video(sample, resolution=1024, bg_color=(0, 0, 0), num_frames=120, r=2, fov=40, **kwargs):
81
+ yaws = -torch.linspace(0, 2 * 3.1415, num_frames) + np.pi/2
82
+ pitch = 0.25 + 0.5 * torch.sin(torch.linspace(0, 2 * 3.1415, num_frames))
 
 
83
  yaws = yaws.tolist()
84
  pitch = pitch.tolist()
85
  extrinsics, intrinsics = yaw_pitch_r_fov_to_extrinsics_intrinsics(yaws, pitch, r, fov)