Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -31,16 +31,19 @@ def check_for_mp4_in_outputs(given_folder):
|
|
31 |
return None
|
32 |
|
33 |
|
34 |
-
def infer():
|
35 |
|
36 |
-
filepath =
|
37 |
# Get the current timestamp
|
38 |
timestamp = datetime.datetime.now().strftime("%Y%m%d%H%M%S")
|
39 |
|
40 |
output_folder_name = f"results_{timestamp}"
|
41 |
|
42 |
-
|
43 |
-
|
|
|
|
|
|
|
44 |
|
45 |
# Call the function and print the result
|
46 |
this_infer_folder = os.path.splitext(os.path.basename(filepath))[0]
|
@@ -52,19 +55,43 @@ def infer():
|
|
52 |
|
53 |
return mp4_file_path
|
54 |
|
|
|
|
|
55 |
with gr.Blocks() as demo:
|
56 |
with gr.Column():
|
57 |
gr.Markdown("# KEEP")
|
|
|
58 |
with gr.Row():
|
59 |
with gr.Column():
|
|
|
|
|
60 |
submit_btn = gr.Button("Submit")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
61 |
with gr.Column():
|
62 |
-
|
|
|
63 |
|
64 |
submit_btn.click(
|
65 |
fn = infer,
|
66 |
-
inputs =
|
67 |
-
outputs = [
|
68 |
show_api=False
|
69 |
)
|
70 |
|
|
|
31 |
return None
|
32 |
|
33 |
|
34 |
+
def infer(input_video, cropped_and_aligned):
|
35 |
|
36 |
+
filepath = input_video
|
37 |
# Get the current timestamp
|
38 |
timestamp = datetime.datetime.now().strftime("%Y%m%d%H%M%S")
|
39 |
|
40 |
output_folder_name = f"results_{timestamp}"
|
41 |
|
42 |
+
if cropped_and_aligned is True:
|
43 |
+
# Example: Run the inference script (replace with your actual command)
|
44 |
+
run_command(f"{sys.executable} inference_keep.py -i={filepath} -o={output_folder_name} --has_aligned --save_video -s=1")
|
45 |
+
else:
|
46 |
+
run_command(f"{sys.executable} inference_keep.py -i={filepath} -o={output_folder_name} --draw_box --save_video -s=1 --bg_upsampler=realesrgan")
|
47 |
|
48 |
# Call the function and print the result
|
49 |
this_infer_folder = os.path.splitext(os.path.basename(filepath))[0]
|
|
|
55 |
|
56 |
return mp4_file_path
|
57 |
|
58 |
+
|
59 |
+
result_video = gr.Video()
|
60 |
with gr.Blocks() as demo:
|
61 |
with gr.Column():
|
62 |
gr.Markdown("# KEEP")
|
63 |
+
gr.Markdown("## Kalman-Inspired Feature Propagation for Video Face Super-Resolution")
|
64 |
with gr.Row():
|
65 |
with gr.Column():
|
66 |
+
input_video = gr.Video(label="Input Video")
|
67 |
+
is_cropped_and_aligned = gr.Checkbox(label="Synthetic data", info="Is your input video ready with cropped and aligned faces ?", value=False)
|
68 |
submit_btn = gr.Button("Submit")
|
69 |
+
gr.Examples(
|
70 |
+
examples = [
|
71 |
+
["./assets/examples/synthetic_1.mp4", True],
|
72 |
+
["./assets/examples/synthetic_2.mp4", True],
|
73 |
+
["./assets/examples/synthetic_3.mp4", True],
|
74 |
+
["./assets/examples/synthetic_4.mp4", True],
|
75 |
+
["./assets/examples/real_1.mp4", False],
|
76 |
+
["./assets/examples/real_2.mp4", False],
|
77 |
+
["./assets/examples/real_3.mp4", False],
|
78 |
+
["./assets/examples/real_4.mp4", False]
|
79 |
+
],
|
80 |
+
fn = infer,
|
81 |
+
inputs = [input_video, is_cropped_and_aligned],
|
82 |
+
outputs = [result_video],
|
83 |
+
run_on_click = False,
|
84 |
+
cache_examples = False
|
85 |
+
)
|
86 |
+
|
87 |
with gr.Column():
|
88 |
+
result_video.render()
|
89 |
+
|
90 |
|
91 |
submit_btn.click(
|
92 |
fn = infer,
|
93 |
+
inputs = [input_video, is_cropped_and_aligned],
|
94 |
+
outputs = [result_video],
|
95 |
show_api=False
|
96 |
)
|
97 |
|