Spaces:
Running
on
Zero
Running
on
Zero
pablovela5620
commited on
Commit
•
e7307fa
1
Parent(s):
4438f2e
Upload gradio_app.py with huggingface_hub
Browse files- gradio_app.py +45 -37
gradio_app.py
CHANGED
@@ -286,39 +286,47 @@ def gradio_warped_image(
|
|
286 |
yield stream.read(), video_file_path, [str(zip_file_path)], "finished"
|
287 |
|
288 |
|
|
|
|
|
|
|
|
|
|
|
289 |
with gr.Blocks() as demo:
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
|
|
|
|
|
|
322 |
|
323 |
# Rerun 0.16 has issues when embedded in a Gradio tab, so we share a viewer between all the tabs.
|
324 |
# In 0.17 we can instead scope each viewer to its own tab to clean up these examples further.
|
@@ -334,12 +342,12 @@ with gr.Blocks() as demo:
|
|
334 |
outputs=[viewer, video_output, image_files_output, iteration_num],
|
335 |
)
|
336 |
|
|
|
|
|
|
|
|
|
337 |
gr.Examples(
|
338 |
-
|
339 |
-
[
|
340 |
-
"examples/000001.jpg",
|
341 |
-
],
|
342 |
-
],
|
343 |
fn=warp_img_btn,
|
344 |
inputs=[img, num_iters, cam_direction, degrees_per_frame],
|
345 |
outputs=[viewer, video_output, image_files_output],
|
|
|
286 |
yield stream.read(), video_file_path, [str(zip_file_path)], "finished"
|
287 |
|
288 |
|
289 |
+
title = "# Mini NVS Solver"
|
290 |
+
description1 = """### Demo showcasing [NVS-Solver: Video Diffusion Model as Zero-Shot Novel View Synthesizer](https://github.com/ZHU-Zhiyu/NVS_Solver)"""
|
291 |
+
description2 = """### Checkout the Mini NVS Solver Repo [![GitHub Repo stars](https://img.shields.io/github/stars/pablovela5620/mini-nvs-solver)](https://github.com/pablovela5620/mini-nvs-solver)"""
|
292 |
+
description3 = """### HIGHLY RECOMMNEDED to run this demo locally through the github repo to avoid GPU abort due to long running time"""
|
293 |
+
|
294 |
with gr.Blocks() as demo:
|
295 |
+
gr.Markdown(title)
|
296 |
+
gr.Markdown(description1)
|
297 |
+
gr.Markdown(description2)
|
298 |
+
gr.Markdown(description3)
|
299 |
+
with gr.Row():
|
300 |
+
img = gr.Image(interactive=True, label="Image", type="filepath")
|
301 |
+
with gr.Tab(label="Settings"):
|
302 |
+
with gr.Column():
|
303 |
+
warp_img_btn = gr.Button("Run NVS Solver")
|
304 |
+
num_iters = gr.Radio(
|
305 |
+
choices=[2, 25, 50, 100],
|
306 |
+
value=2,
|
307 |
+
label="Number of iterations",
|
308 |
+
type="value",
|
309 |
+
)
|
310 |
+
cam_direction = gr.Radio(
|
311 |
+
choices=["left", "right"],
|
312 |
+
value="left",
|
313 |
+
label="Camera direction",
|
314 |
+
type="value",
|
315 |
+
)
|
316 |
+
degrees_per_frame = gr.Slider(
|
317 |
+
minimum=0.25,
|
318 |
+
maximum=1.0,
|
319 |
+
step=0.05,
|
320 |
+
value=0.3,
|
321 |
+
label="Degrees per frame",
|
322 |
+
)
|
323 |
+
iteration_num = gr.Textbox(
|
324 |
+
value="",
|
325 |
+
label="Status",
|
326 |
+
)
|
327 |
+
with gr.Tab(label="Outputs"):
|
328 |
+
video_output = gr.Video(interactive=False)
|
329 |
+
image_files_output = gr.File(interactive=False, file_count="multiple")
|
330 |
|
331 |
# Rerun 0.16 has issues when embedded in a Gradio tab, so we share a viewer between all the tabs.
|
332 |
# In 0.17 we can instead scope each viewer to its own tab to clean up these examples further.
|
|
|
342 |
outputs=[viewer, video_output, image_files_output, iteration_num],
|
343 |
)
|
344 |
|
345 |
+
examples_paths = Path("examples").glob("*.jpg")
|
346 |
+
# set the examples to be the sorted list of input parameterss (path, remove_flying_pixels, depth_map_threshold)
|
347 |
+
examples_list = sorted([[str(path)] for path in examples_paths])
|
348 |
+
|
349 |
gr.Examples(
|
350 |
+
examples_list,
|
|
|
|
|
|
|
|
|
351 |
fn=warp_img_btn,
|
352 |
inputs=[img, num_iters, cam_direction, degrees_per_frame],
|
353 |
outputs=[viewer, video_output, image_files_output],
|