kernkraft commited on
Commit
122d263
·
verified ·
1 Parent(s): 8b5755f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -16
app.py CHANGED
@@ -34,7 +34,7 @@ vae = AutoencoderKL.from_pretrained(
34
  ).to("cuda")
35
 
36
  pipe = StableDiffusionXLFillPipeline.from_pretrained(
37
- "SG161222/RealVisXL_V5.0_Lightning",
38
  torch_dtype=torch.float16,
39
  vae=vae,
40
  controlnet=model,
@@ -179,14 +179,18 @@ def infer(image, width, height, overlap_percentage, num_inference_steps, resize_
179
  cnet_image.paste(0, (0, 0), mask)
180
 
181
  final_prompt = f"{prompt_input} , high quality, 4k"
 
182
 
183
  (
184
  prompt_embeds,
185
- negative_prompt_embeds,
186
  pooled_prompt_embeds,
187
- negative_pooled_prompt_embeds,
188
  ) = pipe.encode_prompt(final_prompt, "cuda", True)
189
 
 
 
 
 
 
190
  for image in pipe(
191
  prompt_embeds=prompt_embeds,
192
  negative_prompt_embeds=negative_prompt_embeds,
@@ -251,13 +255,6 @@ css = """
251
 
252
  title = """<h1 align="center">Diffusers Image Outpaint</h1>
253
  <div align="center">Drop an image you would like to extend, pick your expected ratio and hit Generate.</div>
254
- <div style="display: flex; justify-content: center; align-items: center; text-align: center;">
255
- <p style="display: flex;gap: 6px;">
256
- <a href="https://huggingface.co/spaces/fffiloni/diffusers-image-outpout?duplicate=true">
257
- <img src="https://huggingface.co/datasets/huggingface/badges/resolve/main/duplicate-this-space-md.svg" alt="Duplicate this Space">
258
- </a> to skip the queue and enjoy faster inference on the GPU of your choice
259
- </p>
260
- </div>
261
  """
262
 
263
  with gr.Blocks(css=css) as demo:
@@ -274,6 +271,8 @@ with gr.Blocks(css=css) as demo:
274
  with gr.Row():
275
  with gr.Column(scale=2):
276
  prompt_input = gr.Textbox(label="Prompt (Optional)")
 
 
277
  with gr.Column(scale=1):
278
  run_button = gr.Button("Generate")
279
 
@@ -298,23 +297,23 @@ with gr.Blocks(css=css) as demo:
298
  label="Target Width",
299
  minimum=720,
300
  maximum=1536,
301
- step=8,
302
- value=720, # Set a default value
303
  )
304
  height_slider = gr.Slider(
305
  label="Target Height",
306
  minimum=720,
307
  maximum=1536,
308
- step=8,
309
- value=1280, # Set a default value
310
  )
311
 
312
- num_inference_steps = gr.Slider(label="Steps", minimum=4, maximum=12, step=1, value=8)
313
  with gr.Group():
314
  overlap_percentage = gr.Slider(
315
  label="Mask overlap (%)",
316
  minimum=1,
317
- maximum=50,
318
  value=10,
319
  step=1
320
  )
 
34
  ).to("cuda")
35
 
36
  pipe = StableDiffusionXLFillPipeline.from_pretrained(
37
+ "RunDiffusion/Juggernaut-XI-Lightning",
38
  torch_dtype=torch.float16,
39
  vae=vae,
40
  controlnet=model,
 
179
  cnet_image.paste(0, (0, 0), mask)
180
 
181
  final_prompt = f"{prompt_input} , high quality, 4k"
182
+ negative_final_prompt = f"{negative_prompt_input}"
183
 
184
  (
185
  prompt_embeds,
 
186
  pooled_prompt_embeds,
 
187
  ) = pipe.encode_prompt(final_prompt, "cuda", True)
188
 
189
+ (
190
+ negative_prompt_embeds,
191
+ negative_pooled_prompt_embeds,
192
+ ) = pipe.encode_prompt(negative_final_prompt, "cuda", True)
193
+
194
  for image in pipe(
195
  prompt_embeds=prompt_embeds,
196
  negative_prompt_embeds=negative_prompt_embeds,
 
255
 
256
  title = """<h1 align="center">Diffusers Image Outpaint</h1>
257
  <div align="center">Drop an image you would like to extend, pick your expected ratio and hit Generate.</div>
 
 
 
 
 
 
 
258
  """
259
 
260
  with gr.Blocks(css=css) as demo:
 
271
  with gr.Row():
272
  with gr.Column(scale=2):
273
  prompt_input = gr.Textbox(label="Prompt (Optional)")
274
+ with gr.Column(scale=2):
275
+ negative_prompt_input = gr.Textbox(label="Negative Prompt (Optional)")
276
  with gr.Column(scale=1):
277
  run_button = gr.Button("Generate")
278
 
 
297
  label="Target Width",
298
  minimum=720,
299
  maximum=1536,
300
+ step=32,
301
+ value=1280, # Set a default value
302
  )
303
  height_slider = gr.Slider(
304
  label="Target Height",
305
  minimum=720,
306
  maximum=1536,
307
+ step=32,
308
+ value=720, # Set a default value
309
  )
310
 
311
+ num_inference_steps = gr.Slider(label="Steps", minimum=4, maximum=20, step=1, value=8)
312
  with gr.Group():
313
  overlap_percentage = gr.Slider(
314
  label="Mask overlap (%)",
315
  minimum=1,
316
+ maximum=75,
317
  value=10,
318
  step=1
319
  )