Spaces:
Running
on
A10G
Running
on
A10G
Fix examples inference
#2
by
mishig
HF staff
- opened
app.py
CHANGED
@@ -158,6 +158,19 @@ def infer(text):
|
|
158 |
for i, image in enumerate(images_list["sample"]):
|
159 |
output_images.append(image)
|
160 |
return output_images, gr.update(visible=True), gr.update(visible=True), gr.update(visible=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
161 |
|
162 |
css = '''
|
163 |
.gradio-container {font-family: 'IBM Plex Sans', sans-serif}
|
@@ -207,10 +220,6 @@ css = '''
|
|
207 |
'''
|
208 |
examples = ["a <cat-toy> in <madhubani-art> style", "a <line-art> style mecha robot", "a piano being played by <bonzi>", "Candid photo of <cheburashka>, high resolution photo, trending on artstation, interior design"]
|
209 |
|
210 |
-
community_icon = gr.HTML(community_icon_html, visible=False)
|
211 |
-
loading_icon = gr.HTML(loading_icon_html, visible=False)
|
212 |
-
share_button = gr.Button("Share to community", elem_id="share-btn", visible=False)
|
213 |
-
|
214 |
with gr.Blocks(css=css) as demo:
|
215 |
state = gr.Variable({
|
216 |
'selected': -1
|
@@ -308,7 +317,7 @@ with gr.Blocks(css=css) as demo:
|
|
308 |
with gr.Row():
|
309 |
gr.HTML("<p style=\"font-size: 95%;margin-top: .75em\">Prompting may not work as you are used to. <code>objects</code> may need the concept added at the end, <code>styles</code> may work better at the beginning. You can navigate on <a href='https://lexica.art'>lexica.art</a> to get inspired on prompts</p>")
|
310 |
with gr.Row():
|
311 |
-
gr.Examples(examples=examples, fn=
|
312 |
with gr.Group(elem_id="share-btn-container"):
|
313 |
community_icon = gr.HTML(community_icon_html, visible=False)
|
314 |
loading_icon = gr.HTML(loading_icon_html, visible=False)
|
|
|
158 |
for i, image in enumerate(images_list["sample"]):
|
159 |
output_images.append(image)
|
160 |
return output_images, gr.update(visible=True), gr.update(visible=True), gr.update(visible=True)
|
161 |
+
|
162 |
+
# idetnical to `infer` function without gradio state updates for share btn
|
163 |
+
def infer_examples(text):
|
164 |
+
with autocast("cuda"):
|
165 |
+
images_list = pipe(
|
166 |
+
[text]*2,
|
167 |
+
num_inference_steps=50,
|
168 |
+
guidance_scale=7.5
|
169 |
+
)
|
170 |
+
output_images = []
|
171 |
+
for i, image in enumerate(images_list["sample"]):
|
172 |
+
output_images.append(image)
|
173 |
+
return output_images
|
174 |
|
175 |
css = '''
|
176 |
.gradio-container {font-family: 'IBM Plex Sans', sans-serif}
|
|
|
220 |
'''
|
221 |
examples = ["a <cat-toy> in <madhubani-art> style", "a <line-art> style mecha robot", "a piano being played by <bonzi>", "Candid photo of <cheburashka>, high resolution photo, trending on artstation, interior design"]
|
222 |
|
|
|
|
|
|
|
|
|
223 |
with gr.Blocks(css=css) as demo:
|
224 |
state = gr.Variable({
|
225 |
'selected': -1
|
|
|
317 |
with gr.Row():
|
318 |
gr.HTML("<p style=\"font-size: 95%;margin-top: .75em\">Prompting may not work as you are used to. <code>objects</code> may need the concept added at the end, <code>styles</code> may work better at the beginning. You can navigate on <a href='https://lexica.art'>lexica.art</a> to get inspired on prompts</p>")
|
319 |
with gr.Row():
|
320 |
+
gr.Examples(examples=examples, fn=infer_examples, inputs=[text], outputs=infer_outputs, cache_examples=True)
|
321 |
with gr.Group(elem_id="share-btn-container"):
|
322 |
community_icon = gr.HTML(community_icon_html, visible=False)
|
323 |
loading_icon = gr.HTML(loading_icon_html, visible=False)
|