Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -72,9 +72,12 @@ async def niji_api(prompt, progress=gr.Progress(), max_retries=5, backoff_factor
|
|
72 |
return None
|
73 |
|
74 |
def download_and_split_image(url):
|
75 |
-
|
76 |
-
|
77 |
-
|
|
|
|
|
|
|
78 |
|
79 |
while prog < 100:
|
80 |
try:
|
@@ -91,13 +94,7 @@ async def niji_api(prompt, progress=gr.Progress(), max_retries=5, backoff_factor
|
|
91 |
prog = data.get('progress', 0)
|
92 |
if progress_image_url := data.get('progressImageUrl'):
|
93 |
iters = -100
|
94 |
-
|
95 |
-
try:
|
96 |
-
result = [(img, f"{prog}% done") for img in download_and_split_image(progress_image_url)]
|
97 |
-
except Exception:
|
98 |
-
pass
|
99 |
-
if result:
|
100 |
-
yield result
|
101 |
|
102 |
wait_time = random.uniform(1, 2)
|
103 |
await asyncio.sleep(wait_time)
|
|
|
72 |
return None
|
73 |
|
74 |
def download_and_split_image(url):
|
75 |
+
try:
|
76 |
+
img = fetch_image(url)
|
77 |
+
images = split_image(img)
|
78 |
+
return [save_image(i) for i in images]
|
79 |
+
except Exception:
|
80 |
+
return [None]*4
|
81 |
|
82 |
while prog < 100:
|
83 |
try:
|
|
|
94 |
prog = data.get('progress', 0)
|
95 |
if progress_image_url := data.get('progressImageUrl'):
|
96 |
iters = -100
|
97 |
+
yield [(img, f"{prog}% done") for img in download_and_split_image(progress_image_url)]
|
|
|
|
|
|
|
|
|
|
|
|
|
98 |
|
99 |
wait_time = random.uniform(1, 2)
|
100 |
await asyncio.sleep(wait_time)
|