Update app.py
Browse files
app.py
CHANGED
@@ -65,37 +65,27 @@ predictor = Predictor()
|
|
65 |
|
66 |
with gr.Blocks(title="Face Swap & Enhance") as demo:
|
67 |
gr.Markdown("## Face Swap & Enhancement Tool")
|
68 |
-
|
69 |
with gr.Row():
|
70 |
input_img = gr.Image(type="file", label="Foto tjeter")
|
71 |
swap_img = gr.Image(type="file", label="Foto e juaj")
|
72 |
|
73 |
with gr.Row():
|
74 |
-
output_img = gr.Image(type="filepath", label="Rezultati")
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
download_btn = gr.Button("Shkarko", visible=False)
|
79 |
-
hidden_file = gr.File(visible=False)
|
80 |
|
81 |
def predict_and_update_ui(img1, img2):
|
82 |
result = predictor.predict(img1, img2)
|
83 |
if result:
|
84 |
-
return result, gr.update(visible=True), gr.update(
|
85 |
else:
|
86 |
-
return None, gr.update(visible=False), gr.update(
|
87 |
|
88 |
submit_btn.click(
|
89 |
fn=predict_and_update_ui,
|
90 |
inputs=[input_img, swap_img],
|
91 |
-
outputs=[output_img, download_btn,
|
92 |
-
)
|
93 |
-
|
94 |
-
# Make download button trigger download of the hidden file
|
95 |
-
download_btn.click(
|
96 |
-
fn=lambda f: f,
|
97 |
-
inputs=[hidden_file],
|
98 |
-
outputs=[hidden_file]
|
99 |
)
|
100 |
|
101 |
-
demo.launch()
|
|
|
65 |
|
66 |
with gr.Blocks(title="Face Swap & Enhance") as demo:
|
67 |
gr.Markdown("## Face Swap & Enhancement Tool")
|
|
|
68 |
with gr.Row():
|
69 |
input_img = gr.Image(type="file", label="Foto tjeter")
|
70 |
swap_img = gr.Image(type="file", label="Foto e juaj")
|
71 |
|
72 |
with gr.Row():
|
73 |
+
output_img = gr.Image(type="filepath", label="Rezultati", visible=False)
|
74 |
+
download_btn = gr.File(label="Shkarko", visible=False)
|
75 |
+
|
76 |
+
submit_btn = gr.Button("Përpunoni")
|
|
|
|
|
77 |
|
78 |
def predict_and_update_ui(img1, img2):
|
79 |
result = predictor.predict(img1, img2)
|
80 |
if result:
|
81 |
+
return result, result, gr.update(visible=True), gr.update(visible=True)
|
82 |
else:
|
83 |
+
return None, None, gr.update(visible=False), gr.update(visible=False)
|
84 |
|
85 |
submit_btn.click(
|
86 |
fn=predict_and_update_ui,
|
87 |
inputs=[input_img, swap_img],
|
88 |
+
outputs=[output_img, download_btn, output_img, download_btn]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
89 |
)
|
90 |
|
91 |
+
demo.launch()
|