LPDoctor commited on
Commit
5eda147
·
verified ·
1 Parent(s): 7fe28aa

add LCM Scheduler

Browse files
Files changed (1) hide show
  1. app.py +13 -3
app.py CHANGED
@@ -53,6 +53,11 @@ pipe = StableDiffusionXLInstantIDPipeline.from_pretrained(
53
  safety_checker=None,
54
  feature_extractor=None,
55
  )
 
 
 
 
 
56
  pipe.cuda()
57
  pipe.load_ip_adapter_instantid(face_adapter)
58
  pipe.image_proj_model.to("cuda")
@@ -207,9 +212,14 @@ def generate_image(
207
  seed,
208
  progress=gr.Progress(track_tqdm=True),
209
  ):
 
210
  if prompt is None:
211
  prompt = "a person"
212
 
 
 
 
 
213
  # apply the style template
214
  prompt, negative_prompt = apply_style(style_name, prompt, negative_prompt)
215
 
@@ -371,17 +381,17 @@ with gr.Blocks(css=css) as demo:
371
  )
372
  num_steps = gr.Slider(
373
  label="Number of sample steps",
374
- minimum=20,
375
  maximum=100,
376
  step=1,
377
- value=30,
378
  )
379
  guidance_scale = gr.Slider(
380
  label="Guidance scale",
381
  minimum=0.1,
382
  maximum=10.0,
383
  step=0.1,
384
- value=5,
385
  )
386
  seed = gr.Slider(
387
  label="Seed",
 
53
  safety_checker=None,
54
  feature_extractor=None,
55
  )
56
+
57
+ # load and disable LCM
58
+ pipe.load_lora_weights("latent-consistency/lcm-lora-sdxl")
59
+ pipe.disable_lora()
60
+
61
  pipe.cuda()
62
  pipe.load_ip_adapter_instantid(face_adapter)
63
  pipe.image_proj_model.to("cuda")
 
212
  seed,
213
  progress=gr.Progress(track_tqdm=True),
214
  ):
215
+
216
  if prompt is None:
217
  prompt = "a person"
218
 
219
+ # LCM Sceduler Callback
220
+ pipe.scheduler = diffusers.LCMScheduler.from_config(pipe.scheduler.config)
221
+ pipe.enable_lora()
222
+
223
  # apply the style template
224
  prompt, negative_prompt = apply_style(style_name, prompt, negative_prompt)
225
 
 
381
  )
382
  num_steps = gr.Slider(
383
  label="Number of sample steps",
384
+ minimum=2,
385
  maximum=100,
386
  step=1,
387
+ value=8,
388
  )
389
  guidance_scale = gr.Slider(
390
  label="Guidance scale",
391
  minimum=0.1,
392
  maximum=10.0,
393
  step=0.1,
394
+ value=3.0,
395
  )
396
  seed = gr.Slider(
397
  label="Seed",