From c23c88ee4c9e889e0ad5ec4882f0285c9248ecc3 Mon Sep 17 00:00:00 2001 From: FartyPants Date: Mon, 3 Jul 2023 16:40:22 -0400 Subject: [PATCH] Update LoRA.py - avoid potential error (#2953) --- modules/LoRA.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/modules/LoRA.py b/modules/LoRA.py index c0c8ae08..e54d5337 100644 --- a/modules/LoRA.py +++ b/modules/LoRA.py @@ -106,8 +106,10 @@ def add_lora_transformers(lora_names): # If any LoRA needs to be removed, start over if len(removed_set) > 0: - shared.model.disable_adapter() - shared.model = shared.model.base_model.model + # shared.model may no longer be PeftModel + if hasattr(shared.model, 'disable_adapter'): + shared.model.disable_adapter() + shared.model = shared.model.base_model.model if len(lora_names) > 0: params = {}