mirror of
https://github.com/vladmandic/automatic
synced 2026-09-20 01:31:13 +02:00
Check SD_LORA_DIFFUSERS flag once
This commit is contained in:
@@ -3,6 +3,8 @@ import torch
|
||||
import networks
|
||||
from modules import patches, shared
|
||||
|
||||
# OpenVINO only works with Diffusers LoRa loading
|
||||
force_lora_diffusers = os.environ.get('SD_LORA_DIFFUSERS', None) is not None
|
||||
|
||||
class LoraPatches:
|
||||
def __init__(self):
|
||||
@@ -19,7 +21,7 @@ class LoraPatches:
|
||||
self.MultiheadAttention_load_state_dict = None
|
||||
|
||||
def apply(self):
|
||||
if self.active or (os.environ.get('SD_LORA_DIFFUSERS', None) is not None): # OpenVINO only works with Diffusers LoRa loading
|
||||
if self.active or force_lora_diffusers:
|
||||
return
|
||||
self.Linear_forward = patches.patch(__name__, torch.nn.Linear, 'forward', networks.network_Linear_forward)
|
||||
self.Linear_load_state_dict = patches.patch(__name__, torch.nn.Linear, '_load_from_state_dict', networks.network_Linear_load_state_dict)
|
||||
@@ -37,7 +39,7 @@ class LoraPatches:
|
||||
self.active = True
|
||||
|
||||
def undo(self):
|
||||
if not self.active or (os.environ.get('SD_LORA_DIFFUSERS', None) is not None): # OpenVINO only works with Diffusers LoRa loading
|
||||
if not self.active or force_lora_diffusers:
|
||||
return
|
||||
self.Linear_forward = patches.undo(__name__, torch.nn.Linear, 'forward') # pylint: disable=E1128
|
||||
self.Linear_load_state_dict = patches.undo(__name__, torch.nn.Linear, '_load_from_state_dict') # pylint: disable=E1128
|
||||
|
||||
Reference in New Issue
Block a user