Skip to content

Commit

Permalink
Adding support for 3 Flash LoRA models (SD 1.5 and SDXL)
Browse files Browse the repository at this point in the history
  • Loading branch information
Woolverine94 committed Jun 8, 2024
1 parent 36bfb04 commit df3c692
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
21 changes: 21 additions & 0 deletions ressources/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -1730,6 +1730,24 @@ def write_ini_img2shape(
savefile.write(content)
return


def is_fast_lora(model):
if (\
(model == "ByteDance/SDXL-Lightning") or \
(model == "ByteDance/Hyper-SD") or \
(model == "openskyml/lcm-lora-sdxl-turbo") or \
("H1T/TCD-SD" in model.upper()) or \
(model == "wangfuyun/PCM_Weights") or \
(model == "tianweiy/DMD2") or \
(model == "jasperai/flash-sdxl") or \
(model == "jasperai/flash-sd") or \
(model == "sd-community/sdxl-flash-lora")
):
is_fast_lora_value = True
else:
is_fast_lora_value = False
return is_fast_lora_value

def is_sdxl(model):
if (\
("XL" in model.upper()) or \
Expand Down Expand Up @@ -1760,6 +1778,8 @@ def lora_model_list(model):
"tianweiy/DMD2":("dmd2_sdxl_4step_lora.safetensors", ""),
"h1t/TCD-SDXL-LoRA":("pytorch_lora_weights.safetensors", ""),
"wangfuyun/PCM_Weights":("sdxl/pcm_sdxl_lcmlike_lora_converted.safetensors", ""),
"jasperai/flash-sdxl":("pytorch_lora_weights.safetensors", ""),
"sd-community/sdxl-flash-lora":("sdxl-flash-lora.safetensors", "sdxl-flash-lora:0.55"),
"ehristoforu/dalle-3-xl-v2":("dalle-3-xl-lora-v2.safetensors", ""),
"DoctorDiffusion/doctor-diffusion-s-claymation-style-lora":("DD-made-of-clay-XL-v2.safetensors", "made-of-clay"),
"DoctorDiffusion/doctor-diffusion-s-toy-xl-style-lora":("DD-toy-v2.safetensors", "toy"),
Expand Down Expand Up @@ -1795,6 +1815,7 @@ def lora_model_list(model):
"ByteDance/Hyper-SD":("Hyper-SD15-1step-lora.safetensors", ""),
"h1t/TCD-SD15-LoRA":("pytorch_lora_weights.safetensors", ""),
"wangfuyun/PCM_Weights":("sd15/pcm_sd15_lcmlike_lora_converted.safetensors", ""),
"jasperai/flash-sd":("pytorch_lora_weights.safetensors", ""),
"Kvikontent/midjourney-v6":("mj6-10.safetensors", ""),
"Norod78/SD15-IllusionDiffusionPattern-LoRA":("SD15-IllusionDiffusionPattern-LoRA.safetensors","IllusionDiffusionPattern"),

Expand Down
8 changes: 7 additions & 1 deletion webui.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ def change_lora_model_txt2img_sd(model, lora_model, prompt, steps, cfg_scale, sa
lora_prompt_txt2img_sd = lora_prompt_txt2img_sd.replace(lora_trigger, "")
biniou_internal_previous_trigger_txt2img_sd = lora_keyword

if (lora_model == "ByteDance/SDXL-Lightning") or (lora_model == "ByteDance/Hyper-SD") or (lora_model == "openskyml/lcm-lora-sdxl-turbo") or ("H1T/TCD-SD" in lora_model.upper()) or (lora_model == "wangfuyun/PCM_Weights") or (lora_model == "tianweiy/DMD2"):
if is_fast_lora(lora_model):
biniou_internal_previous_model_txt2img_sd = model
biniou_internal_previous_steps_txt2img_sd = steps
biniou_internal_previous_cfg_txt2img_sd = cfg_scale
Expand All @@ -376,6 +376,12 @@ def change_lora_model_txt2img_sd(model, lora_model, prompt, steps, cfg_scale, sa
return prompt_txt2img_sd.update(value=lora_prompt_txt2img_sd), num_inference_step_txt2img_sd.update(value=4), guidance_scale_txt2img_sd.update(value=0.0), sampler_txt2img_sd.update(value="LCM")
elif (lora_model == "wangfuyun/PCM_Weights"):
return prompt_txt2img_sd.update(value=lora_prompt_txt2img_sd), num_inference_step_txt2img_sd.update(value=2), guidance_scale_txt2img_sd.update(value=0.0), sampler_txt2img_sd.update(value="LCM")
elif (lora_model == "jasperai/flash-sdxl"):
return prompt_txt2img_sd.update(value=lora_prompt_txt2img_sd), num_inference_step_txt2img_sd.update(value=4), guidance_scale_txt2img_sd.update(value=0.0), sampler_txt2img_sd.update(value="LCM")
elif (lora_model == "jasperai/flash-sd"):
return prompt_txt2img_sd.update(value=lora_prompt_txt2img_sd), num_inference_step_txt2img_sd.update(value=2), guidance_scale_txt2img_sd.update(value=0.0), sampler_txt2img_sd.update(value="LCM")
elif (lora_model == "sd-community/sdxl-flash-lora"):
return prompt_txt2img_sd.update(value=lora_prompt_txt2img_sd), num_inference_step_txt2img_sd.update(value=6), guidance_scale_txt2img_sd.update(value=3.0), sampler_txt2img_sd.update(value="DPM++ SDE")
else:
if ((biniou_internal_previous_model_txt2img_sd == "") and (biniou_internal_previous_steps_txt2img_sd == "") and (biniou_internal_previous_cfg_txt2img_sd == "") and (biniou_internal_previous_sampler_txt2img_sd == "")):
return prompt_txt2img_sd.update(value=lora_prompt_txt2img_sd), num_inference_step_txt2img_sd.update(), guidance_scale_txt2img_sd.update(), sampler_txt2img_sd.update()
Expand Down

0 comments on commit df3c692

Please sign in to comment.