Spaces:
Running
on
Zero
Running
on
Zero
Stanislaw Szymanowicz
commited on
Commit
•
053a219
1
Parent(s):
3d70c12
Only export model
Browse files- app.py +7 -34
- requirements.txt +1 -2
app.py
CHANGED
@@ -20,7 +20,6 @@ from utils.app_utils import (
|
|
20 |
import imageio
|
21 |
|
22 |
from scene.gaussian_predictor import GaussianSplatPredictor
|
23 |
-
from gaussian_renderer import render_predicted
|
24 |
|
25 |
import gradio as gr
|
26 |
|
@@ -30,11 +29,8 @@ from huggingface_hub import hf_hub_download
|
|
30 |
|
31 |
def main():
|
32 |
|
33 |
-
os.system("sudo find /usr -name nvcc")
|
34 |
-
|
35 |
if torch.cuda.is_available():
|
36 |
device = "cuda:0"
|
37 |
-
print("Found cuda")
|
38 |
else:
|
39 |
device = "cpu"
|
40 |
|
@@ -94,31 +90,10 @@ def main():
|
|
94 |
None,
|
95 |
activate_output=False)
|
96 |
|
97 |
-
reconstruction = {k: v[0].contiguous() for k, v in reconstruction_unactivated.items()}
|
98 |
-
reconstruction["scaling"] = model.scaling_activation(reconstruction["scaling"])
|
99 |
-
reconstruction["opacity"] = model.opacity_activation(reconstruction["opacity"])
|
100 |
-
|
101 |
-
# render images in a loop
|
102 |
-
world_view_transforms, full_proj_transforms, camera_centers = get_target_cameras()
|
103 |
-
background = torch.tensor([1, 1, 1] , dtype=torch.float32, device=device)
|
104 |
-
loop_renders = []
|
105 |
-
t_to_512 = torchvision.transforms.Resize(512, interpolation=torchvision.transforms.InterpolationMode.NEAREST)
|
106 |
-
for r_idx in range( world_view_transforms.shape[0]):
|
107 |
-
image = render_predicted(reconstruction,
|
108 |
-
world_view_transforms[r_idx].to(device),
|
109 |
-
full_proj_transforms[r_idx].to(device),
|
110 |
-
camera_centers[r_idx].to(device),
|
111 |
-
background,
|
112 |
-
model_cfg,
|
113 |
-
focals_pixels=None)["render"]
|
114 |
-
image = t_to_512(image)
|
115 |
-
loop_renders.append(torch.clamp(image * 255, 0.0, 255.0).detach().permute(1, 2, 0).cpu().numpy().astype(np.uint8))
|
116 |
-
loop_out_path = os.path.join(os.path.dirname(ply_out_path), "loop.mp4")
|
117 |
-
imageio.mimsave(loop_out_path, loop_renders, fps=25)
|
118 |
# export reconstruction to ply
|
119 |
export_to_obj(reconstruction_unactivated, ply_out_path)
|
120 |
|
121 |
-
return ply_out_path
|
122 |
|
123 |
with gr.Blocks() as demo:
|
124 |
gr.Markdown(
|
@@ -159,13 +134,11 @@ def main():
|
|
159 |
with gr.Column():
|
160 |
with gr.Row():
|
161 |
with gr.Tab("Reconstruction"):
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
interactive=False
|
168 |
-
)
|
169 |
|
170 |
submit.click(fn=check_input_image, inputs=[input_image]).success(
|
171 |
fn=preprocess,
|
@@ -174,7 +147,7 @@ def main():
|
|
174 |
).success(
|
175 |
fn=reconstruct_and_export,
|
176 |
inputs=[processed_image],
|
177 |
-
outputs=[output_model
|
178 |
)
|
179 |
|
180 |
demo.queue(max_size=1)
|
|
|
20 |
import imageio
|
21 |
|
22 |
from scene.gaussian_predictor import GaussianSplatPredictor
|
|
|
23 |
|
24 |
import gradio as gr
|
25 |
|
|
|
29 |
|
30 |
def main():
|
31 |
|
|
|
|
|
32 |
if torch.cuda.is_available():
|
33 |
device = "cuda:0"
|
|
|
34 |
else:
|
35 |
device = "cpu"
|
36 |
|
|
|
90 |
None,
|
91 |
activate_output=False)
|
92 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
93 |
# export reconstruction to ply
|
94 |
export_to_obj(reconstruction_unactivated, ply_out_path)
|
95 |
|
96 |
+
return ply_out_path
|
97 |
|
98 |
with gr.Blocks() as demo:
|
99 |
gr.Markdown(
|
|
|
134 |
with gr.Column():
|
135 |
with gr.Row():
|
136 |
with gr.Tab("Reconstruction"):
|
137 |
+
output_model = gr.Model3D(
|
138 |
+
height=512,
|
139 |
+
label="Output Model",
|
140 |
+
interactive=False
|
141 |
+
)
|
|
|
|
|
142 |
|
143 |
submit.click(fn=check_input_image, inputs=[input_image]).success(
|
144 |
fn=preprocess,
|
|
|
147 |
).success(
|
148 |
fn=reconstruct_and_export,
|
149 |
inputs=[processed_image],
|
150 |
+
outputs=[output_model],
|
151 |
)
|
152 |
|
153 |
demo.queue(max_size=1)
|
requirements.txt
CHANGED
@@ -8,5 +8,4 @@ moviepy
|
|
8 |
markupsafe==2.0.1
|
9 |
gradio==4.25.0
|
10 |
rembg
|
11 |
-
spaces
|
12 |
-
cuda-python
|
|
|
8 |
markupsafe==2.0.1
|
9 |
gradio==4.25.0
|
10 |
rembg
|
11 |
+
spaces
|
|