From 375591ecdddb3b51552fc1b97570c7ba549f1057 Mon Sep 17 00:00:00 2001 From: awsr <43862868+awsr@users.noreply.github.com> Date: Wed, 25 Mar 2026 13:39:13 -0700 Subject: [PATCH] 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 1440 --- modules/api/models.py | 6 +++--- modules/attention.py | 2 +- modules/caption/deepbooru.py | 2 +- modules/control/unit.py | 9 --------- modules/sd_models.py | 4 +--- modules/sd_unet.py | 4 ++-- 6 files changed, 8 insertions(+), 19 deletions(-) diff --git a/modules/api/models.py b/modules/api/models.py index 47ccecd6b..c0d4f32ed 100644 --- a/modules/api/models.py +++ b/modules/api/models.py @@ -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: diff --git a/modules/attention.py b/modules/attention.py index 24c30582d..7b3ac8e13 100644 --- a/modules/attention.py +++ b/modules/attention.py @@ -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 diff --git a/modules/caption/deepbooru.py b/modules/caption/deepbooru.py index 878b3852a..2f1026396 100644 --- a/modules/caption/deepbooru.py +++ b/modules/caption/deepbooru.py @@ -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() diff --git a/modules/control/unit.py b/modules/control/unit.py index e66aed02b..9c4a83f10 100644 --- a/modules/control/unit.py +++ b/modules/control/unit.py @@ -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) diff --git a/modules/sd_models.py b/modules/sd_models.py index f7b224f9e..db1007126 100644 --- a/modules/sd_models.py +++ b/modules/sd_models.py @@ -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( diff --git a/modules/sd_unet.py b/modules/sd_unet.py index 344164cb4..c18806911 100644 --- a/modules/sd_unet.py +++ b/modules/sd_unet.py @@ -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