Spaces:
Runtime error
Runtime error
chenjian
commited on
Commit
•
12a84e4
1
Parent(s):
637aa41
add status bar for error tips
Browse files
app.py
CHANGED
@@ -4,12 +4,16 @@ import paddlehub as hub
|
|
4 |
|
5 |
|
6 |
model = hub.Module(name='ernie_vilg')
|
7 |
-
|
8 |
-
|
9 |
def inference(text_prompts, style):
|
10 |
-
|
11 |
-
|
12 |
-
|
|
|
|
|
|
|
|
|
|
|
13 |
|
14 |
|
15 |
title="ERNIE-ViLG"
|
@@ -163,16 +167,19 @@ with block:
|
|
163 |
gallery = gr.Gallery(
|
164 |
label="Generated images", show_label=False, elem_id="gallery"
|
165 |
).style(grid=[2, 3], height="auto")
|
|
|
|
|
|
|
|
|
|
|
|
|
166 |
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
ex = gr.Examples(examples=examples, fn=inference, inputs=[text, styles], outputs=gallery, cache_examples=False)
|
171 |
ex.dataset.headers = [""]
|
172 |
|
173 |
|
174 |
-
text.submit(inference, inputs=[text, styles], outputs=gallery)
|
175 |
-
btn.click(inference, inputs=[text, styles], outputs=gallery)
|
176 |
gr.HTML(
|
177 |
"""
|
178 |
<div class="prompt">
|
|
|
4 |
|
5 |
|
6 |
model = hub.Module(name='ernie_vilg')
|
7 |
+
|
|
|
8 |
def inference(text_prompts, style):
|
9 |
+
try:
|
10 |
+
results = model.generate_image(
|
11 |
+
text_prompts=text_prompts, style=style, visualization=False)
|
12 |
+
return 'Success', results[:6]
|
13 |
+
except Exception as e:
|
14 |
+
error_text = str(e)
|
15 |
+
return error_text, None
|
16 |
+
return
|
17 |
|
18 |
|
19 |
title="ERNIE-ViLG"
|
|
|
167 |
gallery = gr.Gallery(
|
168 |
label="Generated images", show_label=False, elem_id="gallery"
|
169 |
).style(grid=[2, 3], height="auto")
|
170 |
+
status_text = gr.Textbox(
|
171 |
+
label="Process status",
|
172 |
+
show_label=True,
|
173 |
+
max_lines=1,
|
174 |
+
interactive=False
|
175 |
+
)
|
176 |
|
|
|
|
|
|
|
177 |
ex = gr.Examples(examples=examples, fn=inference, inputs=[text, styles], outputs=gallery, cache_examples=False)
|
178 |
ex.dataset.headers = [""]
|
179 |
|
180 |
|
181 |
+
text.submit(inference, inputs=[text, styles], outputs=[status_text, gallery])
|
182 |
+
btn.click(inference, inputs=[text, styles], outputs=[status_text, gallery])
|
183 |
gr.HTML(
|
184 |
"""
|
185 |
<div class="prompt">
|