KingNish commited on
Commit
3ef4373
1 Parent(s): 8a468da

test scheduler

Browse files
Files changed (1) hide show
  1. app.py +15 -9
app.py CHANGED
@@ -6,17 +6,20 @@ import gradio as gr
6
  import numpy as np
7
  import torch
8
  from PIL import Image
9
- from diffusers import StableDiffusionXLImg2ImgPipeline, StableDiffusionXLPipeline, EDMEulerScheduler, StableDiffusionXLInstructPix2PixPipeline, AutoencoderKL, EulerAncestralDiscreteScheduler
10
  from huggingface_hub import hf_hub_download, InferenceClient
11
 
12
  vae = AutoencoderKL.from_pretrained("madebyollin/sdxl-vae-fp16-fix", torch_dtype=torch.float16)
 
 
 
 
13
 
14
  refiner = StableDiffusionXLImg2ImgPipeline.from_pretrained("stabilityai/stable-diffusion-xl-refiner-1.0", vae=vae, torch_dtype=torch.float16, use_safetensors=True, variant="fp16")
15
  refiner.to("cuda")
16
 
17
- pipe_fast = StableDiffusionXLPipeline.from_pretrained("SG161222/RealVisXL_V4.0_Lightning", torch_dtype=torch.float16, vae=vae)
18
- pipe_fast.load_lora_weights("KingNish/Better-Image-XL-Lora", weight_name="example-03.safetensors", adapter_name="lora")
19
- pipe_fast.set_adapters("lora")
20
  pipe_fast.to("cuda")
21
 
22
  help_text = """
@@ -183,6 +186,11 @@ examples=[
183
  None,
184
  "Beautiful Eiffel Tower at Night",
185
  ],
 
 
 
 
 
186
  ]
187
 
188
  with gr.Blocks(css=css) as demo:
@@ -207,7 +215,7 @@ with gr.Blocks(css=css) as demo:
207
  negative_prompt = gr.Text(
208
  label="Negative prompt",
209
  max_lines=1,
210
- value="(deformed, distorted, disfigured:1.3), poorly drawn, bad anatomy, wrong anatomy, extra limb, missing limb, floating limbs, (mutated hands and fingers:1.4), disconnected limbs, mutation, mutated, ugly, disgusting, blurry, amputation",
211
  visible=True)
212
  with gr.Row():
213
  width = gr.Slider( label="Width", minimum=256, maximum=2048, step=64, value=1024)
@@ -220,9 +228,7 @@ with gr.Blocks(css=css) as demo:
220
  show_label=False,
221
  interactive=True,
222
  )
223
- seed = gr.Number(value=1371, step=1, label="Seed", interactive=True)
224
-
225
-
226
 
227
  gr.Examples(
228
  examples=examples,
@@ -259,4 +265,4 @@ with gr.Blocks(css=css) as demo:
259
  outputs=[seed, input_image],
260
  )
261
 
262
- demo.queue(max_size=99999).launch()
 
6
  import numpy as np
7
  import torch
8
  from PIL import Image
9
+ from diffusers import StableDiffusionXLImg2ImgPipeline, StableDiffusionXLPipeline, EDMEulerScheduler, StableDiffusionXLInstructPix2PixPipeline, AutoencoderKL, DPMSolverMultistepScheduler
10
  from huggingface_hub import hf_hub_download, InferenceClient
11
 
12
  vae = AutoencoderKL.from_pretrained("madebyollin/sdxl-vae-fp16-fix", torch_dtype=torch.float16)
13
+ pipe = StableDiffusionXLPipeline.from_pretrained("SG161222/RealVisXL_V4.0", torch_dtype=torch.float16, vae=vae)
14
+ pipe.load_lora_weights("KingNish/Better-Image-XL-Lora", weight_name="example-03.safetensors", adapter_name="lora")
15
+ pipe.set_adapters("lora")
16
+ pipe.to("cuda")
17
 
18
  refiner = StableDiffusionXLImg2ImgPipeline.from_pretrained("stabilityai/stable-diffusion-xl-refiner-1.0", vae=vae, torch_dtype=torch.float16, use_safetensors=True, variant="fp16")
19
  refiner.to("cuda")
20
 
21
+ pipe_fast = StableDiffusionXLPipeline.from_pretrained("SG161222/RealVisXL_V4.0_Lightning", torch_dtype=torch.float16, vae=vae, custom_pipeline="lpw_stable_diffusion_xl", use_safetensors=True)
22
+ pipe_fast.scheduler = DPMSolverMultistepScheduler.from_config(pipe.scheduler.config, use_karras_sigmas=True, algorithm_type="sde-dpmsolver++")
 
23
  pipe_fast.to("cuda")
24
 
25
  help_text = """
 
186
  None,
187
  "Beautiful Eiffel Tower at Night",
188
  ],
189
+ [
190
+ "Image Generation",
191
+ None,
192
+ "Beautiful Eiffel Tower at Night",
193
+ ],
194
  ]
195
 
196
  with gr.Blocks(css=css) as demo:
 
215
  negative_prompt = gr.Text(
216
  label="Negative prompt",
217
  max_lines=1,
218
+ value="(deformed, distorted, disfigured:1.3), poorly drawn, bad anatomy, wrong anatomy, extra limb, missing limb, floating limbs, (mutated hands and fingers:1.4), disconnected limbs, ugly, disgusting, blurry, amputation,(face asymmetry, eyes asymmetry, deformed eyes, open mouth)",
219
  visible=True)
220
  with gr.Row():
221
  width = gr.Slider( label="Width", minimum=256, maximum=2048, step=64, value=1024)
 
228
  show_label=False,
229
  interactive=True,
230
  )
231
+ seed = gr.Number(value=2404, step=1, label="Seed", interactive=True)
 
 
232
 
233
  gr.Examples(
234
  examples=examples,
 
265
  outputs=[seed, input_image],
266
  )
267
 
268
+ demo.queue(max_size=50).launch()