a2569875 2023-05-09 16:49:22 +08:00
parent 35405c3697
commit cf2b97a030
3 changed files with 8 additions and 7 deletions

View File

@ -1,4 +1,4 @@
from typing import List, Dict
from typing import List, Dict, Optional
import re
import torch
import composable_lora_step
@ -31,7 +31,7 @@ def lora_forward(compvis_module, input, res):
if len(lora.loaded_loras) == 0:
return res
lora_layer_name_loading : str | None = getattr(compvis_module, 'lora_layer_name', None)
lora_layer_name_loading : Optional[str] = getattr(compvis_module, 'lora_layer_name', None)
if lora_layer_name_loading is None:
return res
#let it type is actually a string

View File

@ -1,4 +1,4 @@
from typing import List
from typing import List, Union
import re
import ast
import copy
@ -192,7 +192,7 @@ class LoRA_Controller(LoRA_Controller_Base):
#lora with start and end
class LoRA_StartEnd_Controller(LoRA_Controller_Base):
def __init__(self, name : str, weight : float, start : float | int, end : float | int):
def __init__(self, name : str, weight : float, start : Union[float, int], end : Union[float, int]):
super().__init__()
self.name = name
self.weight = float(weight)
@ -218,7 +218,7 @@ class LoRA_StartEnd_Controller(LoRA_Controller_Base):
#switch lora
class LoRA_Switcher_Controller(LoRA_Controller_Base):
def __init__(self, lora_dist : List[LoRA_data], start : float | int, end : float | int):
def __init__(self, lora_dist : List[LoRA_data], start : Union[float, int], end : Union[float, int]):
super().__init__()
self.lora_dist = lora_dist
the_list : List[str] = []
@ -356,7 +356,7 @@ def extra_net_split(input_str : str, pattern : str):
return [input_str]
return result
def extra_net_re_search(pattern : str | re.Pattern[str], input_str : str):
def extra_net_re_search(pattern : Union[str, re.Pattern[str]], input_str : str):
result = MySearchResult()
extra_net_list : List[str] = []
escape_obj_list : List[str] = []

View File

@ -1,3 +1,4 @@
from typing import Optional
import torch
from modules import shared
@ -9,7 +10,7 @@ def lycoris_forward(compvis_module, input, res):
if len(lycoris.loaded_lycos) == 0:
return res
lycoris_layer_name_loading : str | None = getattr(compvis_module, 'lyco_layer_name', None)
lycoris_layer_name_loading : Optional[str] = getattr(compvis_module, 'lyco_layer_name', None)
if lycoris_layer_name_loading is None:
return res
#let it type is actually a string