Update LoRA.py - avoid potential error (#2953)

This commit is contained in:
FartyPants 2023-07-03 16:40:22 -04:00 committed by GitHub
parent 33f56fd41d
commit c23c88ee4c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -106,8 +106,10 @@ def add_lora_transformers(lora_names):
# If any LoRA needs to be removed, start over # If any LoRA needs to be removed, start over
if len(removed_set) > 0: if len(removed_set) > 0:
shared.model.disable_adapter() # shared.model may no longer be PeftModel
shared.model = shared.model.base_model.model if hasattr(shared.model, 'disable_adapter'):
shared.model.disable_adapter()
shared.model = shared.model.base_model.model
if len(lora_names) > 0: if len(lora_names) > 0:
params = {} params = {}