From 942371b25a4f6927d50b4d303889671b5801a9ec Mon Sep 17 00:00:00 2001 From: AI-Casanova <54461896+AI-Casanova@users.noreply.github.com> Date: Fri, 28 Jul 2023 18:00:44 -0500 Subject: [PATCH 1/2] Update lora_diffusers.py --- modules/lora_diffusers.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 From fd7f51302ef62d2922e7b6e07a323d4b7376547a Mon Sep 17 00:00:00 2001 From: AI-Casanova <54461896+AI-Casanova@users.noreply.github.com> Date: Fri, 28 Jul 2023 18:01:38 -0500 Subject: [PATCH 2/2] Update processing_diffusers.py --- modules/processing_diffusers.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/modules/processing_diffusers.py b/modules/processing_diffusers.py index 52175889c..e7c427523 100644 --- a/modules/processing_diffusers.py +++ b/modules/processing_diffusers.py @@ -152,6 +152,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)): if shared.opts.save and not p.do_not_save_samples and shared.opts.save_images_before_refiner and hasattr(shared.sd_model, 'vae'): @@ -207,7 +210,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