diff --git a/modules/lora_diffusers.py b/modules/lora_diffusers.py index e5779b3c6..537416180 100644 --- a/modules/lora_diffusers.py +++ b/modules/lora_diffusers.py @@ -10,6 +10,7 @@ lora_state = { # TODO Lora state for Diffusers def unload_diffusers_lora(): try: pipe = shared.sd_model + pipe.unload_lora_weights() lora_state['active'] = False lora_state['loaded'] = 0 pipe._remove_text_encoder_monkey_patch() # pylint: disable=W0212 @@ -24,7 +25,7 @@ def unload_diffusers_lora(): def load_diffusers_lora(name, lora, strength = 1.0): try: pipe = shared.sd_model - pipe.load_lora_weights(lora.filename, cache_dir=shared.opts.diffusers_dir, local_files_only=True) + pipe.load_lora_weights(lora.filename, cache_dir=shared.opts.diffusers_dir, local_files_only=True, lora_scale=strength) lora_state['active'] = True lora_state['loaded'] += 1 lora_state['multiplier'] = strength diff --git a/modules/processing_diffusers.py b/modules/processing_diffusers.py index cbabc61fb..3f99a6b7a 100644 --- a/modules/processing_diffusers.py +++ b/modules/processing_diffusers.py @@ -159,6 +159,9 @@ def process_diffusers(p: StableDiffusionProcessing, seeds, prompts, negative_pro if shared.sd_refiner is None or not p.enable_hr: output.images = vae_decode(output.images, shared.sd_model) + if lora_state['active']: + unload_diffusers_lora() + if refiner_enabled: for i in range(len(output.images)): #shared.cmd_opts.medvram or shared.opts.diffusers_model_cpu_offload: @@ -216,7 +219,6 @@ def process_diffusers(p: StableDiffusionProcessing, seeds, prompts, negative_pro if p.is_hr_pass: shared.log.warning('Diffusers not implemented: hires fix') - if lora_state['active']: - unload_diffusers_lora() + return results