Spaces:
Runtime error
Runtime error
lixiang46
commited on
Commit
•
b453f9d
1
Parent(s):
e08a1e8
add result_info
Browse files
app.py
CHANGED
@@ -30,6 +30,7 @@ def start_tryon(person_img, garment_img, seed, randomize_seed):
|
|
30 |
|
31 |
response = requests.post(url, headers=headers, data=json.dumps(data))
|
32 |
print("response code", response.status_code)
|
|
|
33 |
if response.status_code == 200:
|
34 |
result = response.json()['result']
|
35 |
status = result['status']
|
@@ -37,8 +38,13 @@ def start_tryon(person_img, garment_img, seed, randomize_seed):
|
|
37 |
result = base64.b64decode(result['result'])
|
38 |
result_np = np.frombuffer(result, np.uint8)
|
39 |
result_img = cv2.imdecode(result_np, cv2.IMREAD_UNCHANGED)
|
|
|
|
|
|
|
|
|
|
|
40 |
|
41 |
-
return result_img, seed
|
42 |
|
43 |
MAX_SEED = 999999
|
44 |
|
@@ -92,7 +98,9 @@ with gr.Blocks(css=css) as Tryon:
|
|
92 |
examples=garm_list_path)
|
93 |
with gr.Column(elem_id = "col-right"):
|
94 |
image_out = gr.Image(label="Output", show_share_button=False)
|
95 |
-
|
|
|
|
|
96 |
try_button = gr.Button(value="Try-on", elem_id="button")
|
97 |
|
98 |
|
@@ -107,7 +115,7 @@ with gr.Blocks(css=css) as Tryon:
|
|
107 |
)
|
108 |
randomize_seed = gr.Checkbox(label="Randomize seed", value=True)
|
109 |
|
110 |
-
try_button.click(fn=start_tryon, inputs=[imgs, garm_img, seed, randomize_seed], outputs=[image_out, seed_used], api_name='tryon')
|
111 |
|
112 |
ip = requests.get('http://ifconfig.me/ip', timeout=1).text.strip()
|
113 |
print("ip address", ip)
|
|
|
30 |
|
31 |
response = requests.post(url, headers=headers, data=json.dumps(data))
|
32 |
print("response code", response.status_code)
|
33 |
+
result_img = None
|
34 |
if response.status_code == 200:
|
35 |
result = response.json()['result']
|
36 |
status = result['status']
|
|
|
38 |
result = base64.b64decode(result['result'])
|
39 |
result_np = np.frombuffer(result, np.uint8)
|
40 |
result_img = cv2.imdecode(result_np, cv2.IMREAD_UNCHANGED)
|
41 |
+
info = "Success"
|
42 |
+
else:
|
43 |
+
info = "Try again latter"
|
44 |
+
else:
|
45 |
+
info = "URL error"
|
46 |
|
47 |
+
return result_img, seed, info
|
48 |
|
49 |
MAX_SEED = 999999
|
50 |
|
|
|
98 |
examples=garm_list_path)
|
99 |
with gr.Column(elem_id = "col-right"):
|
100 |
image_out = gr.Image(label="Output", show_share_button=False)
|
101 |
+
with gr.Row():
|
102 |
+
seed_used = gr.Number(label="Seed Used")
|
103 |
+
result_info = gr.Text(label="Info")
|
104 |
try_button = gr.Button(value="Try-on", elem_id="button")
|
105 |
|
106 |
|
|
|
115 |
)
|
116 |
randomize_seed = gr.Checkbox(label="Randomize seed", value=True)
|
117 |
|
118 |
+
try_button.click(fn=start_tryon, inputs=[imgs, garm_img, seed, randomize_seed], outputs=[image_out, seed_used, result_info], api_name='tryon')
|
119 |
|
120 |
ip = requests.get('http://ifconfig.me/ip', timeout=1).text.strip()
|
121 |
print("ip address", ip)
|