Spaces:
vilarin
/
Running on Zero

vilarin commited on
Commit
4515b07
1 Parent(s): 70c3578

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -12
app.py CHANGED
@@ -97,7 +97,8 @@ def generate_image(
97
  scale=5,
98
  steps=30,
99
  strength=0.7,
100
- seed=-1):
 
101
 
102
  if seed == -1:
103
  seed = random.randint(0, MAX_SEED)
@@ -124,6 +125,7 @@ def generate_image(
124
  num_inference_steps=steps,
125
  strength=strength,
126
  generator = generator,
 
127
  )
128
  else:
129
  image = pipe(
@@ -134,8 +136,9 @@ def generate_image(
134
  guidance_scale=scale,
135
  num_inference_steps=steps,
136
  generator = generator,
 
137
  )
138
- return image.images[0]
139
 
140
 
141
  examples = [
@@ -160,9 +163,8 @@ with gr.Blocks(css=CSS, js=JS, theme="soft") as demo:
160
  gr.HTML("<p><center><a href='https://huggingface.co/stabilityai/stable-diffusion-3-medium'>sd3m</a> text/image-to-image generation<br>Update: img2img, add Strength, T5 long Token</center></p>")
161
  with gr.Group():
162
  with gr.Row():
163
- prompt = gr.MultimodalTextbox(label='Enter Your Prompt (Multi-Languages)', interactive=True, placeholder="Enter prompt, add one image.", file_types=['image'], scale=6)
164
- submit = gr.Button(scale=1, variant='primary')
165
- img = gr.Image(label='SD3M Generated Image')
166
  with gr.Accordion("Advanced Options", open=False):
167
  with gr.Row():
168
  negative = gr.Textbox(label="Negative prompt", value="low quality, ugly, blurry, poor face, bad anatomy")
@@ -210,7 +212,14 @@ with gr.Blocks(css=CSS, js=JS, theme="soft") as demo:
210
  maximum=10000000000000,
211
  step=1,
212
  value=-1,
213
- )
 
 
 
 
 
 
 
214
  gr.Examples(
215
  examples=examples,
216
  inputs=prompt,
@@ -221,12 +230,9 @@ with gr.Blocks(css=CSS, js=JS, theme="soft") as demo:
221
  )
222
 
223
  prompt.submit(fn=generate_image,
224
- inputs=[prompt, negative, width, height, scale, steps, strength, seed],
225
- outputs=img,
226
- )
227
- submit.click(fn=generate_image,
228
- inputs=[prompt, negative, width, height, scale, steps, strength, seed],
229
- outputs=img,
230
  )
 
231
 
232
  demo.queue().launch()
 
97
  scale=5,
98
  steps=30,
99
  strength=0.7,
100
+ seed=-1,
101
+ nums=1):
102
 
103
  if seed == -1:
104
  seed = random.randint(0, MAX_SEED)
 
125
  num_inference_steps=steps,
126
  strength=strength,
127
  generator = generator,
128
+ num_images_per_prompt = nums,
129
  )
130
  else:
131
  image = pipe(
 
136
  guidance_scale=scale,
137
  num_inference_steps=steps,
138
  generator = generator,
139
+ num_images_per_prompt = nums,
140
  )
141
+ return image, seed
142
 
143
 
144
  examples = [
 
163
  gr.HTML("<p><center><a href='https://huggingface.co/stabilityai/stable-diffusion-3-medium'>sd3m</a> text/image-to-image generation<br>Update: img2img, add Strength, T5 long Token</center></p>")
164
  with gr.Group():
165
  with gr.Row():
166
+ prompt = gr.MultimodalTextbox(label='Enter Your Prompt (Multi-Languages)', interactive=True, placeholder="Enter prompt, add one image.", file_types=['image'], scale=1)
167
+ img = gr.Gallery(label='SD3M Generated Image',columns = 1, preview=True)
 
168
  with gr.Accordion("Advanced Options", open=False):
169
  with gr.Row():
170
  negative = gr.Textbox(label="Negative prompt", value="low quality, ugly, blurry, poor face, bad anatomy")
 
212
  maximum=10000000000000,
213
  step=1,
214
  value=-1,
215
+ )
216
+ nums = gr.Slider(
217
+ label="Image Numbers",
218
+ minimum=1,
219
+ maximum=4,
220
+ step=1,
221
+ value=1,
222
+ )
223
  gr.Examples(
224
  examples=examples,
225
  inputs=prompt,
 
230
  )
231
 
232
  prompt.submit(fn=generate_image,
233
+ inputs=[prompt, negative, width, height, scale, steps, strength, seed, nums],
234
+ outputs=[img,seed],
 
 
 
 
235
  )
236
+
237
 
238
  demo.queue().launch()