Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -38,10 +38,15 @@ def infer(prompt, seed=42, randomize_seed=False, width=1024, height=1024, guidan
|
|
38 |
good_vae=good_vae,
|
39 |
):
|
40 |
images.append(img)
|
|
|
41 |
|
42 |
images[0].save("output.gif", save_all=True, append_images=images[1:], duration=500, loop=0)
|
43 |
-
|
44 |
-
|
|
|
|
|
|
|
|
|
45 |
examples = [
|
46 |
"a tiny astronaut hatching from an egg on the moon",
|
47 |
"a cat holding a sign that says hello world",
|
@@ -76,6 +81,8 @@ with gr.Blocks(css=css) as demo:
|
|
76 |
run_button = gr.Button("Run", scale=0)
|
77 |
|
78 |
result = gr.Image(label="Result", show_label=False)
|
|
|
|
|
79 |
gif = gr.Image(label="GIF")
|
80 |
|
81 |
with gr.Accordion("Advanced Settings", open=False):
|
@@ -133,11 +140,19 @@ with gr.Blocks(css=css) as demo:
|
|
133 |
outputs = [result, seed],
|
134 |
cache_examples="lazy"
|
135 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
136 |
gr.on(
|
137 |
triggers=[run_button.click, prompt.submit],
|
138 |
fn = infer,
|
139 |
inputs = [prompt, seed, randomize_seed, width, height, guidance_scale, num_inference_steps],
|
140 |
-
outputs = [result, seed
|
141 |
)
|
|
|
142 |
|
143 |
demo.launch()
|
|
|
38 |
good_vae=good_vae,
|
39 |
):
|
40 |
images.append(img)
|
41 |
+
yield images[-1], seed
|
42 |
|
43 |
images[0].save("output.gif", save_all=True, append_images=images[1:], duration=500, loop=0)
|
44 |
+
print("GIF saved!")
|
45 |
+
|
46 |
+
@spaces.GPU()
|
47 |
+
def show_gif_function():
|
48 |
+
return "output.gif"
|
49 |
+
|
50 |
examples = [
|
51 |
"a tiny astronaut hatching from an egg on the moon",
|
52 |
"a cat holding a sign that says hello world",
|
|
|
81 |
run_button = gr.Button("Run", scale=0)
|
82 |
|
83 |
result = gr.Image(label="Result", show_label=False)
|
84 |
+
|
85 |
+
gif_button = gr.Button("Show GIF")
|
86 |
gif = gr.Image(label="GIF")
|
87 |
|
88 |
with gr.Accordion("Advanced Settings", open=False):
|
|
|
140 |
outputs = [result, seed],
|
141 |
cache_examples="lazy"
|
142 |
)
|
143 |
+
|
144 |
+
gif_button.click(
|
145 |
+
fn=show_gif_function,
|
146 |
+
inputs=[],
|
147 |
+
outputs=[gif]
|
148 |
+
)
|
149 |
+
|
150 |
gr.on(
|
151 |
triggers=[run_button.click, prompt.submit],
|
152 |
fn = infer,
|
153 |
inputs = [prompt, seed, randomize_seed, width, height, guidance_scale, num_inference_steps],
|
154 |
+
outputs = [result, seed]
|
155 |
)
|
156 |
+
|
157 |
|
158 |
demo.launch()
|