wjmcat commited on
Commit
0027f9c
1 Parent(s): b8b09f2

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -3
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
- new_content = content.decode(encoding='utf-8')
22
- if new_content.startswith("error: "):
23
- return []
 
 
 
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)