Stanislaw Szymanowicz commited on
Commit
f1ccc45
1 Parent(s): 7c56dda

Add video rendering

Browse files
Files changed (2) hide show
  1. app.py +7 -9
  2. requirements.txt +1 -0
app.py CHANGED
@@ -6,8 +6,6 @@ import os
6
  from omegaconf import OmegaConf
7
  from PIL import Image
8
 
9
- import tempfile
10
-
11
  from utils.app_utils import (
12
  remove_background,
13
  resize_foreground,
@@ -21,7 +19,7 @@ from utils.app_utils import (
21
  import imageio
22
 
23
  from scene.gaussian_predictor import GaussianSplatPredictor
24
- # from gaussian_renderer import render_predicted
25
 
26
  import gradio as gr
27
 
@@ -33,9 +31,9 @@ def main():
33
 
34
  if torch.cuda.is_available():
35
  device = "cuda:0"
 
36
  else:
37
  device = "cpu"
38
- # torch.cuda.set_device(device)
39
 
40
  model_cfg = OmegaConf.load(
41
  os.path.join(
@@ -92,7 +90,7 @@ def main():
92
  None,
93
  activate_output=False)
94
 
95
- """reconstruction = {k: v[0].contiguous() for k, v in reconstruction_unactivated.items()}
96
  reconstruction["scaling"] = model.scaling_activation(reconstruction["scaling"])
97
  reconstruction["opacity"] = model.opacity_activation(reconstruction["opacity"])
98
 
@@ -112,11 +110,11 @@ def main():
112
  image = t_to_512(image)
113
  loop_renders.append(torch.clamp(image * 255, 0.0, 255.0).detach().permute(1, 2, 0).cpu().numpy().astype(np.uint8))
114
  loop_out_path = os.path.join(os.path.dirname(ply_out_path), "loop.mp4")
115
- imageio.mimsave(loop_out_path, loop_renders, fps=25)"""
116
  # export reconstruction to ply
117
  export_to_obj(reconstruction_unactivated, ply_out_path)
118
 
119
- return ply_out_path
120
 
121
  with gr.Blocks() as demo:
122
  gr.Markdown(
@@ -158,7 +156,7 @@ def main():
158
  with gr.Row():
159
  with gr.Tab("Reconstruction"):
160
  with gr.Column():
161
- # output_video = gr.Video(value=None, width=512, label="Rendered Video", autoplay=True)
162
  output_model = gr.Model3D(
163
  height=512,
164
  label="Output Model",
@@ -172,7 +170,7 @@ def main():
172
  ).success(
173
  fn=reconstruct_and_export,
174
  inputs=[processed_image],
175
- outputs=[output_model],
176
  )
177
 
178
  demo.queue(max_size=1)
 
6
  from omegaconf import OmegaConf
7
  from PIL import Image
8
 
 
 
9
  from utils.app_utils import (
10
  remove_background,
11
  resize_foreground,
 
19
  import imageio
20
 
21
  from scene.gaussian_predictor import GaussianSplatPredictor
22
+ from gaussian_renderer import render_predicted
23
 
24
  import gradio as gr
25
 
 
31
 
32
  if torch.cuda.is_available():
33
  device = "cuda:0"
34
+ torch.cuda.set_device(device)
35
  else:
36
  device = "cpu"
 
37
 
38
  model_cfg = OmegaConf.load(
39
  os.path.join(
 
90
  None,
91
  activate_output=False)
92
 
93
+ reconstruction = {k: v[0].contiguous() for k, v in reconstruction_unactivated.items()}
94
  reconstruction["scaling"] = model.scaling_activation(reconstruction["scaling"])
95
  reconstruction["opacity"] = model.opacity_activation(reconstruction["opacity"])
96
 
 
110
  image = t_to_512(image)
111
  loop_renders.append(torch.clamp(image * 255, 0.0, 255.0).detach().permute(1, 2, 0).cpu().numpy().astype(np.uint8))
112
  loop_out_path = os.path.join(os.path.dirname(ply_out_path), "loop.mp4")
113
+ imageio.mimsave(loop_out_path, loop_renders, fps=25)
114
  # export reconstruction to ply
115
  export_to_obj(reconstruction_unactivated, ply_out_path)
116
 
117
+ return ply_out_path, loop_out_path
118
 
119
  with gr.Blocks() as demo:
120
  gr.Markdown(
 
156
  with gr.Row():
157
  with gr.Tab("Reconstruction"):
158
  with gr.Column():
159
+ output_video = gr.Video(value=None, width=512, label="Rendered Video", autoplay=True)
160
  output_model = gr.Model3D(
161
  height=512,
162
  label="Output Model",
 
170
  ).success(
171
  fn=reconstruct_and_export,
172
  inputs=[processed_image],
173
+ outputs=[output_model, output_video],
174
  )
175
 
176
  demo.queue(max_size=1)
requirements.txt CHANGED
@@ -8,3 +8,4 @@ moviepy
8
  markupsafe==2.0.1
9
  gradio==4.25.0
10
  rembg
 
 
8
  markupsafe==2.0.1
9
  gradio==4.25.0
10
  rembg
11
+ git+https://github.com/graphdeco-inria/diff-gaussian-rasterization