Spaces:
Runtime error
Runtime error
Upload app.py
Browse files
app.py
CHANGED
@@ -18,9 +18,12 @@ def gen_image(prompt: str):
|
|
18 |
url = f"https://aip.baidubce.com/rpc/2.0/nlp-itec/poc/chinese_stable_diffusion?access_token={access_token}"
|
19 |
|
20 |
content = requests.post(url, json={"text": prompt}).content
|
21 |
-
|
22 |
-
|
23 |
-
|
|
|
|
|
|
|
24 |
|
25 |
cache_dir = 'images'
|
26 |
os.makedirs(cache_dir, exist_ok=True)
|
|
|
18 |
url = f"https://aip.baidubce.com/rpc/2.0/nlp-itec/poc/chinese_stable_diffusion?access_token={access_token}"
|
19 |
|
20 |
content = requests.post(url, json={"text": prompt}).content
|
21 |
+
try:
|
22 |
+
new_content = content.decode(encoding='utf-8')
|
23 |
+
if new_content.startswith("error: "):
|
24 |
+
return []
|
25 |
+
except:
|
26 |
+
pass
|
27 |
|
28 |
cache_dir = 'images'
|
29 |
os.makedirs(cache_dir, exist_ok=True)
|