Jeff850 commited on
Commit
fbf34fa
·
verified ·
1 Parent(s): 5a741b0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -6
app.py CHANGED
@@ -30,6 +30,7 @@ def infer(
30
  height=1024,
31
  guidance_scale=3,
32
  num_inference_steps=20,
 
33
  progress=gr.Progress(track_tqdm=True),
34
  ):
35
  if randomize_seed:
@@ -37,7 +38,7 @@ def infer(
37
 
38
  generator = torch.Generator().manual_seed(seed)
39
 
40
- image = pipe(
41
  prompt=prompt,
42
  negative_prompt=negative_prompt,
43
  guidance_scale=guidance_scale,
@@ -45,10 +46,10 @@ def infer(
45
  width=width,
46
  height=height,
47
  generator=generator,
48
- ).images[0]
49
-
50
- return image, seed
51
 
 
52
 
53
  examples = [
54
  "A capybara wearing a suit holding a sign that reads Hello World",
@@ -63,7 +64,7 @@ css = """
63
 
64
  with gr.Blocks(css=css) as demo:
65
  with gr.Column(elem_id="col-container"):
66
- gr.Markdown(" # [Stable Diffusion 3.5 Medium Turbo")
67
  with gr.Row():
68
  prompt = gr.Text(
69
  label="Prompt",
@@ -75,7 +76,7 @@ with gr.Blocks(css=css) as demo:
75
 
76
  run_button = gr.Button("Run", scale=0, variant="primary")
77
 
78
- result = gr.Image(label="Result", show_label=False)
79
 
80
  with gr.Accordion("Advanced Settings", open=False):
81
  negative_prompt = gr.Text(
@@ -129,6 +130,14 @@ with gr.Blocks(css=css) as demo:
129
  value=20,
130
  )
131
 
 
 
 
 
 
 
 
 
132
  gr.Examples(examples=examples, inputs=[prompt], outputs=[result, seed], fn=infer, cache_examples=True, cache_mode="lazy")
133
  gr.on(
134
  triggers=[run_button.click, prompt.submit],
@@ -142,6 +151,7 @@ with gr.Blocks(css=css) as demo:
142
  height,
143
  guidance_scale,
144
  num_inference_steps,
 
145
  ],
146
  outputs=[result, seed],
147
  )
 
30
  height=1024,
31
  guidance_scale=3,
32
  num_inference_steps=20,
33
+ num_images=1,
34
  progress=gr.Progress(track_tqdm=True),
35
  ):
36
  if randomize_seed:
 
38
 
39
  generator = torch.Generator().manual_seed(seed)
40
 
41
+ images = pipe(
42
  prompt=prompt,
43
  negative_prompt=negative_prompt,
44
  guidance_scale=guidance_scale,
 
46
  width=width,
47
  height=height,
48
  generator=generator,
49
+ num_images_per_prompt=num_images,
50
+ ).images
 
51
 
52
+ return images, seed
53
 
54
  examples = [
55
  "A capybara wearing a suit holding a sign that reads Hello World",
 
64
 
65
  with gr.Blocks(css=css) as demo:
66
  with gr.Column(elem_id="col-container"):
67
+ gr.Markdown(" # [Stable Diffusion 3.5 Medium Turbo]")
68
  with gr.Row():
69
  prompt = gr.Text(
70
  label="Prompt",
 
76
 
77
  run_button = gr.Button("Run", scale=0, variant="primary")
78
 
79
+ result = gr.Gallery(label="Results").style(grid=[4], preview=True)
80
 
81
  with gr.Accordion("Advanced Settings", open=False):
82
  negative_prompt = gr.Text(
 
130
  value=20,
131
  )
132
 
133
+ num_images = gr.Slider(
134
+ label="Number of Images",
135
+ minimum=1,
136
+ maximum=4,
137
+ step=1,
138
+ value=1,
139
+ )
140
+
141
  gr.Examples(examples=examples, inputs=[prompt], outputs=[result, seed], fn=infer, cache_examples=True, cache_mode="lazy")
142
  gr.on(
143
  triggers=[run_button.click, prompt.submit],
 
151
  height,
152
  guidance_scale,
153
  num_inference_steps,
154
+ num_images,
155
  ],
156
  outputs=[result, seed],
157
  )