Spaces:
Runtime error
Runtime error
add examples and cache examples (#5)
Browse files- add examples and cache examples (e758278056673576783caa82fb36ba32993dd99a)
Co-authored-by: Ahsen Khaliq <[email protected]>
app.py
CHANGED
|
@@ -133,6 +133,16 @@ css = """
|
|
| 133 |
}
|
| 134 |
"""
|
| 135 |
block = gr.Blocks(css=css)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 136 |
with block as demo:
|
| 137 |
gr.HTML(
|
| 138 |
"""
|
|
@@ -175,6 +185,10 @@ with block as demo:
|
|
| 175 |
gallery = gr.Gallery(label="Generated images", show_label=False, elem_id="generated_id").style(
|
| 176 |
grid=[2], height="auto"
|
| 177 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 178 |
text.submit(infer, inputs=[text], outputs=gallery)
|
| 179 |
btn.click(infer, inputs=[text], outputs=gallery)
|
| 180 |
|
|
|
|
| 133 |
}
|
| 134 |
"""
|
| 135 |
block = gr.Blocks(css=css)
|
| 136 |
+
|
| 137 |
+
examples = [
|
| 138 |
+
[
|
| 139 |
+
'Goku'
|
| 140 |
+
],
|
| 141 |
+
[
|
| 142 |
+
'Mikasa Ackerman'
|
| 143 |
+
],
|
| 144 |
+
]
|
| 145 |
+
|
| 146 |
with block as demo:
|
| 147 |
gr.HTML(
|
| 148 |
"""
|
|
|
|
| 185 |
gallery = gr.Gallery(label="Generated images", show_label=False, elem_id="generated_id").style(
|
| 186 |
grid=[2], height="auto"
|
| 187 |
)
|
| 188 |
+
|
| 189 |
+
ex = gr.Examples(examples=examples, fn=infer, inputs=[text], outputs=gallery, cache_examples=True)
|
| 190 |
+
ex.dataset.headers = [""]
|
| 191 |
+
|
| 192 |
text.submit(infer, inputs=[text], outputs=gallery)
|
| 193 |
btn.click(infer, inputs=[text], outputs=gallery)
|
| 194 |
|