Spaces:
Runtime error
Runtime error
Upload app.py
Browse files
app.py
CHANGED
@@ -18,6 +18,9 @@ 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 |
cache_dir = 'images'
|
23 |
os.makedirs(cache_dir, exist_ok=True)
|
@@ -46,8 +49,10 @@ examples = [
|
|
46 |
'厚涂层油画《悲伤男孩的特写肖像》,本·科迪,希卡里·希莫达'
|
47 |
]
|
48 |
|
|
|
49 |
with block:
|
50 |
gr.HTML(read_content("header.html"))
|
|
|
51 |
gr.Markdown("[![Stargazers repo roster for @PaddlePaddle/PaddleNLP](https://reporoster.com/stars/PaddlePaddle/PaddleNLP)](https://github.com/PaddlePaddle/PaddleNLP)")
|
52 |
with gr.Group():
|
53 |
with gr.Box():
|
|
|
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)
|
|
|
49 |
'厚涂层油画《悲伤男孩的特写肖像》,本·科迪,希卡里·希莫达'
|
50 |
]
|
51 |
|
52 |
+
|
53 |
with block:
|
54 |
gr.HTML(read_content("header.html"))
|
55 |
+
gr.Markdown("> warning", elem_id='warning', visible=False)
|
56 |
gr.Markdown("[![Stargazers repo roster for @PaddlePaddle/PaddleNLP](https://reporoster.com/stars/PaddlePaddle/PaddleNLP)](https://github.com/PaddlePaddle/PaddleNLP)")
|
57 |
with gr.Group():
|
58 |
with gr.Box():
|