Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
lixiang46
commited on
Commit
•
a079d6c
1
Parent(s):
2240654
add log info
Browse files
app.py
CHANGED
@@ -32,15 +32,15 @@ def tryon(person_img, garment_img, seed, randomize_seed):
|
|
32 |
}
|
33 |
try:
|
34 |
response = requests.post(url, headers=headers, data=json.dumps(data), timeout=50)
|
35 |
-
print("post response code", response.status_code)
|
36 |
if response.status_code == 200:
|
37 |
result = response.json()['result']
|
38 |
status = result['status']
|
39 |
if status == "success":
|
40 |
uuid = result['result']
|
41 |
-
print(uuid)
|
42 |
except Exception as err:
|
43 |
-
print(f"Error: {err}")
|
44 |
raise gr.Error("Too many users, please try again later")
|
45 |
post_end_time = time.time()
|
46 |
print(f"post time used: {post_end_time-post_start_time}")
|
@@ -49,11 +49,12 @@ def tryon(person_img, garment_img, seed, randomize_seed):
|
|
49 |
time.sleep(9)
|
50 |
Max_Retry = 10
|
51 |
result_img = None
|
|
|
52 |
for i in range(Max_Retry):
|
53 |
try:
|
54 |
url = "http://" + os.environ['tryon_url'] + "Query?taskId=" + uuid
|
55 |
response = requests.get(url, headers=headers, timeout=15)
|
56 |
-
print("get response code", response.status_code)
|
57 |
if response.status_code == 200:
|
58 |
result = response.json()['result']
|
59 |
status = result['status']
|
@@ -65,18 +66,23 @@ def tryon(person_img, garment_img, seed, randomize_seed):
|
|
65 |
info = "Success"
|
66 |
break
|
67 |
elif status == "error":
|
|
|
68 |
raise gr.Error("Too many users, please try again later")
|
69 |
else:
|
70 |
print(response.text)
|
71 |
info = "URL error, pleace contact the admin"
|
72 |
except requests.exceptions.ReadTimeout:
|
73 |
-
print("
|
74 |
info = "Too many users, please try again later"
|
75 |
except Exception as err:
|
76 |
-
print(f"Error: {err}")
|
77 |
time.sleep(1)
|
78 |
get_end_time = time.time()
|
79 |
print(f"get time used: {get_end_time-get_start_time}")
|
|
|
|
|
|
|
|
|
80 |
|
81 |
return result_img, seed, info
|
82 |
|
|
|
32 |
}
|
33 |
try:
|
34 |
response = requests.post(url, headers=headers, data=json.dumps(data), timeout=50)
|
35 |
+
# print("post response code", response.status_code)
|
36 |
if response.status_code == 200:
|
37 |
result = response.json()['result']
|
38 |
status = result['status']
|
39 |
if status == "success":
|
40 |
uuid = result['result']
|
41 |
+
# print(uuid)
|
42 |
except Exception as err:
|
43 |
+
print(f"Post Exception Error: {err}")
|
44 |
raise gr.Error("Too many users, please try again later")
|
45 |
post_end_time = time.time()
|
46 |
print(f"post time used: {post_end_time-post_start_time}")
|
|
|
49 |
time.sleep(9)
|
50 |
Max_Retry = 10
|
51 |
result_img = None
|
52 |
+
info = ""
|
53 |
for i in range(Max_Retry):
|
54 |
try:
|
55 |
url = "http://" + os.environ['tryon_url'] + "Query?taskId=" + uuid
|
56 |
response = requests.get(url, headers=headers, timeout=15)
|
57 |
+
# print("get response code", response.status_code)
|
58 |
if response.status_code == 200:
|
59 |
result = response.json()['result']
|
60 |
status = result['status']
|
|
|
66 |
info = "Success"
|
67 |
break
|
68 |
elif status == "error":
|
69 |
+
print(f"Status is Error")
|
70 |
raise gr.Error("Too many users, please try again later")
|
71 |
else:
|
72 |
print(response.text)
|
73 |
info = "URL error, pleace contact the admin"
|
74 |
except requests.exceptions.ReadTimeout:
|
75 |
+
print("Http Timeout")
|
76 |
info = "Too many users, please try again later"
|
77 |
except Exception as err:
|
78 |
+
print(f"Get Exception Error: {err}")
|
79 |
time.sleep(1)
|
80 |
get_end_time = time.time()
|
81 |
print(f"get time used: {get_end_time-get_start_time}")
|
82 |
+
print(f"all time used: {get_end_time-get_start_time+post_end_time-post_start_time}")
|
83 |
+
if info == "":
|
84 |
+
print(f"No image after {Max_Retry} retries")
|
85 |
+
info = "Too many users, please try again later"
|
86 |
|
87 |
return result_img, seed, info
|
88 |
|