Revert "much stricter ruff linting"

This reverts commit 310dbf1574.
This commit is contained in:
Vladimir Mandic
2026-05-11 08:13:57 +02:00
parent 8296d07ff8
commit c8d6fd5cf8
132 changed files with 363 additions and 292 deletions
+4 -4
View File
@@ -5,7 +5,7 @@ from typing import Union
from diffusers import StableDiffusionPipeline, StableDiffusionXLPipeline, FluxPipeline, StableDiffusion3Pipeline, ControlNetModel
from modules.control.units import detect
from modules.shared import log, opts, cmd_opts, state, listdir
from modules import errors, sd_models, devices
from modules import errors, sd_models, devices, model_quant
from modules.processing import StableDiffusionProcessingControl
@@ -163,7 +163,7 @@ def find_models():
find_models()
def api_list_models(model_type: str | None = None):
def api_list_models(model_type: str = None):
import modules.shared
model_type = model_type or modules.shared.sd_model_type
model_list = []
@@ -215,7 +215,7 @@ def list_models(refresh=False):
class ControlNet():
def __init__(self, model_id: str | None = None, device = None, dtype = None, load_config = None):
def __init__(self, model_id: str = None, device = None, dtype = None, load_config = None):
self.model: ControlNetModel = None
self.model_id: str = model_id
self.device = device
@@ -311,7 +311,7 @@ class ControlNet():
self.load_config['original_config_file '] = config_path
self.model = cls.from_single_file(model_path, config=config, **self.load_config)
def load(self, model_id: str | None = None, force: bool = False) -> str:
def load(self, model_id: str = None, force: bool = False) -> str:
with load_lock:
try:
t0 = time.time()
+2 -2
View File
@@ -63,7 +63,7 @@ def list_models(refresh=False):
class ControlLLLite():
def __init__(self, model_id: str | None = None, device = None, dtype = None, load_config = None):
def __init__(self, model_id: str = None, device = None, dtype = None, load_config = None):
self.model: ControlNetLLLite = None
self.model_id: str = model_id
self.device = device
@@ -83,7 +83,7 @@ class ControlLLLite():
self.model = None
self.model_id = None
def load(self, model_id: str | None = None, force: bool = True) -> str:
def load(self, model_id: str = None, force: bool = True) -> str:
with load_lock:
try:
t0 = time.time()
+2 -2
View File
@@ -71,7 +71,7 @@ class AdapterModel(T2IAdapter):
class Adapter():
def __init__(self, model_id: str | None = None, device = None, dtype = None, load_config = None):
def __init__(self, model_id: str = None, device = None, dtype = None, load_config = None):
self.model: AdapterModel = None
self.model_id: str = model_id
self.device = device
@@ -91,7 +91,7 @@ class Adapter():
self.model = None
self.model_id = None
def load(self, model_id: str | None = None, force: bool = True) -> str:
def load(self, model_id: str = None, force: bool = True) -> str:
with load_lock:
try:
t0 = time.time()
+2 -2
View File
@@ -59,7 +59,7 @@ def list_models(refresh=False):
class ControlNetXS():
def __init__(self, model_id: str | None = None, device = None, dtype = None, load_config = None):
def __init__(self, model_id: str = None, device = None, dtype = None, load_config = None):
self.model: ControlNetXSModel = None
self.model_id: str = model_id
self.device = device
@@ -79,7 +79,7 @@ class ControlNetXS():
self.model = None
self.model_id = None
def load(self, model_id: str | None = None, time_embedding_mix: float = 0.0, force: bool = True) -> str:
def load(self, model_id: str = None, time_embedding_mix: float = 0.0, force: bool = True) -> str:
with load_lock:
try:
t0 = time.time()
+6 -6
View File
@@ -64,9 +64,9 @@ class ControlNetXSOutput(BaseOutput):
class ControlNetConditioningEmbedding(nn.Module):
"""
Quoting from https://arxiv.org/abs/2302.05543: "Stable Diffusion uses a pre-processing method similar to VQ-GAN
[11] to convert the entire dataset of 512 x 512 images into smaller 64 x 64 “latent images” for stabilized
training. This requires ControlNets to convert image-based conditions to 64 x 64 feature space to match the
convolution size. We use a tiny network E(·) of four convolution layers with 4 x 4 kernels and 2 x 2 strides
[11] to convert the entire dataset of 512 × 512 images into smaller 64 × 64 “latent images” for stabilized
training. This requires ControlNets to convert image-based conditions to 64 × 64 feature space to match the
convolution size. We use a tiny network E(·) of four convolution layers with 4 × 4 kernels and 2 × 2 strides
(activated by ReLU, channels are 16, 32, 64, 128, initialized with Gaussian weights, trained jointly with the full
model) to encode image-space conditions ... into feature maps ..."
"""
@@ -657,7 +657,7 @@ class ControlNetXSModel(ModelMixin, ConfigMixin):
if base_model.config.addition_embed_type == "text":
aug_emb = base_model.add_embedding(encoder_hidden_states)
elif base_model.config.addition_embed_type == "text_image":
raise NotImplementedError
raise NotImplementedError()
elif base_model.config.addition_embed_type == "text_time":
# SDXL - style
if "text_embeds" not in added_cond_kwargs:
@@ -676,9 +676,9 @@ class ControlNetXSModel(ModelMixin, ConfigMixin):
add_embeds = add_embeds.to(temb.dtype)
aug_emb = base_model.add_embedding(add_embeds)
elif base_model.config.addition_embed_type == "image":
raise NotImplementedError
raise NotImplementedError()
elif base_model.config.addition_embed_type == "image_hint":
raise NotImplementedError
raise NotImplementedError()
temb = temb + aug_emb if aug_emb is not None else temb
+8 -8
View File
@@ -518,8 +518,8 @@ class StableDiffusionXLControlNetXSPipeline(
)
if (
isinstance(self.controlnet, ControlNetXSModel)
or (is_compiled
and isinstance(self.controlnet._orig_mod, ControlNetXSModel))
or is_compiled
and isinstance(self.controlnet._orig_mod, ControlNetXSModel)
):
self.check_image(image, prompt, prompt_embeds)
else:
@@ -528,8 +528,8 @@ class StableDiffusionXLControlNetXSPipeline(
# Check `controlnet_conditioning_scale`
if (
isinstance(self.controlnet, ControlNetXSModel)
or (is_compiled
and isinstance(self.controlnet._orig_mod, ControlNetXSModel))
or is_compiled
and isinstance(self.controlnet._orig_mod, ControlNetXSModel)
):
if not isinstance(controlnet_conditioning_scale, float):
raise TypeError("For single controlnet: `controlnet_conditioning_scale` must be type `float`.")
@@ -1521,8 +1521,8 @@ class StableDiffusionControlNetXSPipeline(
)
if (
isinstance(self.controlnet, ControlNetXSModel)
or (is_compiled
and isinstance(self.controlnet._orig_mod, ControlNetXSModel))
or is_compiled
and isinstance(self.controlnet._orig_mod, ControlNetXSModel)
):
self.check_image(image, prompt, prompt_embeds)
else:
@@ -1531,8 +1531,8 @@ class StableDiffusionControlNetXSPipeline(
# Check `controlnet_conditioning_scale`
if (
isinstance(self.controlnet, ControlNetXSModel)
or (is_compiled
and isinstance(self.controlnet._orig_mod, ControlNetXSModel))
or is_compiled
and isinstance(self.controlnet._orig_mod, ControlNetXSModel)
):
if not isinstance(controlnet_conditioning_scale, float):
raise TypeError("For single controlnet: `controlnet_conditioning_scale` must be type `float`.")