Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,6 +1,63 @@
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
|
3 |
-
|
4 |
-
|
|
|
5 |
|
6 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import subprocess
|
3 |
import gradio as gr
|
4 |
|
5 |
+
# execute a CLI command
|
6 |
+
def execute_command(command: str) -> None:
|
7 |
+
subprocess.run(command, check=True)
|
8 |
|
9 |
+
|
10 |
+
def infer(video_frames, masks_frames):
|
11 |
+
|
12 |
+
video_frames_folder = "inputs/object_removal/bmx-trees"
|
13 |
+
masks_folder = "inputs/object_removal/bmx-trees_mask"
|
14 |
+
|
15 |
+
# Create the "results" folder if it doesn't exist
|
16 |
+
output_folder = "results"
|
17 |
+
if not os.path.exists(results_folder):
|
18 |
+
os.makedirs(results_folder)
|
19 |
+
|
20 |
+
command = [
|
21 |
+
f"python",
|
22 |
+
f"inference_propainter.py",
|
23 |
+
f"--video={video_frames_folder}",
|
24 |
+
f"--mask={masks_folder}",
|
25 |
+
f"--output={output_folder}"
|
26 |
+
]
|
27 |
+
|
28 |
+
execute_command(command)
|
29 |
+
|
30 |
+
return "done"
|
31 |
+
|
32 |
+
css="""
|
33 |
+
#col-container{
|
34 |
+
margin: 0 auto;
|
35 |
+
max-width: 840px;
|
36 |
+
text-align: left;
|
37 |
+
}
|
38 |
+
"""
|
39 |
+
|
40 |
+
with gr.Blocks(css=css) as demo:
|
41 |
+
with gr.Column(elem_id="col-container"):
|
42 |
+
gr.HTML("""
|
43 |
+
<h2 style="text-align: center;">ProPainter</h2>
|
44 |
+
<p style="text-align: center;">
|
45 |
+
|
46 |
+
</p>
|
47 |
+
""")
|
48 |
+
|
49 |
+
with gr.Row():
|
50 |
+
with gr.Column():
|
51 |
+
video_frames = gr.Files(label="Video frames")
|
52 |
+
masks_frames = gr.Files(label="Masks frames")
|
53 |
+
|
54 |
+
submit_btn = gr.Button("Submit")
|
55 |
+
|
56 |
+
with gr.Column():
|
57 |
+
result = gr.Textbox(label="Result")
|
58 |
+
|
59 |
+
|
60 |
+
|
61 |
+
submit_btn.click(fn=infer, inputs=[video_frames, masks_frames], outputs=[result])
|
62 |
+
|
63 |
+
demo.queue(max_size=12).launch()
|