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
@@ -789,10 +789,10 @@ class ConsistorySDXLUNet2DConditionModel(ModelMixin, ConfigMixin, UNet2DConditio
b2 (`float`): Scaling factor for stage 2 to amplify the contributions of backbone features.
"""
for i, upsample_block in enumerate(self.up_blocks):
upsample_block.s1 = s1
upsample_block.s2 = s2
upsample_block.b1 = b1
upsample_block.b2 = b2
setattr(upsample_block, "s1", s1)
setattr(upsample_block, "s2", s2)
setattr(upsample_block, "b1", b1)
setattr(upsample_block, "b2", b2)
def disable_freeu(self):
"""Disables the FreeU mechanism."""
+1 -1
View File
@@ -196,7 +196,7 @@ class ConsiStoryScript(scripts_manager.Script):
log.warning(f'ConsiStory: class={shared.sd_model.__class__.__name__} model={shared.sd_model_type} required={supported_model_list}')
return None
_subject, concepts, prompts, dropout, _sampler, steps, same, queries, sdsa, _freeu, _freeu_preset, alpha, injection = args # pylint: disable=unused-variable
subject, concepts, prompts, dropout, sampler, steps, same, queries, sdsa, freeu, _freeu_preset, alpha, injection = args # pylint: disable=unused-variable
self.create_model() # create model if not already done
concepts, anchors, prompts, alpha, steps, seed = self.set_args(p, *args) # set arguments
+1 -1
View File
@@ -3,7 +3,7 @@ import ast
import gradio as gr
from modules import scripts_manager
from modules.processing import Processed, get_processed
from modules.shared import cmd_opts # pylint: disable=unused-import
from modules.shared import opts, cmd_opts, state # pylint: disable=unused-import
def convertExpr2Expression(expr):
+1 -1
View File
@@ -1627,7 +1627,7 @@ class StableDiffusionDiffImg2ImgPipeline(DiffusionPipeline):
if isinstance(image[0], PIL.Image.Image):
w, h = image[0].size
w, h = map(lambda x: x - x % 8, (w, h)) # resize to integer multiple of 8
w, h = map(lambda x: x - x % 8, (w, h)) # resize to integer multiple of 8 # noqa: C417
image = [np.array(i.resize((w, h), resample=PIL_INTERPOLATION["lanczos"]))[None, :] for i in image]
image = np.concatenate(image, axis=0)
+1 -1
View File
@@ -1,5 +1,5 @@
import gradio as gr
from diffusers.pipelines import StableDiffusionPipeline # pylint: disable=unused-import
from diffusers.pipelines import StableDiffusionPipeline, StableDiffusionXLPipeline # pylint: disable=unused-import
from modules import shared, scripts_manager, processing, sd_models, devices
from modules.logger import log
+8 -8
View File
@@ -137,10 +137,10 @@ def register_free_upblock2d(model, b1=1.2, b2=1.4, s1=0.9, s2=0.2):
for i, upsample_block in enumerate(model.unet.up_blocks):
if isinstance_str(upsample_block, "UpBlock2D"):
upsample_block.forward = up_forward(upsample_block)
upsample_block.b1 = b1
upsample_block.b2 = b2
upsample_block.s1 = s1
upsample_block.s2 = s2
setattr(upsample_block, 'b1', b1)
setattr(upsample_block, 'b2', b2)
setattr(upsample_block, 's1', s1)
setattr(upsample_block, 's2', s2)
def register_crossattn_upblock2d(model):
@@ -300,7 +300,7 @@ def register_free_crossattn_upblock2d(model, b1=1.2, b2=1.4, s1=0.9, s2=0.2):
for i, upsample_block in enumerate(model.unet.up_blocks):
if isinstance_str(upsample_block, "CrossAttnUpBlock2D"):
upsample_block.forward = up_forward(upsample_block)
upsample_block.b1 = b1
upsample_block.b2 = b2
upsample_block.s1 = s1
upsample_block.s2 = s2
setattr(upsample_block, 'b1', b1)
setattr(upsample_block, 'b2', b2)
setattr(upsample_block, 's1', s1)
setattr(upsample_block, 's2', s2)
+1 -1
View File
@@ -18,7 +18,7 @@ def FeedForward(dim, mult=4):
def reshape_tensor(x, heads):
bs, length, _width = x.shape
bs, length, width = x.shape
#(bs, length, width) --> (bs, length, n_heads, dim_per_head)
x = x.view(bs, length, heads, -1)
# (bs, length, n_heads, dim_per_head) --> (bs, n_heads, length, dim_per_head)
+5 -5
View File
@@ -166,11 +166,11 @@ PREVIEWER_LORA_MODULES = [
def remove_attn2(model):
def recursive_find_module(name, module):
if "up_blocks" not in name and "down_blocks" not in name and "mid_block" not in name: return
if not "up_blocks" in name and not "down_blocks" in name and not "mid_block" in name: return
elif "resnets" in name: return
if hasattr(module, "attn2"):
module.attn2 = None
module.norm2 = None
setattr(module, "attn2", None)
setattr(module, "norm2", None)
return
for sub_name, sub_module in module.named_children():
recursive_find_module(f"{name}.{sub_name}", sub_module)
@@ -834,8 +834,8 @@ class InstantIRPipeline(
)
if (
isinstance(self.aggregator, Aggregator)
or (is_compiled
and isinstance(self.aggregator._orig_mod, Aggregator))
or is_compiled
and isinstance(self.aggregator._orig_mod, Aggregator)
):
self.check_image(image, prompt, prompt_embeds)
else:
+1
View File
@@ -71,6 +71,7 @@ class MoDScript(scripts_manager.Script):
from installer import install
install('ligo-segments')
try:
from ligo.segments import segment # pylint: disable=unused-import
return True
except Exception as e:
log.error(f'MoD: {e}')
+1
View File
@@ -17,6 +17,7 @@ def check_dependencies():
if not installed(pkg[1], quiet=True):
install(pkg[0], pkg[1], ignore=False)
try:
from ligo.segments import segment # pylint: disable=unused-import
checked_ok = True
return True
except Exception as e:
+1 -1
View File
@@ -798,7 +798,7 @@ class PromptEnhanceScript(scripts_manager.Script):
if debug_enabled:
errors.display(e, 'Prompt enhance')
self.busy = False
response = f'Error: {e!s}'
response = f'Error: {str(e)}'
finally:
offload_aux('prompt_enhance')
devices.torch_gc(force=False, reason='prompt-enhance')
+1 -1
View File
@@ -18,7 +18,7 @@ from .tokenizer import HFTokenizer, tokenize
from .utils import resize_clip_pos_embed, resize_evaclip_pos_embed, resize_visual_pos_embed, resize_eva_pos_embed
_MODEL_CONFIG_PATHS = [Path(__file__).parent / "model_configs/"]
_MODEL_CONFIG_PATHS = [Path(__file__).parent / f"model_configs/"]
_MODEL_CONFIGS = {} # directory (model_name: config) of model architecture configs
+1 -1
View File
@@ -14,7 +14,7 @@ try:
from transformers import AutoModel, AutoModelForMaskedLM, AutoTokenizer, AutoConfig, PretrainedConfig
from transformers.modeling_outputs import BaseModelOutput, BaseModelOutputWithPooling, \
BaseModelOutputWithPoolingAndCrossAttentions
except ImportError:
except ImportError as e:
transformers = None
+1 -1
View File
@@ -385,7 +385,7 @@ def build_model_from_openai_state_dict(
vocab_size = state_dict["token_embedding.weight"].shape[0]
transformer_width = state_dict["ln_final.weight"].shape[0]
transformer_heads = transformer_width // 64
transformer_layers = len(set(k.split(".")[2] for k in state_dict if k.startswith("transformer.resblocks")))
transformer_layers = len(set(k.split(".")[2] for k in state_dict if k.startswith(f"transformer.resblocks")))
vision_cfg = CLIPVisionCfg(
layers=vision_layers,
+1 -1
View File
@@ -110,7 +110,7 @@ class TimmModel(nn.Module):
def set_grad_checkpointing(self, enable=True):
try:
self.trunk.set_grad_checkpointing(enable)
except Exception:
except Exception as e:
logging.warning('grad checkpointing not supported for this timm image tower, continuing without...')
def forward(self, x):
+1
View File
@@ -12,6 +12,7 @@ import regex as re
import torch
# https://stackoverflow.com/q/62691279
import os
os.environ["TOKENIZERS_PARALLELISM"] = "false"
+1 -1
View File
@@ -149,7 +149,7 @@ def resize_rel_pos_embed(state_dict, model, interpolation: str = 'bicubic', seq_
dst_num_pos, _ = model.visual.state_dict()[key].size()
dst_patch_shape = model.visual.patch_embed.patch_shape
if dst_patch_shape[0] != dst_patch_shape[1]:
raise NotImplementedError
raise NotImplementedError()
num_extra_tokens = dst_num_pos - (dst_patch_shape[0] * 2 - 1) * (dst_patch_shape[1] * 2 - 1)
src_size = int((src_num_pos - num_extra_tokens) ** 0.5)
dst_size = int((dst_num_pos - num_extra_tokens) ** 0.5)
+1 -1
View File
@@ -6,7 +6,7 @@ from modules.logger import log
def apply_flux(pipe: FluxPipeline):
if not hasattr(pipe, 'transformer') or 'Nunchaku' not in pipe.transformer.__class__.__name__:
if not hasattr(pipe, 'transformer') or not 'Nunchaku' in pipe.transformer.__class__.__name__:
log.error('PuLID: flux support requires nunchaku')
return pipe
+1
View File
@@ -87,6 +87,7 @@ class SVDScript(scripts_manager.Script):
c = shared.sd_model.__class__.__name__
model_loaded = shared.sd_model.sd_checkpoint_info.model_name if shared.sd_loaded else None
if model_name != model_loaded or c != 'StableVideoDiffusionPipeline':
from diffusers import StableVideoDiffusionPipeline # pylint: disable=unused-import
shared.opts.sd_model_checkpoint = model_path
sd_models.reload_model_weights()
shared.sd_model._encode_vae_image = self._encode_image # pylint: disable=protected-access
+1
View File
@@ -34,6 +34,7 @@ from scripts.xyz.xyz_grid_shared import ( # pylint: disable=no-name-in-module, u
apply_control,
format_value_add_label,
format_bool,
format_value,
format_value_join_list,
do_nothing,
format_nothing,
+1
View File
@@ -11,6 +11,7 @@ import gradio as gr
from scripts.xyz.xyz_grid_shared import str_permutations, list_to_csv_string, restore_comma, re_range, re_plain_comma # pylint: disable=no-name-in-module
from scripts.xyz.xyz_grid_classes import axis_options, AxisOption, SharedSettingsStackHelper # pylint: disable=no-name-in-module
from scripts.xyz.xyz_grid_draw import draw_xyz_grid # pylint: disable=no-name-in-module
from scripts.xyz.xyz_grid_shared import apply_field, apply_task_args, apply_setting, apply_prompt, apply_order, apply_sampler, apply_hr_sampler_name, confirm_samplers, apply_checkpoint, apply_refiner, apply_unet, apply_clip_skip, apply_vae, list_lora, apply_lora, apply_lora_strength, apply_te, apply_styles, apply_upscaler, apply_context, apply_detailer, apply_override, apply_processing, apply_options, apply_seed, format_value_add_label, format_value, format_value_join_list, do_nothing, format_nothing # pylint: disable=no-name-in-module, unused-import
from modules import shared, errors, scripts_manager, images, video, processing
from modules.ui_components import ToolButton
from modules.ui_sections import create_video_inputs