Spaces:
Paused
Paused
lixiang46
commited on
Commit
·
5d19a11
1
Parent(s):
4aa1288
add warning'
Browse files
app.py
CHANGED
|
@@ -12,6 +12,7 @@ import time
|
|
| 12 |
def tryon(person_img, garment_img, seed, randomize_seed):
|
| 13 |
post_start_time = time.time()
|
| 14 |
if person_img is None or garment_img is None:
|
|
|
|
| 15 |
return None, None, "Empty image"
|
| 16 |
if randomize_seed:
|
| 17 |
seed = random.randint(0, MAX_SEED)
|
|
@@ -69,13 +70,15 @@ def tryon(person_img, garment_img, seed, randomize_seed):
|
|
| 69 |
elif status == "error":
|
| 70 |
err_log = f"Status is Error"
|
| 71 |
info = "Error"
|
|
|
|
| 72 |
else:
|
| 73 |
# print(response.text)
|
| 74 |
err_log = "URL error, pleace contact the admin"
|
| 75 |
info = "URL error, pleace contact the admin"
|
|
|
|
| 76 |
except requests.exceptions.ReadTimeout:
|
| 77 |
err_log = "Http Timeout"
|
| 78 |
-
info = "
|
| 79 |
except Exception as err:
|
| 80 |
err_log = f"Get Exception Error: {err}"
|
| 81 |
time.sleep(1)
|
|
@@ -87,7 +90,7 @@ def tryon(person_img, garment_img, seed, randomize_seed):
|
|
| 87 |
info = "Too many users, please try again later"
|
| 88 |
if info != "Success":
|
| 89 |
print(f"Error Log: {err_log}")
|
| 90 |
-
|
| 91 |
|
| 92 |
return result_img, seed, info
|
| 93 |
|
|
|
|
| 12 |
def tryon(person_img, garment_img, seed, randomize_seed):
|
| 13 |
post_start_time = time.time()
|
| 14 |
if person_img is None or garment_img is None:
|
| 15 |
+
gr.Warning("Empty image")
|
| 16 |
return None, None, "Empty image"
|
| 17 |
if randomize_seed:
|
| 18 |
seed = random.randint(0, MAX_SEED)
|
|
|
|
| 70 |
elif status == "error":
|
| 71 |
err_log = f"Status is Error"
|
| 72 |
info = "Error"
|
| 73 |
+
break
|
| 74 |
else:
|
| 75 |
# print(response.text)
|
| 76 |
err_log = "URL error, pleace contact the admin"
|
| 77 |
info = "URL error, pleace contact the admin"
|
| 78 |
+
break
|
| 79 |
except requests.exceptions.ReadTimeout:
|
| 80 |
err_log = "Http Timeout"
|
| 81 |
+
info = "Http Timeout, please try again later"
|
| 82 |
except Exception as err:
|
| 83 |
err_log = f"Get Exception Error: {err}"
|
| 84 |
time.sleep(1)
|
|
|
|
| 90 |
info = "Too many users, please try again later"
|
| 91 |
if info != "Success":
|
| 92 |
print(f"Error Log: {err_log}")
|
| 93 |
+
gr.Warning("Too many users, please try again later")
|
| 94 |
|
| 95 |
return result_img, seed, info
|
| 96 |
|