akameswa commited on
Commit
cc285aa
1 Parent(s): 76d8871

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -3
app.py CHANGED
@@ -25,7 +25,8 @@ def infer(prompt, seed=42, randomize_seed=False, width=1024, height=1024, guidan
25
  if randomize_seed:
26
  seed = random.randint(0, MAX_SEED)
27
  generator = torch.Generator().manual_seed(seed)
28
-
 
29
  for img in pipe.flux_pipe_call_that_returns_an_iterable_of_images(
30
  prompt=prompt,
31
  guidance_scale=guidance_scale,
@@ -36,8 +37,10 @@ def infer(prompt, seed=42, randomize_seed=False, width=1024, height=1024, guidan
36
  output_type="pil",
37
  good_vae=good_vae,
38
  ):
 
 
39
  yield img, seed
40
-
41
  examples = [
42
  "a tiny astronaut hatching from an egg on the moon",
43
  "a cat holding a sign that says hello world",
@@ -72,6 +75,7 @@ with gr.Blocks(css=css) as demo:
72
  run_button = gr.Button("Run", scale=0)
73
 
74
  result = gr.Image(label="Result", show_label=False)
 
75
 
76
  with gr.Accordion("Advanced Settings", open=False):
77
 
@@ -128,7 +132,6 @@ with gr.Blocks(css=css) as demo:
128
  outputs = [result, seed],
129
  cache_examples="lazy"
130
  )
131
-
132
  gr.on(
133
  triggers=[run_button.click, prompt.submit],
134
  fn = infer,
 
25
  if randomize_seed:
26
  seed = random.randint(0, MAX_SEED)
27
  generator = torch.Generator().manual_seed(seed)
28
+
29
+ imgs = []
30
  for img in pipe.flux_pipe_call_that_returns_an_iterable_of_images(
31
  prompt=prompt,
32
  guidance_scale=guidance_scale,
 
37
  output_type="pil",
38
  good_vae=good_vae,
39
  ):
40
+ imgs.append(img)
41
+ imgs[0].save("output.gif", save_all=True, append_images=images[1:], duration=500, loop=0)
42
  yield img, seed
43
+
44
  examples = [
45
  "a tiny astronaut hatching from an egg on the moon",
46
  "a cat holding a sign that says hello world",
 
75
  run_button = gr.Button("Run", scale=0)
76
 
77
  result = gr.Image(label="Result", show_label=False)
78
+ gif = gr.Image(label="GIF")
79
 
80
  with gr.Accordion("Advanced Settings", open=False):
81
 
 
132
  outputs = [result, seed],
133
  cache_examples="lazy"
134
  )
 
135
  gr.on(
136
  triggers=[run_button.click, prompt.submit],
137
  fn = infer,