mirror of https://github.com/vladmandic/automatic
Revert non-critical changes
The following errors are re-introduced and will need follow-up: - models.py, line 92 - sd_unet.py, line 41 - sd_models.py, line 1440pull/4710/head
parent
a255e5bdcf
commit
375591ecdd
|
|
@ -57,9 +57,9 @@ def underscore(name: str) -> str: # Convert CamelCase or PascalCase string to un
|
|||
class PydanticModelGenerator:
|
||||
def __init__(
|
||||
self,
|
||||
model_name: str,
|
||||
class_instance,
|
||||
additional_fields: list,
|
||||
model_name: str | None = None,
|
||||
class_instance: type | None = None,
|
||||
additional_fields: list[dict[str, Any]] | None = None,
|
||||
exclude_fields: list | None = None,
|
||||
):
|
||||
if exclude_fields is None:
|
||||
|
|
|
|||
|
|
@ -190,7 +190,7 @@ def set_diffusers_attention(pipe, quiet = False):
|
|||
from modules import shared
|
||||
import diffusers.models.attention_processor as p
|
||||
|
||||
def set_attn(pipe, attention, name: str):
|
||||
def set_attn(pipe, attention, name: str | None = None):
|
||||
if attention is None:
|
||||
return
|
||||
# other models uses their own attention processor
|
||||
|
|
|
|||
|
|
@ -134,7 +134,7 @@ def get_models() -> list:
|
|||
return ["DeepBooru"]
|
||||
|
||||
|
||||
def load_model(model_name: str = "") -> bool: # pylint: disable=unused-argument
|
||||
def load_model(model_name: str | None = None) -> bool: # pylint: disable=unused-argument
|
||||
"""Load the DeepBooru model."""
|
||||
try:
|
||||
model.load()
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
from typing import TYPE_CHECKING
|
||||
from PIL import Image
|
||||
import gradio as gr
|
||||
from modules.logger import log
|
||||
|
|
@ -178,8 +177,6 @@ class Unit: # mashup of gradio controls and mapping to actual implementation cla
|
|||
|
||||
# bind ui controls to properties if present
|
||||
if self.type == 't2i adapter':
|
||||
if TYPE_CHECKING:
|
||||
assert isinstance(self.adapter, t2iadapter.Adapter)
|
||||
if model_id is not None:
|
||||
if isinstance(model_id, str):
|
||||
self.adapter.load(model_id)
|
||||
|
|
@ -189,8 +186,6 @@ class Unit: # mashup of gradio controls and mapping to actual implementation cla
|
|||
if extra_controls is not None and len(extra_controls) > 0:
|
||||
extra_controls[0].change(fn=adapter_extra, inputs=extra_controls)
|
||||
elif self.type == 'controlnet':
|
||||
if TYPE_CHECKING:
|
||||
assert isinstance(self.controlnet, controlnet.ControlNet)
|
||||
if model_id is not None:
|
||||
if isinstance(model_id, str):
|
||||
self.controlnet.load(model_id)
|
||||
|
|
@ -201,8 +196,6 @@ class Unit: # mashup of gradio controls and mapping to actual implementation cla
|
|||
if extra_controls is not None and len(extra_controls) > 0:
|
||||
extra_controls[0].change(fn=controlnet_extra, inputs=extra_controls)
|
||||
elif self.type == 'xs':
|
||||
if TYPE_CHECKING:
|
||||
assert isinstance(self.controlnet, xs.ControlNetXS)
|
||||
if model_id is not None:
|
||||
if isinstance(model_id, str):
|
||||
self.controlnet.load(model_id)
|
||||
|
|
@ -212,8 +205,6 @@ class Unit: # mashup of gradio controls and mapping to actual implementation cla
|
|||
if extra_controls is not None and len(extra_controls) > 0:
|
||||
extra_controls[0].change(fn=controlnetxs_extra, inputs=extra_controls)
|
||||
elif self.type == 'lite':
|
||||
if TYPE_CHECKING:
|
||||
assert isinstance(self.controlnet, lite.ControlLLLite)
|
||||
if model_id is not None:
|
||||
if isinstance(model_id, str):
|
||||
self.controlnet.load(model_id)
|
||||
|
|
|
|||
|
|
@ -1418,7 +1418,7 @@ def hf_auth_check(checkpoint_info, force:bool=False):
|
|||
return False
|
||||
|
||||
|
||||
def save_model(name: str, path: str | None = None, shard: str = "5GB", overwrite = False):
|
||||
def save_model(name: str, path: str | None = None, shard: str | None = None, overwrite = False):
|
||||
if (name is None) or len(name.strip()) == 0:
|
||||
log.error('Save model: invalid model name')
|
||||
return 'Invalid model name'
|
||||
|
|
@ -1432,8 +1432,6 @@ def save_model(name: str, path: str | None = None, shard: str = "5GB", overwrite
|
|||
if os.path.exists(model_name) and not overwrite:
|
||||
log.error(f'Save model: path="{model_name}" exists')
|
||||
return f'Path exists: {model_name}'
|
||||
if not shard.strip():
|
||||
shard = "5GB" # Guard against empty input
|
||||
try:
|
||||
t0 = time.time()
|
||||
save_sdnq_model(
|
||||
|
|
|
|||
|
|
@ -38,8 +38,8 @@ def load_unet_sdxl_nunchaku(repo_id):
|
|||
def load_unet(model, repo_id: str | None = None):
|
||||
global loaded_unet # pylint: disable=global-statement
|
||||
|
||||
if ("StableDiffusionXLPipeline" in model.__class__.__name__) and repo_id is not None and (("stable-diffusion-xl-base" in repo_id) or ("sdxl-turbo" in repo_id)):
|
||||
if model_quant.check_nunchaku("Model"):
|
||||
if ("StableDiffusionXLPipeline" in model.__class__.__name__) and (('stable-diffusion-xl-base' in repo_id) or ('sdxl-turbo' in repo_id)):
|
||||
if model_quant.check_nunchaku('Model'):
|
||||
unet = load_unet_sdxl_nunchaku(repo_id)
|
||||
if unet is not None:
|
||||
model.unet = unet
|
||||
|
|
|
|||
Loading…
Reference in New Issue