Update app.py
Browse files
app.py
CHANGED
@@ -9,7 +9,11 @@ client = Client(
|
|
9 |
hf_token=HF_TOKEN,
|
10 |
)
|
11 |
|
|
|
|
|
|
|
12 |
def virtual_tryon(person_path, garment_path, garment_type):
|
|
|
13 |
person_file = handle_file(person_path)
|
14 |
garment_file = handle_file(garment_path)
|
15 |
|
@@ -25,24 +29,13 @@ def virtual_tryon(person_path, garment_path, garment_type):
|
|
25 |
vt_repaint=False,
|
26 |
api_name="/leffa_predict_vt",
|
27 |
)
|
28 |
-
|
|
|
|
|
|
|
|
|
29 |
|
30 |
-
with gr.Blocks(theme=gr.themes.Soft()
|
31 |
-
#image-container { position: relative; display: inline-block; }
|
32 |
-
#download-button {
|
33 |
-
position: absolute;
|
34 |
-
top: 10px;
|
35 |
-
left: 50%;
|
36 |
-
transform: translateX(-50%);
|
37 |
-
z-index: 10;
|
38 |
-
background-color: rgba(0, 0, 0, 0.6);
|
39 |
-
color: white;
|
40 |
-
padding: 10px 16px;
|
41 |
-
border-radius: 6px;
|
42 |
-
border: none;
|
43 |
-
cursor: pointer;
|
44 |
-
}
|
45 |
-
""") as demo:
|
46 |
gr.Markdown("")
|
47 |
with gr.Row():
|
48 |
with gr.Column():
|
@@ -62,12 +55,12 @@ with gr.Blocks(theme=gr.themes.Soft(), css="""
|
|
62 |
)
|
63 |
with gr.Column():
|
64 |
gr.Markdown("")
|
65 |
-
|
66 |
-
download_btn = gr.File(label="Shkarko", elem_id="download-button", visible=False)
|
67 |
-
out = gr.Image(type="filepath", label="Rezultati")
|
68 |
btn = gr.Button("VISHU")
|
|
|
69 |
|
70 |
-
btn.click(virtual_tryon, [src, ref, garment_type], [out,
|
|
|
71 |
|
72 |
demo.launch(
|
73 |
share=True,
|
|
|
9 |
hf_token=HF_TOKEN,
|
10 |
)
|
11 |
|
12 |
+
# To store the last result path
|
13 |
+
result_path = ""
|
14 |
+
|
15 |
def virtual_tryon(person_path, garment_path, garment_type):
|
16 |
+
global result_path
|
17 |
person_file = handle_file(person_path)
|
18 |
garment_file = handle_file(garment_path)
|
19 |
|
|
|
29 |
vt_repaint=False,
|
30 |
api_name="/leffa_predict_vt",
|
31 |
)
|
32 |
+
result_path = result[0]
|
33 |
+
return result_path, gr.update(visible=True)
|
34 |
+
|
35 |
+
def download_image():
|
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():
|
|
|
55 |
)
|
56 |
with gr.Column():
|
57 |
gr.Markdown("")
|
58 |
+
out = gr.Image(type="filepath", label="Rezultati")
|
|
|
|
|
59 |
btn = gr.Button("VISHU")
|
60 |
+
download_trigger = gr.Button("Shkarko", visible=False)
|
61 |
|
62 |
+
btn.click(virtual_tryon, [src, ref, garment_type], [out, download_trigger])
|
63 |
+
download_trigger.click(download_image, outputs=gr.File())
|
64 |
|
65 |
demo.launch(
|
66 |
share=True,
|