Update app.py
Browse files
app.py
CHANGED
@@ -9,7 +9,7 @@ client = Client(
|
|
9 |
hf_token=HF_TOKEN,
|
10 |
)
|
11 |
|
12 |
-
#
|
13 |
result_path = ""
|
14 |
|
15 |
def virtual_tryon(person_path, garment_path, garment_type):
|
@@ -30,22 +30,19 @@ def virtual_tryon(person_path, garment_path, garment_type):
|
|
30 |
api_name="/leffa_predict_vt",
|
31 |
)
|
32 |
result_path = result[0]
|
33 |
-
return result_path, gr.update(visible=True)
|
34 |
|
35 |
-
def
|
36 |
-
return result_path
|
37 |
|
38 |
with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
39 |
gr.Markdown("")
|
40 |
with gr.Row():
|
41 |
with gr.Column():
|
42 |
-
gr.Markdown("")
|
43 |
src = gr.Image(sources="upload", type="filepath", label="Foto e personit")
|
44 |
with gr.Column():
|
45 |
-
gr.Markdown("")
|
46 |
ref = gr.Image(sources="upload", type="filepath", label="Foto e veshjes")
|
47 |
with gr.Column():
|
48 |
-
gr.Markdown("")
|
49 |
garment_type = gr.Radio(
|
50 |
choices=[("Siper", "upper_body"),
|
51 |
("Posht", "lower_body"),
|
@@ -54,13 +51,13 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
54 |
label="Lloji i veshjes",
|
55 |
)
|
56 |
with gr.Column():
|
57 |
-
gr.Markdown("")
|
58 |
-
out = gr.Image(type="filepath", label="Rezultati")
|
59 |
btn = gr.Button("VISHU")
|
60 |
-
|
|
|
|
|
61 |
|
62 |
-
btn.click(virtual_tryon, [src, ref, garment_type], [out,
|
63 |
-
|
64 |
|
65 |
demo.launch(
|
66 |
share=True,
|
|
|
9 |
hf_token=HF_TOKEN,
|
10 |
)
|
11 |
|
12 |
+
# Variable to hold result path
|
13 |
result_path = ""
|
14 |
|
15 |
def virtual_tryon(person_path, garment_path, garment_type):
|
|
|
30 |
api_name="/leffa_predict_vt",
|
31 |
)
|
32 |
result_path = result[0]
|
33 |
+
return result_path, gr.update(visible=True), gr.update(visible=False)
|
34 |
|
35 |
+
def trigger_download():
|
36 |
+
return gr.update(value=result_path, visible=True)
|
37 |
|
38 |
with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
39 |
gr.Markdown("")
|
40 |
with gr.Row():
|
41 |
with gr.Column():
|
|
|
42 |
src = gr.Image(sources="upload", type="filepath", label="Foto e personit")
|
43 |
with gr.Column():
|
|
|
44 |
ref = gr.Image(sources="upload", type="filepath", label="Foto e veshjes")
|
45 |
with gr.Column():
|
|
|
46 |
garment_type = gr.Radio(
|
47 |
choices=[("Siper", "upper_body"),
|
48 |
("Posht", "lower_body"),
|
|
|
51 |
label="Lloji i veshjes",
|
52 |
)
|
53 |
with gr.Column():
|
|
|
|
|
54 |
btn = gr.Button("VISHU")
|
55 |
+
shkarko_btn = gr.Button("SHKARKO", visible=False)
|
56 |
+
downloadable = gr.File(visible=False)
|
57 |
+
out = gr.Image(type="filepath", label="Rezultati")
|
58 |
|
59 |
+
btn.click(virtual_tryon, [src, ref, garment_type], [out, shkarko_btn, downloadable])
|
60 |
+
shkarko_btn.click(trigger_download, outputs=downloadable)
|
61 |
|
62 |
demo.launch(
|
63 |
share=True,
|