diff --git a/CHANGELOG.md b/CHANGELOG.md index b1a112d43..f6e275904 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,12 +1,12 @@ # Change Log for SD.Next -## Update for 2026-05-11 +## Update for 2026-05-10 -### Highlights for 2026-05-11 +### Highlights for 2026-05-10 *What's New?* - Image editing models now can work with multiple image inputs! -- Five new base models: *HiDream-O1 Image*, *JoyAI Image Edit*, *Step1X-Edit*, *VIBE Image Edit* and *UltraFlux* +- New models: *HiDream-O1 Image*, *JoyAI Image Edit*, *Step1X-Edit*, *VIBE Image Edit* and *UltraFlux* - Enhanced capabilities for *Anima*, *Ernie-Image*, *LTX*, *Flux.2* and *Chroma* models - UI improvements accross the board: *Main panels*, *Gallery*, *Kanvas*, and more... @@ -14,7 +14,7 @@ For full details, see [ChangeLog](https://github.com/vladmandic/automatic/blob/m [ReadMe](https://github.com/vladmandic/automatic/blob/master/README.md) | [ChangeLog](https://github.com/vladmandic/automatic/blob/master/CHANGELOG.md) | [Docs](https://vladmandic.github.io/sdnext-docs/) | [WiKi](https://github.com/vladmandic/automatic/wiki) | [Discord](https://discord.com/invite/sd-next-federal-batch-inspectors-1101998836328697867) | [Sponsor](https://github.com/sponsors/vladmandic) -### Details for 2026-05-11 +### Details for 2026-05-10 - **Models** - [HiDream-O1-Image](https://huggingface.co/HiDream-ai/HiDream-O1-Image) pixel-level unified transformer model support @@ -22,7 +22,6 @@ For full details, see [ChangeLog](https://github.com/vladmandic/automatic/blob/m includes both **HiDream-O1-Image** *(base)* and **HiDream-O1-Image-Dev** *(distilled*)* variants includes *T2I* and *I2I edit* capabilities and resolutions up to 2048px *note*: use steps:50 for base and steps:28 for dev variants - *note*: when using quantization, make sure that quantized matmul is disabled, otherwise quality degrades significantly - [JoyAI Image Edit](https://huggingface.co/jdopensource/JoyAI-Image-Edit-Diffusers) image-editing model support includes multimodal conditioning using *Qwen3-VL* with a dedicated *JoyImageEdit* diffusion transformer *note* this is a large model at 50GB so use of agressive quantization is recommended @@ -55,7 +54,6 @@ For full details, see [ChangeLog](https://github.com/vladmandic/automatic/blob/m - custom **VAE** loader for all pipelines *note*: vae still needs to be compatible with the model - **CivitAI** downloaded thumbnails now include metadata - - **Installer** support for `git+http` style references - **UI** - **Networks** using networks to load model or auto-download a reference model will now be reflected in the UI - ability to manually reorient *input/output* panels @@ -81,7 +79,6 @@ For full details, see [ChangeLog](https://github.com/vladmandic/automatic/blob/m - remove obsolete `lora` stepwise and functional code, thanks @awsr - interrupt model loading between components - patch `rich` for cleaner exception logging - - stricter `ruff` linting - **Fixes** - add missing `jquery` and `sparkline` js scripts - save handle already decoded images diff --git a/cli/api-samplers.py b/cli/api-samplers.py index 7371ed0de..c63baf37c 100755 --- a/cli/api-samplers.py +++ b/cli/api-samplers.py @@ -4,6 +4,7 @@ get list of all samplers and details of current sampler """ +import sys import logging import urllib3 import requests diff --git a/modules/api/endpoints.py b/modules/api/endpoints.py index 3c96449a7..eec9f3666 100644 --- a/modules/api/endpoints.py +++ b/modules/api/endpoints.py @@ -361,7 +361,7 @@ def get_deletefile(file: str): return {"deleted": f"{file}"} except Exception as e: log.error(f'Delete: file="{file}" error: {e}') - raise HTTPException(status_code=500, detail=f"error deleting file {file}: {e!s}") from e + raise HTTPException(status_code=500, detail=f"error deleting file {file}: {str(e)}") from e def get_deleteimage(file: str): import os @@ -383,7 +383,7 @@ def get_deleteimage(file: str): return {"deleted": f"{file}"} except Exception as e: log.error(f'Delete: file="{file}" error: {e}') - raise HTTPException(status_code=500, detail=f"error deleting file {file}: {e!s}") from e + raise HTTPException(status_code=500, detail=f"error deleting file {file}: {str(e)}") from e def get_pnginfo(file: str): """Extract generation parameters from a image file path. Returns raw info string and parsed parameters dict.""" diff --git a/modules/api/middleware.py b/modules/api/middleware.py index 4a3ef052d..db42d901d 100644 --- a/modules/api/middleware.py +++ b/modules/api/middleware.py @@ -44,7 +44,7 @@ def setup_middleware(app: FastAPI, cmd_opts): client = req.scope.get('client', ('0:0.0.0', 0))[0] token = req.cookies.get("access-token") or req.cookies.get("access-token-unsecure") validate_request(client, endpoint) - if cmd_opts.api_log: + if (cmd_opts.api_log): if not validate_log(client, endpoint): return res log.info('API user={user} code={code} {prot}/{ver} {method} {endpoint} {client} {duration}'.format( # pylint: disable=consider-using-f-string, logging-format-interpolation diff --git a/modules/api/validate.py b/modules/api/validate.py index 3ba4f774a..1ff77be75 100644 --- a/modules/api/validate.py +++ b/modules/api/validate.py @@ -9,7 +9,6 @@ request_cost = { "/run/predict": 0, "/sdapi/v1/browser/thumb": 0, "/sdapi/v1/network/thumb": 0, - "/sdapi/v1/gpu-smi": 0, "/sdapi/v1/txt2img": 5, "/sdapi/v1/img2img": 5, "/sdapi/v1/control": 5, diff --git a/modules/caption/joycaption.py b/modules/caption/joycaption.py index 905f932da..a18b46800 100644 --- a/modules/caption/joycaption.py +++ b/modules/caption/joycaption.py @@ -65,7 +65,7 @@ def load(repo: str | None = None): if llava_model is None or opts.repo != repo: opts.repo = repo llava_model = None - log.info(f'Caption: type=vlm model="JoyCaption" {opts!s}') + log.info(f'Caption: type=vlm model="JoyCaption" {str(opts)}') processor = AutoProcessor.from_pretrained(repo, max_pixels=1024*1024, cache_dir=shared.opts.hfcache_dir) quant_args = model_quant.create_config(module='LLM') llava_model = LlavaForConditionalGeneration.from_pretrained( diff --git a/modules/caption/moondream3.py b/modules/caption/moondream3.py index c3bb8bfc7..7859f0f06 100644 --- a/modules/caption/moondream3.py +++ b/modules/caption/moondream3.py @@ -402,7 +402,7 @@ def predict(question: str, image: Image.Image, repo: str, model_name: str | None except Exception as e: from modules import errors errors.display(e, 'Moondream3') - return f"Error: {e!s}" + return f"Error: {str(e)}" finally: offload_aux('moondream3') diff --git a/modules/caption/vqa.py b/modules/caption/vqa.py index 6655a25e6..74cc3cdca 100644 --- a/modules/caption/vqa.py +++ b/modules/caption/vqa.py @@ -13,7 +13,7 @@ from modules import shared, devices, errors, model_quant, sd_models, sd_models_c from modules.sd_offload_aux import register_aux, deregister_aux, move_aux_to_gpu, offload_aux from modules.logger import log, console from modules.caption import vqa_detection -from modules.caption.models_def import vlm_models, vlm_prefill, vlm_prompt_mapping, vlm_prompt_placeholders, vlm_prompts_common, vlm_prompts_florence, vlm_prompts_moondream, vlm_prompts_moondream2, vlm_prompts_promptgen, get_vlm_repo +from modules.caption.models_def import vlm_models, vlm_system, vlm_default, vlm_prefill, vlm_prompts, vlm_prompt_mapping, vlm_prompt_placeholders, vlm_prompts_common, vlm_prompts_florence, vlm_prompts_moondream, vlm_prompts_moondream2, vlm_prompts_promptgen, get_vlm_repo # Debug logging - function-based to avoid circular import debug_enabled = os.environ.get('SD_CAPTION_DEBUG', None) is not None diff --git a/modules/cfgzero/cogview4_pipeline.py b/modules/cfgzero/cogview4_pipeline.py index 07c6a8383..472c2eb72 100644 --- a/modules/cfgzero/cogview4_pipeline.py +++ b/modules/cfgzero/cogview4_pipeline.py @@ -191,7 +191,7 @@ class CogView4CFGZeroPipeline(DiffusionPipeline, CogView4LoraLoaderMixin): def _get_glm_embeds( self, - prompt: Union[str, List[str]] | None = None, + prompt: Union[str, List[str]] = None, max_sequence_length: int = 1024, device: Optional[torch.device] = None, dtype: Optional[torch.dtype] = None, diff --git a/modules/cfgzero/flux_pipeline.py b/modules/cfgzero/flux_pipeline.py index e42d7baa1..362a434e4 100644 --- a/modules/cfgzero/flux_pipeline.py +++ b/modules/cfgzero/flux_pipeline.py @@ -217,7 +217,7 @@ class FluxCFGZeroPipeline( def _get_t5_prompt_embeds( self, - prompt: Union[str, List[str]] | None = None, + prompt: Union[str, List[str]] = None, num_images_per_prompt: int = 1, max_sequence_length: int = 512, device: Optional[torch.device] = None, @@ -535,7 +535,7 @@ class FluxCFGZeroPipeline( @staticmethod def _unpack_latents(latents, height, width, vae_scale_factor): - batch_size, _num_patches, channels = latents.shape + batch_size, num_patches, channels = latents.shape # VAE applies 8x compression on images but we must also account for packing which requires # latent height and width to be divisible by 2. @@ -637,9 +637,9 @@ class FluxCFGZeroPipeline( @replace_example_docstring(EXAMPLE_DOC_STRING) def __call__( self, - prompt: Union[str, List[str]] | None = None, + prompt: Union[str, List[str]] = None, prompt_2: Optional[Union[str, List[str]]] = None, - negative_prompt: Union[str, List[str]] | None = None, + negative_prompt: Union[str, List[str]] = None, negative_prompt_2: Optional[Union[str, List[str]]] = None, true_cfg_scale: float = 1.0, height: Optional[int] = None, diff --git a/modules/cfgzero/hidream_pipeline.py b/modules/cfgzero/hidream_pipeline.py index edfd47d78..9eaff0878 100644 --- a/modules/cfgzero/hidream_pipeline.py +++ b/modules/cfgzero/hidream_pipeline.py @@ -211,7 +211,7 @@ class HiDreamImageCFGZeroPipeline(DiffusionPipeline, HiDreamImageLoraLoaderMixin def _get_t5_prompt_embeds( self, - prompt: Union[str, List[str]] | None = None, + prompt: Union[str, List[str]] = None, max_sequence_length: int = 128, device: Optional[torch.device] = None, dtype: Optional[torch.dtype] = None, @@ -285,7 +285,7 @@ class HiDreamImageCFGZeroPipeline(DiffusionPipeline, HiDreamImageLoraLoaderMixin def _get_llama3_prompt_embeds( self, - prompt: Union[str, List[str]] | None = None, + prompt: Union[str, List[str]] = None, max_sequence_length: int = 128, device: Optional[torch.device] = None, dtype: Optional[torch.dtype] = None, @@ -545,7 +545,7 @@ class HiDreamImageCFGZeroPipeline(DiffusionPipeline, HiDreamImageLoraLoaderMixin @torch.no_grad() def __call__( self, - prompt: Union[str, List[str]] | None = None, + prompt: Union[str, List[str]] = None, prompt_2: Optional[Union[str, List[str]]] = None, prompt_3: Optional[Union[str, List[str]]] = None, prompt_4: Optional[Union[str, List[str]]] = None, diff --git a/modules/cfgzero/hunyuan_t2v_pipeline.py b/modules/cfgzero/hunyuan_t2v_pipeline.py index 0f880f576..8494b9b96 100644 --- a/modules/cfgzero/hunyuan_t2v_pipeline.py +++ b/modules/cfgzero/hunyuan_t2v_pipeline.py @@ -317,7 +317,7 @@ class HunyuanVideoCFGZeroPipeline(DiffusionPipeline, HunyuanVideoLoraLoaderMixin def encode_prompt( self, prompt: Union[str, List[str]], - prompt_2: Union[str, List[str]] | None = None, + prompt_2: Union[str, List[str]] = None, prompt_template: Dict[str, Any] = DEFAULT_PROMPT_TEMPLATE, num_videos_per_prompt: int = 1, prompt_embeds: Optional[torch.Tensor] = None, @@ -481,15 +481,15 @@ class HunyuanVideoCFGZeroPipeline(DiffusionPipeline, HunyuanVideoLoraLoaderMixin @replace_example_docstring(EXAMPLE_DOC_STRING) def __call__( self, - prompt: Union[str, List[str]] | None = None, - prompt_2: Union[str, List[str]] | None = None, - negative_prompt: Union[str, List[str]] | None = None, - negative_prompt_2: Union[str, List[str]] | None = None, + prompt: Union[str, List[str]] = None, + prompt_2: Union[str, List[str]] = None, + negative_prompt: Union[str, List[str]] = None, + negative_prompt_2: Union[str, List[str]] = None, height: int = 720, width: int = 1280, num_frames: int = 129, num_inference_steps: int = 50, - sigmas: List[float] | None = None, + sigmas: List[float] = None, true_cfg_scale: float = 1.0, guidance_scale: float = 6.0, num_videos_per_prompt: Optional[int] = 1, diff --git a/modules/cfgzero/sd3_pipeline.py b/modules/cfgzero/sd3_pipeline.py index 1cae06511..946571d81 100644 --- a/modules/cfgzero/sd3_pipeline.py +++ b/modules/cfgzero/sd3_pipeline.py @@ -246,7 +246,7 @@ class StableDiffusion3CFGZeroPipeline(DiffusionPipeline, SD3LoraLoaderMixin, Fro def _get_t5_prompt_embeds( self, - prompt: Union[str, List[str]] | None = None, + prompt: Union[str, List[str]] = None, num_images_per_prompt: int = 1, max_sequence_length: int = 256, device: Optional[torch.device] = None, @@ -786,7 +786,7 @@ class StableDiffusion3CFGZeroPipeline(DiffusionPipeline, SD3LoraLoaderMixin, Fro @replace_example_docstring(EXAMPLE_DOC_STRING) def __call__( self, - prompt: Union[str, List[str]] | None = None, + prompt: Union[str, List[str]] = None, prompt_2: Optional[Union[str, List[str]]] = None, prompt_3: Optional[Union[str, List[str]]] = None, height: Optional[int] = None, @@ -813,7 +813,7 @@ class StableDiffusion3CFGZeroPipeline(DiffusionPipeline, SD3LoraLoaderMixin, Fro callback_on_step_end: Optional[Callable[[int, int, Dict], None]] = None, callback_on_step_end_tensor_inputs: List[str] = ["latents"], max_sequence_length: int = 256, - skip_guidance_layers: List[int] | None = None, + skip_guidance_layers: List[int] = None, skip_layer_guidance_scale: float = 2.8, skip_layer_guidance_stop: float = 0.2, skip_layer_guidance_start: float = 0.01, diff --git a/modules/cfgzero/wan_t2v_pipeline.py b/modules/cfgzero/wan_t2v_pipeline.py index 4660b2360..9cc0fa529 100644 --- a/modules/cfgzero/wan_t2v_pipeline.py +++ b/modules/cfgzero/wan_t2v_pipeline.py @@ -153,7 +153,7 @@ class WanCFGZeroPipeline(DiffusionPipeline, WanLoraLoaderMixin): def _get_t5_prompt_embeds( self, - prompt: Union[str, List[str]] | None = None, + prompt: Union[str, List[str]] = None, num_videos_per_prompt: int = 1, max_sequence_length: int = 226, device: Optional[torch.device] = None, @@ -374,8 +374,8 @@ class WanCFGZeroPipeline(DiffusionPipeline, WanLoraLoaderMixin): @replace_example_docstring(EXAMPLE_DOC_STRING) def __call__( self, - prompt: Union[str, List[str]] | None = None, - negative_prompt: Union[str, List[str]] | None = None, + prompt: Union[str, List[str]] = None, + negative_prompt: Union[str, List[str]] = None, height: int = 480, width: int = 832, num_frames: int = 81, diff --git a/modules/civitai/metadata_civitai.py b/modules/civitai/metadata_civitai.py index 88f50a1da..258cb8143 100644 --- a/modules/civitai/metadata_civitai.py +++ b/modules/civitai/metadata_civitai.py @@ -93,7 +93,7 @@ def civit_update_metadata(raw: bool = False): model.latest_name = f.get('name', '') if model.vername == model.latest: model.status = 'Latest version' - elif any(map(lambda v: v in model.latest_hashes, all_hashes)): # pylint: disable=cell-var-from-loop + elif any(map(lambda v: v in model.latest_hashes, all_hashes)): # pylint: disable=cell-var-from-loop # noqa: C417 model.status = 'Update downloaded' else: model.status = 'Update available' diff --git a/modules/control/proc/canny.py b/modules/control/proc/canny.py index ad0113a92..1e4bb3176 100644 --- a/modules/control/proc/canny.py +++ b/modules/control/proc/canny.py @@ -7,7 +7,7 @@ from modules.control.util import HWC3, resize_image class CannyDetector: def __call__(self, input_image=None, low_threshold=100, high_threshold=200, detect_resolution=512, image_resolution=512, output_type=None, **kwargs): if "img" in kwargs: - warnings.warn("img is deprecated, please use `input_image=...` instead.", DeprecationWarning, stacklevel=2) + warnings.warn("img is deprecated, please use `input_image=...` instead.", DeprecationWarning) input_image = kwargs.pop("img") if input_image is None: raise ValueError("input_image must be defined.") diff --git a/modules/control/proc/depth_anything/util/transform.py b/modules/control/proc/depth_anything/util/transform.py index 21bc0c146..d542fefee 100644 --- a/modules/control/proc/depth_anything/util/transform.py +++ b/modules/control/proc/depth_anything/util/transform.py @@ -1,4 +1,7 @@ +import random +from PIL import Image, ImageOps, ImageFilter import torch +from torchvision import transforms import torch.nn.functional as F import numpy as np diff --git a/modules/control/proc/depth_pro/__init__.py b/modules/control/proc/depth_pro/__init__.py index f0f74852e..e9bd20793 100644 --- a/modules/control/proc/depth_pro/__init__.py +++ b/modules/control/proc/depth_pro/__init__.py @@ -16,7 +16,7 @@ class DepthProDetector: self.processor = processor @classmethod - def from_pretrained(cls, pretrained_model_or_path: str = "apple/DepthPro-hf", cache_dir: str | None = None, local_files_only = False) -> "DepthProDetector": + def from_pretrained(cls, pretrained_model_or_path: str = "apple/DepthPro-hf", cache_dir: str = None, local_files_only = False) -> "DepthProDetector": from transformers import AutoImageProcessor, DepthProForDepthEstimation processor = AutoImageProcessor.from_pretrained(pretrained_model_or_path, cache_dir=cache_dir, local_files_only=local_files_only) diff --git a/modules/control/proc/edge.py b/modules/control/proc/edge.py index 9de932172..f91ab83bb 100644 --- a/modules/control/proc/edge.py +++ b/modules/control/proc/edge.py @@ -33,7 +33,7 @@ class EdgeDetector: params.PFmode = pf ed.setParams(params) if "img" in kwargs: - warnings.warn("img is deprecated, please use `input_image=...` instead.", DeprecationWarning, stacklevel=2) + warnings.warn("img is deprecated, please use `input_image=...` instead.", DeprecationWarning) input_image = kwargs.pop("img") if input_image is None: raise ValueError("input_image must be defined.") diff --git a/modules/control/proc/leres/leres/Resnext_torch.py b/modules/control/proc/leres/leres/Resnext_torch.py index e45d52176..1a3dac630 100644 --- a/modules/control/proc/leres/leres/Resnext_torch.py +++ b/modules/control/proc/leres/leres/Resnext_torch.py @@ -5,7 +5,7 @@ import torch.nn as nn try: from urllib import urlretrieve except ImportError: - pass + from urllib.request import urlretrieve __all__ = ['resnext101_32x8d'] diff --git a/modules/control/proc/leres/leres/multi_depth_model_woauxi.py b/modules/control/proc/leres/leres/multi_depth_model_woauxi.py index bb5286f44..c1266bef1 100644 --- a/modules/control/proc/leres/leres/multi_depth_model_woauxi.py +++ b/modules/control/proc/leres/leres/multi_depth_model_woauxi.py @@ -1,3 +1,4 @@ +import torch import torch.nn as nn from . import network_auxi as network diff --git a/modules/control/proc/leres/leres/network_auxi.py b/modules/control/proc/leres/leres/network_auxi.py index 5e9688832..34007c9c9 100644 --- a/modules/control/proc/leres/leres/network_auxi.py +++ b/modules/control/proc/leres/leres/network_auxi.py @@ -384,7 +384,7 @@ class SenceUnderstand(nn.Module): self.initial_params() def forward(self, x): - n, _c, h, w = x.size() + n, c, h, w = x.size() x = self.conv1(x) x = self.pool(x) x = x.view(n, -1) diff --git a/modules/control/proc/leres/pix2pix/options/base_options.py b/modules/control/proc/leres/pix2pix/options/base_options.py index a48914fba..533a1e88a 100644 --- a/modules/control/proc/leres/pix2pix/options/base_options.py +++ b/modules/control/proc/leres/pix2pix/options/base_options.py @@ -1,8 +1,8 @@ import argparse import os -from ...pix2pix.util import util # noqa: TID252 +from ...pix2pix.util import util # import torch -from ...pix2pix import models # noqa: TID252 +from ...pix2pix import models # import pix2pix.data import numpy as np diff --git a/modules/control/proc/marigold/marigold_pipeline.py b/modules/control/proc/marigold/marigold_pipeline.py index 4ab8c0495..768c67684 100644 --- a/modules/control/proc/marigold/marigold_pipeline.py +++ b/modules/control/proc/marigold/marigold_pipeline.py @@ -113,7 +113,7 @@ class MarigoldPipeline(DiffusionPipeline): batch_size: int = 0, color_map: str = "Spectral", show_progress_bar: bool = True, - ensemble_kwargs: Dict | None = None, + ensemble_kwargs: Dict = None, ) -> MarigoldDepthOutput: """ Function invoked when calling the pipeline. diff --git a/modules/control/proc/marigold/util/ensemble.py b/modules/control/proc/marigold/util/ensemble.py index 1139b5554..710db1cc2 100644 --- a/modules/control/proc/marigold/util/ensemble.py +++ b/modules/control/proc/marigold/util/ensemble.py @@ -43,7 +43,7 @@ def ensemble_depths( max_iter: int = 2, tol: float = 1e-3, reduction: str = "median", - max_res: int | None = None, + max_res: int = None, ): """ To ensemble multiple affine-invariant depth images (up to scale and shift), diff --git a/modules/control/proc/marigold/util/seed_all.py b/modules/control/proc/marigold/util/seed_all.py index b3cdcaae5..b09006c9b 100644 --- a/modules/control/proc/marigold/util/seed_all.py +++ b/modules/control/proc/marigold/util/seed_all.py @@ -28,6 +28,6 @@ def seed_all(seed: int = 0): Set random seeds of all components. """ random.seed(seed) - np.random.seed(seed) + np.random.seed(seed) # noqa torch.manual_seed(seed) torch.cuda.manual_seed_all(seed) diff --git a/modules/control/proc/mediapipe_face.py b/modules/control/proc/mediapipe_face.py index a8f24533b..ceda9f857 100644 --- a/modules/control/proc/mediapipe_face.py +++ b/modules/control/proc/mediapipe_face.py @@ -16,6 +16,7 @@ def check_dependencies(): if not installed(pkg[1], quiet=True): install(pkg[0], pkg[1], ignore=False) try: + import mediapipe as mp # pylint: disable=unused-import checked_ok = True return True except Exception as e: diff --git a/modules/control/proc/midas/api.py b/modules/control/proc/midas/api.py index 724700c30..c08c02cdd 100644 --- a/modules/control/proc/midas/api.py +++ b/modules/control/proc/midas/api.py @@ -2,6 +2,7 @@ import cv2 import os +import torch import torch.nn as nn from torchvision.transforms import Compose diff --git a/modules/control/proc/midas/midas/blocks.py b/modules/control/proc/midas/midas/blocks.py index 9281efd1d..861687fe3 100644 --- a/modules/control/proc/midas/midas/blocks.py +++ b/modules/control/proc/midas/midas/blocks.py @@ -5,6 +5,7 @@ from .vit import ( _make_pretrained_vitb_rn50_384, _make_pretrained_vitl16_384, _make_pretrained_vitb16_384, + forward_vit, ) def _make_encoder(backbone, features, use_pretrained, groups=1, expand=False, exportable=True, hooks=None, use_vit_only=False, use_readout="ignore",): diff --git a/modules/control/proc/midas/midas/dpt_depth.py b/modules/control/proc/midas/midas/dpt_depth.py index 81d46d4d1..600a42cd8 100644 --- a/modules/control/proc/midas/midas/dpt_depth.py +++ b/modules/control/proc/midas/midas/dpt_depth.py @@ -1,8 +1,10 @@ import torch import torch.nn as nn +import torch.nn.functional as F from .base_model import BaseModel from .blocks import ( + FeatureFusionBlock, FeatureFusionBlock_custom, Interpolate, _make_encoder, diff --git a/modules/control/proc/midas/midas/midas_net_custom.py b/modules/control/proc/midas/midas/midas_net_custom.py index 7f09df0a6..cba1bcfff 100644 --- a/modules/control/proc/midas/midas/midas_net_custom.py +++ b/modules/control/proc/midas/midas/midas_net_custom.py @@ -6,7 +6,7 @@ import torch import torch.nn as nn from .base_model import BaseModel -from .blocks import FeatureFusionBlock_custom, Interpolate, _make_encoder +from .blocks import FeatureFusionBlock, FeatureFusionBlock_custom, Interpolate, _make_encoder class MidasNet_small(BaseModel): diff --git a/modules/control/proc/midas/midas/vit.py b/modules/control/proc/midas/midas/vit.py index 0f2aae284..f268a9fc4 100644 --- a/modules/control/proc/midas/midas/vit.py +++ b/modules/control/proc/midas/midas/vit.py @@ -54,7 +54,7 @@ class Transpose(nn.Module): def forward_vit(pretrained, x): - _b, _c, h, w = x.shape + b, c, h, w = x.shape pretrained.model.forward_flex(x) @@ -115,7 +115,7 @@ def _resize_pos_embed(self, posemb, gs_h, gs_w): def forward_flex(self, x): - _b, _c, h, w = x.shape + b, c, h, w = x.shape pos_embed = self._resize_pos_embed( self.pos_embed, h // self.patch_size[1], w // self.patch_size[0] diff --git a/modules/control/proc/midas/utils.py b/modules/control/proc/midas/utils.py index f3de55e64..9a9d3b5b6 100644 --- a/modules/control/proc/midas/utils.py +++ b/modules/control/proc/midas/utils.py @@ -75,7 +75,7 @@ def write_pfm(path, image, scale=1): if len(image.shape) == 3 and image.shape[2] == 3: # color image color = True elif ( - len(image.shape) == 2 or (len(image.shape) == 3 and image.shape[2] == 1) + len(image.shape) == 2 or len(image.shape) == 3 and image.shape[2] == 1 ): # greyscale color = False else: @@ -86,7 +86,7 @@ def write_pfm(path, image, scale=1): endian = image.dtype.byteorder - if endian == "<" or (endian == "=" and sys.byteorder == "little"): + if endian == "<" or endian == "=" and sys.byteorder == "little": scale = -scale file.write("%f\n".encode() % scale) diff --git a/modules/control/proc/mlsd/models/mbv2_mlsd_large.py b/modules/control/proc/mlsd/models/mbv2_mlsd_large.py index 1e27a788f..39acf8dd5 100644 --- a/modules/control/proc/mlsd/models/mbv2_mlsd_large.py +++ b/modules/control/proc/mlsd/models/mbv2_mlsd_large.py @@ -1,3 +1,5 @@ +import os +import sys import torch import torch.nn as nn import torch.utils.model_zoo as model_zoo diff --git a/modules/control/proc/mlsd/models/mbv2_mlsd_tiny.py b/modules/control/proc/mlsd/models/mbv2_mlsd_tiny.py index 38ffe3e8d..4f043851e 100644 --- a/modules/control/proc/mlsd/models/mbv2_mlsd_tiny.py +++ b/modules/control/proc/mlsd/models/mbv2_mlsd_tiny.py @@ -1,3 +1,5 @@ +import os +import sys import torch import torch.nn as nn import torch.utils.model_zoo as model_zoo diff --git a/modules/control/proc/mlsd/utils.py b/modules/control/proc/mlsd/utils.py index 246a45741..ca8034370 100644 --- a/modules/control/proc/mlsd/utils.py +++ b/modules/control/proc/mlsd/utils.py @@ -9,6 +9,7 @@ Copyright 2021-present NAVER Corp. Apache License v2.0 ''' +import os import numpy as np import cv2 import torch @@ -21,7 +22,7 @@ def deccode_output_score_and_ptss(tpMap, topk_n = 200, ksize = 5): center: tpMap[1, 0, :, :] displacement: tpMap[1, 1:5, :, :] ''' - b, _c, _h, w = tpMap.shape + b, c, h, w = tpMap.shape assert b==1, 'only support bsize==1' displacement = tpMap[:, 1:5, :, :][0] center = tpMap[:, 0, :, :] @@ -470,9 +471,9 @@ def pred_squares(image, square[end_idx] # check whether outside or inside - _start_position, start_min, start_cover_param, start_peri_param = check_outside_inside(start_segments, + start_position, start_min, start_cover_param, start_peri_param = check_outside_inside(start_segments, connect_idx) - _end_position, end_min, end_cover_param, end_peri_param = check_outside_inside(end_segments, connect_idx) + end_position, end_min, end_cover_param, end_peri_param = check_outside_inside(end_segments, connect_idx) cover += dist_segments[connect_idx] + start_cover_param * start_min + end_cover_param * end_min perimeter += dist_segments[connect_idx] + start_peri_param * start_min + end_peri_param * end_min diff --git a/modules/control/proc/openpose/__init__.py b/modules/control/proc/openpose/__init__.py index 4d4c72911..746351718 100644 --- a/modules/control/proc/openpose/__init__.py +++ b/modules/control/proc/openpose/__init__.py @@ -194,14 +194,14 @@ class OpenposeDetector: def __call__(self, input_image, detect_resolution=512, image_resolution=512, include_body=True, include_hand=False, include_face=False, hand_and_face=None, output_type="pil", **kwargs): self.to(devices.device) if hand_and_face is not None: - warnings.warn("hand_and_face is deprecated. Use include_hand and include_face instead.", DeprecationWarning, stacklevel=2) + warnings.warn("hand_and_face is deprecated. Use include_hand and include_face instead.", DeprecationWarning) include_hand = hand_and_face include_face = hand_and_face if "return_pil" in kwargs: - warnings.warn("return_pil is deprecated. Use output_type instead.", DeprecationWarning, stacklevel=2) + warnings.warn("return_pil is deprecated. Use output_type instead.", DeprecationWarning) output_type = "pil" if kwargs["return_pil"] else "np" if type(output_type) is bool: - warnings.warn("Passing `True` or `False` to `output_type` is deprecated and will raise an error in future versions", stacklevel=2) + warnings.warn("Passing `True` or `False` to `output_type` is deprecated and will raise an error in future versions") if output_type: output_type = "pil" if not isinstance(input_image, np.ndarray): diff --git a/modules/control/proc/openpose/face.py b/modules/control/proc/openpose/face.py index 43e7d04cb..e8e34451c 100644 --- a/modules/control/proc/openpose/face.py +++ b/modules/control/proc/openpose/face.py @@ -328,7 +328,7 @@ class Face(object): def __call__(self, face_img): device = next(iter(self.model.parameters())).device - H, W, _C = face_img.shape + H, W, C = face_img.shape w_size = 384 x_data = torch.from_numpy(util.smart_resize(face_img, (w_size, w_size))).permute([2, 0, 1]) / 256.0 - 0.5 diff --git a/modules/control/proc/openpose/hand.py b/modules/control/proc/openpose/hand.py index 576ad7172..78e00213e 100644 --- a/modules/control/proc/openpose/hand.py +++ b/modules/control/proc/openpose/hand.py @@ -32,7 +32,7 @@ class Hand(object): wsize = 128 heatmap_avg = np.zeros((wsize, wsize, 22)) - Hr, Wr, _Cr = oriImgRaw.shape + Hr, Wr, Cr = oriImgRaw.shape oriImg = cv2.GaussianBlur(oriImgRaw, (0, 0), 0.8) diff --git a/modules/control/proc/segment_anything/__init__.py b/modules/control/proc/segment_anything/__init__.py index a86c7d6d7..121421c18 100644 --- a/modules/control/proc/segment_anything/__init__.py +++ b/modules/control/proc/segment_anything/__init__.py @@ -53,7 +53,7 @@ class SamDetector: def __call__(self, input_image: Union[np.ndarray, Image.Image]=None, detect_resolution=512, image_resolution=512, output_type="pil", **kwargs) -> Image.Image: if "image" in kwargs: - warnings.warn("image is deprecated, please use `input_image=...` instead.", DeprecationWarning, stacklevel=2) + warnings.warn("image is deprecated, please use `input_image=...` instead.", DeprecationWarning) input_image = kwargs.pop("image") if input_image is None: raise ValueError("input_image must be defined.") diff --git a/modules/control/proc/segment_anything/modeling/sam.py b/modules/control/proc/segment_anything/modeling/sam.py index a056a7215..614fd7483 100644 --- a/modules/control/proc/segment_anything/modeling/sam.py +++ b/modules/control/proc/segment_anything/modeling/sam.py @@ -25,8 +25,8 @@ class Sam(nn.Module): image_encoder: Union[ImageEncoderViT, TinyViT], prompt_encoder: PromptEncoder, mask_decoder: MaskDecoder, - pixel_mean: List[float] | None = None, - pixel_std: List[float] | None = None, + pixel_mean: List[float] = None, + pixel_std: List[float] = None, ) -> None: """ SAM predicts object masks from an image and input prompts. diff --git a/modules/control/proc/segment_anything/modeling/transformer.py b/modules/control/proc/segment_anything/modeling/transformer.py index 5d6155002..28fafea52 100644 --- a/modules/control/proc/segment_anything/modeling/transformer.py +++ b/modules/control/proc/segment_anything/modeling/transformer.py @@ -79,7 +79,7 @@ class TwoWayTransformer(nn.Module): torch.Tensor: the processed image_embedding """ # BxCxHxW -> BxHWxC == B x N_image_tokens x C - _bs, _c, _h, _w = image_embedding.shape + bs, c, h, w = image_embedding.shape image_embedding = image_embedding.flatten(2).permute(0, 2, 1) image_pe = image_pe.flatten(2).permute(0, 2, 1) diff --git a/modules/control/proc/segment_anything/utils/onnx.py b/modules/control/proc/segment_anything/utils/onnx.py index cd678117c..103867faf 100644 --- a/modules/control/proc/segment_anything/utils/onnx.py +++ b/modules/control/proc/segment_anything/utils/onnx.py @@ -10,7 +10,7 @@ from torch.nn import functional as F from typing import Tuple -from ..modeling import Sam # noqa: TID252 +from ..modeling import Sam from .amg import calculate_stability_score diff --git a/modules/control/proc/shuffle.py b/modules/control/proc/shuffle.py index 01da6719c..3ee285857 100644 --- a/modules/control/proc/shuffle.py +++ b/modules/control/proc/shuffle.py @@ -10,10 +10,10 @@ from modules.control.util import HWC3, img2mask, make_noise_disk, resize_image class ContentShuffleDetector: def __call__(self, input_image, h=None, w=None, f=None, detect_resolution=512, image_resolution=512, output_type="pil", **kwargs): if "return_pil" in kwargs: - warnings.warn("return_pil is deprecated. Use output_type instead.", DeprecationWarning, stacklevel=2) + warnings.warn("return_pil is deprecated. Use output_type instead.", DeprecationWarning) output_type = "pil" if kwargs["return_pil"] else "np" if type(output_type) is bool: - warnings.warn("Passing `True` or `False` to `output_type` is deprecated and will raise an error in future versions", stacklevel=2) + warnings.warn("Passing `True` or `False` to `output_type` is deprecated and will raise an error in future versions") if output_type: output_type = "pil" @@ -49,7 +49,7 @@ class ContentShuffleDetector: class ColorShuffleDetector: def __call__(self, img): H, W, C = img.shape - F = np.random.randint(64, 384) + F = np.random.randint(64, 384) # noqa A = make_noise_disk(H, W, 3, F) B = make_noise_disk(H, W, 3, F) C = (A + B) / 2.0 @@ -82,11 +82,11 @@ class DownSampleDetector: def __call__(self, img, level=3, k=16.0): h = img.astype(np.float32) for _ in range(level): - h += np.random.normal(loc=0.0, scale=k, size=h.shape) + h += np.random.normal(loc=0.0, scale=k, size=h.shape) # noqa h = cv2.pyrDown(h) for _ in range(level): h = cv2.pyrUp(h) - h += np.random.normal(loc=0.0, scale=k, size=h.shape) + h += np.random.normal(loc=0.0, scale=k, size=h.shape) # noqa return h.clip(0, 255).astype(np.uint8) diff --git a/modules/control/proc/zoe/zoedepth/models/base_models/midas_repo/midas/backbones/beit.py b/modules/control/proc/zoe/zoedepth/models/base_models/midas_repo/midas/backbones/beit.py index cd835ebc1..ab7458704 100644 --- a/modules/control/proc/zoe/zoedepth/models/base_models/midas_repo/midas/backbones/beit.py +++ b/modules/control/proc/zoe/zoedepth/models/base_models/midas_repo/midas/backbones/beit.py @@ -66,7 +66,7 @@ def attention_forward(self, x, resolution, shared_rel_pos_bias: Optional[torch.T """ Modification of timm.models.beit.py: Attention.forward to support arbitrary window sizes. """ - B, N, _C = x.shape + B, N, C = x.shape qkv_bias = torch.cat((self.q_bias, self.k_bias, self.v_bias)) if self.q_bias is not None else None qkv = F.linear(input=x, weight=self.qkv.weight, bias=qkv_bias) diff --git a/modules/control/proc/zoe/zoedepth/models/base_models/midas_repo/midas/backbones/utils.py b/modules/control/proc/zoe/zoedepth/models/base_models/midas_repo/midas/backbones/utils.py index a58fa876b..bed17f97d 100644 --- a/modules/control/proc/zoe/zoedepth/models/base_models/midas_repo/midas/backbones/utils.py +++ b/modules/control/proc/zoe/zoedepth/models/base_models/midas_repo/midas/backbones/utils.py @@ -81,7 +81,7 @@ def forward_default(pretrained, x, function_name="forward_features"): def forward_adapted_unflatten(pretrained, x, function_name="forward_features"): - _b, _c, h, w = x.shape + b, c, h, w = x.shape exec(f"glob = pretrained.model.{function_name}(x)") diff --git a/modules/control/proc/zoe/zoedepth/models/base_models/midas_repo/midas/backbones/vit.py b/modules/control/proc/zoe/zoedepth/models/base_models/midas_repo/midas/backbones/vit.py index ce8ea0176..71e864cdf 100644 --- a/modules/control/proc/zoe/zoedepth/models/base_models/midas_repo/midas/backbones/vit.py +++ b/modules/control/proc/zoe/zoedepth/models/base_models/midas_repo/midas/backbones/vit.py @@ -31,7 +31,7 @@ def _resize_pos_embed(self, posemb, gs_h, gs_w): def forward_flex(self, x): - _b, _c, h, w = x.shape + b, c, h, w = x.shape pos_embed = self._resize_pos_embed( self.pos_embed, h // self.patch_size[1], w // self.patch_size[0] diff --git a/modules/control/proc/zoe/zoedepth/models/base_models/midas_repo/midas/blocks.py b/modules/control/proc/zoe/zoedepth/models/base_models/midas_repo/midas/blocks.py index 46e10c14e..c480bbb66 100644 --- a/modules/control/proc/zoe/zoedepth/models/base_models/midas_repo/midas/blocks.py +++ b/modules/control/proc/zoe/zoedepth/models/base_models/midas_repo/midas/blocks.py @@ -5,6 +5,10 @@ from .backbones.beit import ( _make_pretrained_beitl16_512, _make_pretrained_beitl16_384, _make_pretrained_beitb16_384, + forward_beit, +) +from .backbones.swin_common import ( + forward_swin, ) from .backbones.swin2 import ( _make_pretrained_swin2l24_384, @@ -16,11 +20,13 @@ from .backbones.swin import ( ) from .backbones.levit import ( _make_pretrained_levit_384, + forward_levit, ) from .backbones.vit import ( _make_pretrained_vitb_rn50_384, _make_pretrained_vitl16_384, _make_pretrained_vitb16_384, + forward_vit, ) def _make_encoder(backbone, features, use_pretrained, groups=1, expand=False, exportable=True, hooks=None, diff --git a/modules/control/proc/zoe/zoedepth/models/base_models/midas_repo/midas/midas_net_custom.py b/modules/control/proc/zoe/zoedepth/models/base_models/midas_repo/midas/midas_net_custom.py index 7f09df0a6..cba1bcfff 100644 --- a/modules/control/proc/zoe/zoedepth/models/base_models/midas_repo/midas/midas_net_custom.py +++ b/modules/control/proc/zoe/zoedepth/models/base_models/midas_repo/midas/midas_net_custom.py @@ -6,7 +6,7 @@ import torch import torch.nn as nn from .base_model import BaseModel -from .blocks import FeatureFusionBlock_custom, Interpolate, _make_encoder +from .blocks import FeatureFusionBlock, FeatureFusionBlock_custom, Interpolate, _make_encoder class MidasNet_small(BaseModel): diff --git a/modules/control/proc/zoe/zoedepth/models/layers/attractor.py b/modules/control/proc/zoe/zoedepth/models/layers/attractor.py index 5e58ee348..c2fe653ed 100644 --- a/modules/control/proc/zoe/zoedepth/models/layers/attractor.py +++ b/modules/control/proc/zoe/zoedepth/models/layers/attractor.py @@ -100,7 +100,7 @@ class AttractorLayer(nn.Module): A = self._net(x) eps = 1e-3 A = A + eps - n, _c, h, w = A.shape + n, c, h, w = A.shape A = A.view(n, self.n_attractors, 2, h, w) A_normed = A / A.sum(dim=2, keepdim=True) # n, a, 2, h, w A_normed = A[:, :, 0, ...] # n, na, h, w @@ -177,7 +177,7 @@ class AttractorLayerUnnormed(nn.Module): x = x + prev_b_embedding A = self._net(x) - _n, _c, h, w = A.shape + n, c, h, w = A.shape b_prev = nn.functional.interpolate( b_prev, (h, w), mode='bilinear', align_corners=True) diff --git a/modules/control/proc/zoe/zoedepth/models/layers/localbins_layers.py b/modules/control/proc/zoe/zoedepth/models/layers/localbins_layers.py index 9af4dc463..b70ae562e 100644 --- a/modules/control/proc/zoe/zoedepth/models/layers/localbins_layers.py +++ b/modules/control/proc/zoe/zoedepth/models/layers/localbins_layers.py @@ -146,7 +146,7 @@ class LinearSplitter(nn.Module): S = self._net(x) eps = 1e-3 S = S + eps - n, _c, h, w = S.shape + n, c, h, w = S.shape S = S.view(n, self.prev_nbins, self.split_factor, h, w) S_normed = S / S.sum(dim=2, keepdim=True) # fractional splits diff --git a/modules/control/proc/zoe/zoedepth/models/zoedepth/zoedepth_v1.py b/modules/control/proc/zoe/zoedepth/models/zoedepth/zoedepth_v1.py index 1dc3635b3..1705442c6 100644 --- a/modules/control/proc/zoe/zoedepth/models/zoedepth/zoedepth_v1.py +++ b/modules/control/proc/zoe/zoedepth/models/zoedepth/zoedepth_v1.py @@ -26,13 +26,13 @@ import itertools import torch import torch.nn as nn -from ..depth_model import DepthModel # noqa: TID252 -from ..base_models.midas import MidasCore # noqa: TID252 -from ..layers.attractor import AttractorLayer, AttractorLayerUnnormed # noqa: TID252 -from ..layers.dist_layers import ConditionalLogBinomial # noqa: TID252 -from ..layers.localbins_layers import (Projector, SeedBinRegressor, # noqa: TID252 +from ..depth_model import DepthModel +from ..base_models.midas import MidasCore +from ..layers.attractor import AttractorLayer, AttractorLayerUnnormed +from ..layers.dist_layers import ConditionalLogBinomial +from ..layers.localbins_layers import (Projector, SeedBinRegressor, SeedBinRegressorUnnormed) -from ..model_io import load_state_from_resource # noqa: TID252 +from ..model_io import load_state_from_resource class ZoeDepth(DepthModel): @@ -139,7 +139,7 @@ class ZoeDepth(DepthModel): - probs (torch.Tensor): Output probability distribution of shape (B, n_bins, H, W). Present only if return_probs is True """ - b, _c, h, w = x.shape + b, c, h, w = x.shape # print("input shape ", x.shape) self.orig_input_width = w self.orig_input_height = h diff --git a/modules/control/proc/zoe/zoedepth/models/zoedepth_nk/zoedepth_nk_v1.py b/modules/control/proc/zoe/zoedepth/models/zoedepth_nk/zoedepth_nk_v1.py index 0b8f73074..889b1e282 100644 --- a/modules/control/proc/zoe/zoedepth/models/zoedepth_nk/zoedepth_nk_v1.py +++ b/modules/control/proc/zoe/zoedepth/models/zoedepth_nk/zoedepth_nk_v1.py @@ -27,14 +27,14 @@ import itertools import torch import torch.nn as nn -from ..depth_model import DepthModel # noqa: TID252 -from ..base_models.midas import MidasCore # noqa: TID252 -from ..layers.attractor import AttractorLayer, AttractorLayerUnnormed # noqa: TID252 -from ..layers.dist_layers import ConditionalLogBinomial # noqa: TID252 -from ..layers.localbins_layers import (Projector, SeedBinRegressor, # noqa: TID252 +from ..depth_model import DepthModel +from ..base_models.midas import MidasCore +from ..layers.attractor import AttractorLayer, AttractorLayerUnnormed +from ..layers.dist_layers import ConditionalLogBinomial +from ..layers.localbins_layers import (Projector, SeedBinRegressor, SeedBinRegressorUnnormed) -from ..layers.patch_transformer import PatchTransformerEncoder # noqa: TID252 -from ..model_io import load_state_from_resource # noqa: TID252 +from ..layers.patch_transformer import PatchTransformerEncoder +from ..model_io import load_state_from_resource class ZoeDepthNK(DepthModel): def __init__(self, core, bin_conf, bin_centers_type="softplus", bin_embedding_dim=128, @@ -173,10 +173,10 @@ class ZoeDepthNK(DepthModel): - "bin_centers": Bin centers of shape (B, N, H, W). Present only if return_final_centers is True - "probs": Bin probabilities of shape (B, N, H, W). Present only if return_probs is True """ - b, _c, h, w = x.shape + b, c, h, w = x.shape self.orig_input_width = w self.orig_input_height = h - _rel_depth, out = self.core(x, denorm=denorm, return_rel_depth=True) + rel_depth, out = self.core(x, denorm=denorm, return_rel_depth=True) outconv_activation = out[0] btlnck = out[1] diff --git a/modules/control/units/controlnet.py b/modules/control/units/controlnet.py index 34658cf0a..5bc231f56 100644 --- a/modules/control/units/controlnet.py +++ b/modules/control/units/controlnet.py @@ -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() diff --git a/modules/control/units/lite.py b/modules/control/units/lite.py index 0c5bbf32a..107ebb0a0 100644 --- a/modules/control/units/lite.py +++ b/modules/control/units/lite.py @@ -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() diff --git a/modules/control/units/t2iadapter.py b/modules/control/units/t2iadapter.py index cb3a2da4e..5bdf99fb8 100644 --- a/modules/control/units/t2iadapter.py +++ b/modules/control/units/t2iadapter.py @@ -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() diff --git a/modules/control/units/xs.py b/modules/control/units/xs.py index 754273cdb..2d56fd7ff 100644 --- a/modules/control/units/xs.py +++ b/modules/control/units/xs.py @@ -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() diff --git a/modules/control/units/xs_model.py b/modules/control/units/xs_model.py index 9040d24a7..f4866b58d 100644 --- a/modules/control/units/xs_model.py +++ b/modules/control/units/xs_model.py @@ -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 diff --git a/modules/control/units/xs_pipe.py b/modules/control/units/xs_pipe.py index e61e5f1c8..f178c11b1 100644 --- a/modules/control/units/xs_pipe.py +++ b/modules/control/units/xs_pipe.py @@ -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`.") diff --git a/modules/errorlimiter.py b/modules/errorlimiter.py index 4f23ffcd7..b869a8553 100644 --- a/modules/errorlimiter.py +++ b/modules/errorlimiter.py @@ -2,8 +2,10 @@ from __future__ import annotations from contextlib import contextmanager from threading import Lock -from typing import ClassVar +from typing import TYPE_CHECKING, ClassVar +if TYPE_CHECKING: + from collections.abc import Iterable _instance_id = 0 _lock = Lock() diff --git a/modules/framepack/pipeline/hunyuan_video_packed.py b/modules/framepack/pipeline/hunyuan_video_packed.py index a5f171b5c..a852fbc10 100644 --- a/modules/framepack/pipeline/hunyuan_video_packed.py +++ b/modules/framepack/pipeline/hunyuan_video_packed.py @@ -832,7 +832,7 @@ class HunyuanVideoTransformer3DModelPacked(ModelMixin, ConfigMixin, PeftAdapterM clean_latents_4x=None, clean_latent_4x_indices=None ): hidden_states = self.gradient_checkpointing_method(self.x_embedder.proj, latents) - B, _C, T, H, W = hidden_states.shape + B, C, T, H, W = hidden_states.shape if latent_indices is None: latent_indices = torch.arange(0, T).unsqueeze(0).expand(B, -1) @@ -897,7 +897,7 @@ class HunyuanVideoTransformer3DModelPacked(ModelMixin, ConfigMixin, PeftAdapterM if attention_kwargs is None: attention_kwargs = {} - batch_size, _num_channels, num_frames, height, width = hidden_states.shape + batch_size, num_channels, num_frames, height, width = hidden_states.shape p, p_t = self.config['patch_size'], self.config['patch_size_t'] post_patch_num_frames = num_frames // p_t post_patch_height = height // p diff --git a/modules/framepack/pipeline/uni_pc_fm.py b/modules/framepack/pipeline/uni_pc_fm.py index 4cc22eec0..123c2b059 100644 --- a/modules/framepack/pipeline/uni_pc_fm.py +++ b/modules/framepack/pipeline/uni_pc_fm.py @@ -18,7 +18,7 @@ torch_linalg_solve = None def test_solver(): - from modules import devices + from modules import devices, shared try: a = torch.randn(50, 50).to(device=devices.device, dtype=torch.float32) b = torch.randn(50, 2).to(device=devices.device, dtype=torch.float32) diff --git a/modules/hidiffusion/hidiffusion.py b/modules/hidiffusion/hidiffusion.py index fd2c4b408..b0ddf3b58 100644 --- a/modules/hidiffusion/hidiffusion.py +++ b/modules/hidiffusion/hidiffusion.py @@ -107,7 +107,7 @@ def make_diffusers_transformer_block(block_class: Type[torch.nn.Module]) -> Type encoder_hidden_states: Optional[torch.FloatTensor] = None, encoder_attention_mask: Optional[torch.FloatTensor] = None, timestep: Optional[torch.LongTensor] = None, - cross_attention_kwargs: Dict[str, Any] | None = None, + cross_attention_kwargs: Dict[str, Any] = None, class_labels: Optional[torch.LongTensor] = None, added_cond_kwargs: Optional[Dict[str, torch.Tensor]] = None, ) -> torch.FloatTensor: diff --git a/modules/hidiffusion/hidiffusion_controlnet.py b/modules/hidiffusion/hidiffusion_controlnet.py index ef7ce0457..990ecf8da 100644 --- a/modules/hidiffusion/hidiffusion_controlnet.py +++ b/modules/hidiffusion/hidiffusion_controlnet.py @@ -272,7 +272,7 @@ def make_diffusers_sdxl_contrtolnet_ppl(block_class): @torch.no_grad() def __call__( self, - prompt: Union[str, List[str]] | None = None, + prompt: Union[str, List[str]] = None, prompt_2: Optional[Union[str, List[str]]] = None, image: PipelineImageInput = None, control_image: PipelineImageInput = None, @@ -298,9 +298,9 @@ def make_diffusers_sdxl_contrtolnet_ppl(block_class): guess_mode: bool = False, control_guidance_start: Union[float, List[float]] = 0.0, control_guidance_end: Union[float, List[float]] = 1.0, - original_size: Tuple[int, int] | None = None, + original_size: Tuple[int, int] = None, crops_coords_top_left: Tuple[int, int] = (0, 0), - target_size: Tuple[int, int] | None = None, + target_size: Tuple[int, int] = None, negative_original_size: Optional[Tuple[int, int]] = None, negative_crops_coords_top_left: Tuple[int, int] = (0, 0), negative_target_size: Optional[Tuple[int, int]] = None, diff --git a/modules/images.py b/modules/images.py index 1e50ec104..05c33d802 100644 --- a/modules/images.py +++ b/modules/images.py @@ -6,21 +6,21 @@ from modules.image.grid import Grid, image_grid, check_grid_size, get_grid_size, from modules.image.util import draw_text, flatten __all__ = [ - 'FilenameGenerator', - 'Grid', 'check_grid_size', 'combine_grid', 'draw_grid_annotations', 'draw_prompt_matrix', - 'draw_text', - 'flatten', - 'get_font', + 'FilenameGenerator', 'get_grid_size', - 'get_next_sequence_number', + 'Grid', 'image_data', 'image_grid', 'read_info_from_image', 'resize_image', 'sanitize_filename_part', 'save_image', + 'get_font', + 'get_next_sequence_number', + 'draw_text', + 'flatten', ] diff --git a/modules/intel/ipex/diffusers.py b/modules/intel/ipex/diffusers.py index 5c36efd67..363f3a991 100644 --- a/modules/intel/ipex/diffusers.py +++ b/modules/intel/ipex/diffusers.py @@ -50,7 +50,7 @@ def hidream_rope(pos: torch.Tensor, dim: int, theta: int) -> torch.Tensor: scale = torch.arange(0, dim, 2, dtype=torch.float64, device=pos.device) / dim omega = 1.0 / (theta**scale) - batch_size, _seq_length = pos.shape + batch_size, seq_length = pos.shape out = torch.einsum("...n,d->...nd", pos, omega) cos_out = torch.cos(out) sin_out = torch.sin(out) diff --git a/modules/intel/ipex/hijacks.py b/modules/intel/ipex/hijacks.py index 6fb0714c0..e4662bfa9 100644 --- a/modules/intel/ipex/hijacks.py +++ b/modules/intel/ipex/hijacks.py @@ -52,7 +52,7 @@ def autocast_init(self, device_type=None, dtype=None, enabled=True, cache_enable original_grad_scaler_init = torch.amp.grad_scaler.GradScaler.__init__ @wraps(torch.amp.grad_scaler.GradScaler.__init__) -def GradScaler_init(self, device: str | None = None, init_scale: float = 2.0**16, growth_factor: float = 2.0, backoff_factor: float = 0.5, growth_interval: int = 2000, enabled: bool = True): +def GradScaler_init(self, device: str = None, init_scale: float = 2.0**16, growth_factor: float = 2.0, backoff_factor: float = 0.5, growth_interval: int = 2000, enabled: bool = True): if device is None or check_cuda(device): return original_grad_scaler_init(self, device=return_xpu(device), init_scale=init_scale, growth_factor=growth_factor, backoff_factor=backoff_factor, growth_interval=growth_interval, enabled=enabled) else: diff --git a/modules/loader.py b/modules/loader.py index b623ed32e..d57bfd3b7 100644 --- a/modules/loader.py +++ b/modules/loader.py @@ -75,7 +75,7 @@ except Exception: pass try: - pass # pylint: disable=unused-import,ungrouped-imports + import torch.distributed.distributed_c10d as _c10d # pylint: disable=unused-import,ungrouped-imports except Exception: log.warning('Loader: torch is not built with distributed support') @@ -96,6 +96,7 @@ warnings.filterwarnings(action="ignore", category=UserWarning, module="torchvisi torchvision = None try: import torchvision # pylint: disable=W0611,C0411 + import pytorch_lightning # pytorch_lightning should be imported after torch, but it re-enables warnings on import so import once to disable them # pylint: disable=W0611,C0411 except Exception as e: report(f'torchvision=={torchvision.__version__ if torchvision is not None else None}', e) @@ -126,6 +127,7 @@ if ".dev" in torch.__version__ or "+git" in torch.__version__: timer.startup.record("torch") try: + import bitsandbytes # pylint: disable=unused-import _bnb = True except Exception: _bnb = False @@ -209,9 +211,10 @@ except Exception as e: sys.exit(1) try: - pass # pylint: disable=W0611,C0411 + import pillow_jxl # pylint: disable=W0611,C0411 except Exception: pass +from PIL import Image # pylint: disable=W0611,C0411 timer.startup.record("pillow") diff --git a/modules/lora/lora_load.py b/modules/lora/lora_load.py index f4e868f1c..b3c4b0908 100644 --- a/modules/lora/lora_load.py +++ b/modules/lora/lora_load.py @@ -354,7 +354,7 @@ def network_load(names, te_multipliers=None, unet_multipliers=None, dyn_dims=Non sd_model.set_adapters(adapter_names=lora_diffusers.diffuser_loaded, adapter_weights=lora_diffusers.diffuser_scales) except Exception as e: if str(e) not in exclude_errors: - log.error(f'Network load: type=LoRA action=strength {e!s}') + log.error(f'Network load: type=LoRA action=strength {str(e)}') if l.debug: errors.display(e, 'LoRA') try: @@ -363,7 +363,7 @@ def network_load(names, te_multipliers=None, unet_multipliers=None, dyn_dims=Non sd_model.unload_lora_weights() l.timer.activate += time.time() - t1 except Exception as e: - log.error(f'Network load: type=LoRA action=fuse {e!s}') + log.error(f'Network load: type=LoRA action=fuse {str(e)}') if l.debug: errors.display(e, 'LoRA') shared.sd_model = sd_models.apply_balanced_offload(shared.sd_model, force=True, silent=True) # some layers may end up on cpu without hook diff --git a/modules/ltx/ltx_process.py b/modules/ltx/ltx_process.py index fef91478c..4c5bdc26c 100644 --- a/modules/ltx/ltx_process.py +++ b/modules/ltx/ltx_process.py @@ -149,7 +149,7 @@ def run_ltx(task_id, extra_networks.deactivate(p) shared.state.end() progress.finish_task(task_id) - yield None, f'LTX Error: {e!s}' + yield None, f'LTX Error: {str(e)}' if model is None or len(model) == 0 or model == 'None': yield from abort('Video: no model selected', ok=True) diff --git a/modules/merging/merge_methods.py b/modules/merging/merge_methods.py index 8bece57ab..256baeb05 100644 --- a/modules/merging/merge_methods.py +++ b/modules/merging/merge_methods.py @@ -4,18 +4,18 @@ import torch from torch import Tensor __all__ = [ + "weighted_sum", + "weighted_subtraction", + "tensor_sum", "add_difference", - "distribution_crossover", + "sum_twice", + "triple_sum", "euclidean_add_difference", "multiply_difference", - "similarity_add_difference", - "sum_twice", - "tensor_sum", - "ties_add_difference", "top_k_tensor_sum", - "triple_sum", - "weighted_subtraction", - "weighted_sum", + "similarity_add_difference", + "distribution_crossover", + "ties_add_difference", ] diff --git a/modules/onnx_impl/execution_providers.py b/modules/onnx_impl/execution_providers.py index 82d6270d2..1b0a47be5 100644 --- a/modules/onnx_impl/execution_providers.py +++ b/modules/onnx_impl/execution_providers.py @@ -96,7 +96,7 @@ def get_provider() -> tuple: def install_execution_provider(ep: ExecutionProvider): import importlib # pylint: disable=deprecated-module - from installer import install, uninstall + from installer import installed, install, uninstall res = "
"
     res += uninstall(["onnxruntime", "onnxruntime-directml", "onnxruntime-gpu", "onnxruntime-training", "onnxruntime-openvino"], quiet=True)
     packages = ["onnxruntime"] # Failed to load olive: cannot import name '__version__' from 'onnxruntime'
diff --git a/modules/postprocess/swinir_model_arch.py b/modules/postprocess/swinir_model_arch.py
index 8064e0fef..4b306433d 100644
--- a/modules/postprocess/swinir_model_arch.py
+++ b/modules/postprocess/swinir_model_arch.py
@@ -238,7 +238,7 @@ class SwinTransformerBlock(nn.Module):
 
     def forward(self, x, x_size):
         H, W = x_size
-        B, _L, C = x.shape
+        B, L, C = x.shape
         # assert L == H * W, "input feature has wrong size"
 
         shortcut = x
@@ -559,7 +559,7 @@ class PatchUnEmbed(nn.Module):
         self.embed_dim = embed_dim
 
     def forward(self, x, x_size):
-        B, _HW, _C = x.shape
+        B, HW, C = x.shape
         x = x.transpose(1, 2).view(B, self.embed_dim, x_size[0], x_size[1])  # B Ph*Pw C
         return x
 
diff --git a/modules/postprocess/swinir_model_arch_v2.py b/modules/postprocess/swinir_model_arch_v2.py
index 00577c8ba..d61e92668 100644
--- a/modules/postprocess/swinir_model_arch_v2.py
+++ b/modules/postprocess/swinir_model_arch_v2.py
@@ -266,7 +266,7 @@ class SwinTransformerBlock(nn.Module):
 
     def forward(self, x, x_size):
         H, W = x_size
-        B, _L, C = x.shape
+        B, L, C = x.shape
         #assert L == H * W, "input feature has wrong size"
 
         shortcut = x
@@ -476,7 +476,7 @@ class PatchEmbed(nn.Module):
             self.norm = None
 
     def forward(self, x):
-        _B, _C, _H, _W = x.shape
+        B, C, H, W = x.shape
         # FIXME look at relaxing size constraints
         # assert H == self.img_size[0] and W == self.img_size[1],
         #     f"Input image size ({H}*{W}) doesn't match model ({self.img_size[0]}*{self.img_size[1]})."
@@ -591,7 +591,7 @@ class PatchUnEmbed(nn.Module):
         self.embed_dim = embed_dim
 
     def forward(self, x, x_size):
-        B, _HW, _C = x.shape
+        B, HW, C = x.shape
         x = x.transpose(1, 2).view(B, self.embed_dim, x_size[0], x_size[1])  # B Ph*Pw C
         return x
 
diff --git a/modules/processing.py b/modules/processing.py
index 4e8b001b8..0306b20a8 100644
--- a/modules/processing.py
+++ b/modules/processing.py
@@ -8,6 +8,10 @@ from modules.logger import log
 from modules.sd_hijack_hypertile import context_hypertile_vae, context_hypertile_unet
 from modules.processing_class import ( # pylint: disable=unused-import
     StableDiffusionProcessing,
+    StableDiffusionProcessingTxt2Img,
+    StableDiffusionProcessingImg2Img,
+    StableDiffusionProcessingVideo,
+    StableDiffusionProcessingControl,
 )
 from modules.processing_info import create_infotext
 
diff --git a/modules/ras/__init__.py b/modules/ras/__init__.py
index 8384812f1..717772600 100644
--- a/modules/ras/__init__.py
+++ b/modules/ras/__init__.py
@@ -19,7 +19,7 @@ def apply(pipe, p: processing.StableDiffusionProcessing):
     MANAGER.width = p.width
     MANAGER.height = p.height
     MANAGER.error_reset_steps = [int(1*p.steps/3), int(2*p.steps/3)]
-    log.info(f'RAS: scheduler={pipe.scheduler.__class__.__name__} {MANAGER!s}')
+    log.info(f'RAS: scheduler={pipe.scheduler.__class__.__name__} {str(MANAGER)}')
     MANAGER.reset_cache()
     MANAGER.generate_skip_token_list()
     pipe.transformer.old_forward = pipe.transformer.forward
diff --git a/modules/res4lyf/res_unified_scheduler.py b/modules/res4lyf/res_unified_scheduler.py
index 2b1d1bf0a..061517f10 100644
--- a/modules/res4lyf/res_unified_scheduler.py
+++ b/modules/res4lyf/res_unified_scheduler.py
@@ -304,7 +304,7 @@ class RESUnifiedScheduler(SchedulerMixin, ConfigMixin):
             return SchedulerOutput(prev_sample=x_next)
 
         # GET COEFFICIENTS
-        b, _h_val = self._get_coefficients(sigma, sigma_next)
+        b, h_val = self._get_coefficients(sigma, sigma_next)
 
         if len(b) == 1:
             res = b[0] * x0
diff --git a/modules/schedulers/scheduler_dc.py b/modules/schedulers/scheduler_dc.py
index d13fd940b..7121d4364 100644
--- a/modules/schedulers/scheduler_dc.py
+++ b/modules/schedulers/scheduler_dc.py
@@ -126,7 +126,7 @@ class DCSolverMultistepScheduler(SchedulerMixin, ConfigMixin):
             Any other scheduler that if specified, the algorithm becomes `solver_p + UniC`.
         use_karras_sigmas (`bool`, *optional*, defaults to `False`):
             Whether to use Karras sigmas for step sizes in the noise schedule during the sampling process. If `True`,
-            the sigmas are determined according to a sequence of noise levels {sigma_i}.
+            the sigmas are determined according to a sequence of noise levels {σi}.
         timestep_spacing (`str`, defaults to `"linspace"`):
             The way the timesteps should be scaled. Refer to Table 2 of the [Common Diffusion Noise Schedules and
             Sample Steps are Flawed](https://huggingface.co/papers/2305.08891) for more information.
@@ -449,7 +449,7 @@ class DCSolverMultistepScheduler(SchedulerMixin, ConfigMixin):
         model_output: torch.FloatTensor = None,
         *args,
         sample: torch.FloatTensor = None,
-        order: int | None = None,
+        order: int = None,
         **kwargs,
     ) -> torch.FloatTensor:
         """
@@ -488,12 +488,13 @@ class DCSolverMultistepScheduler(SchedulerMixin, ConfigMixin):
             )
         model_output_list = self.model_outputs
 
+        s0 = self.timestep_list[-1]
         m0 = model_output_list[-1]
         assert m0 is not None
         x = sample
 
         if self.solver_p:
-            raise NotImplementedError
+            raise NotImplementedError()
 
         sigma_t, sigma_s0 = self.sigmas[self.step_index + 1], self.sigmas[self.step_index]
         alpha_t, sigma_t = self._sigma_to_alpha_sigma_t(sigma_t)
@@ -533,7 +534,7 @@ class DCSolverMultistepScheduler(SchedulerMixin, ConfigMixin):
         elif self.config.solver_type == "bh2":
             B_h = torch.expm1(hh)
         else:
-            raise NotImplementedError
+            raise NotImplementedError()
 
         for i in range(1, order + 1):
             R.append(torch.pow(rks, i - 1))
@@ -578,7 +579,7 @@ class DCSolverMultistepScheduler(SchedulerMixin, ConfigMixin):
         *args,
         last_sample: torch.FloatTensor = None,
         this_sample: torch.FloatTensor = None,
-        order: int | None = None,
+        order: int = None,
         **kwargs,
     ) -> torch.FloatTensor:
         """
@@ -668,7 +669,7 @@ class DCSolverMultistepScheduler(SchedulerMixin, ConfigMixin):
         elif self.config.solver_type == "bh2":
             B_h = torch.expm1(hh)
         else:
-            raise NotImplementedError
+            raise NotImplementedError()
 
         for i in range(1, order + 1):
             R.append(torch.pow(rks, i - 1))
@@ -810,7 +811,7 @@ class DCSolverMultistepScheduler(SchedulerMixin, ConfigMixin):
             return loss
 
         optimizer = torch.optim.AdamW([ratio_param], lr=0.1)
-        for _ in range(self.num_iters):
+        for iter_ in range(self.num_iters):
             optimizer.zero_grad()
             loss = closure(ratio_param)
             loss.backward()
diff --git a/modules/schedulers/scheduler_dpm_flowmatch.py b/modules/schedulers/scheduler_dpm_flowmatch.py
index 2dff1b9d4..97472f754 100644
--- a/modules/schedulers/scheduler_dpm_flowmatch.py
+++ b/modules/schedulers/scheduler_dpm_flowmatch.py
@@ -170,7 +170,7 @@ class FlowMatchDPMSolverMultistepScheduler(SchedulerMixin, ConfigMixin):
         from installer import install
         install('torchsde==0.2.6', 'torchsde', quiet=True)
         try:
-            pass
+            import torchsde
         except Exception as e:
             raise ImportError("Failed to import torchsde. Please make sure it is installed correctly.") from e
 
@@ -234,7 +234,7 @@ class FlowMatchDPMSolverMultistepScheduler(SchedulerMixin, ConfigMixin):
         return math.exp(mu) / (math.exp(mu) + (1 / t - 1) ** sigma)
 
     def set_timesteps(self,
-        num_inference_steps: int | None = None,
+        num_inference_steps: int = None,
         device: Union[str, torch.device] = None,
         sigmas: Optional[List[float]] = None,
         mu: Optional[float] = None,
diff --git a/modules/schedulers/scheduler_tdd.py b/modules/schedulers/scheduler_tdd.py
index f7939f012..05b49f35c 100644
--- a/modules/schedulers/scheduler_tdd.py
+++ b/modules/schedulers/scheduler_tdd.py
@@ -395,7 +395,7 @@ class TDDScheduler(DPMSolverSinglestepScheduler):
         model_output_list: List[torch.FloatTensor],
         *args,
         sample: torch.FloatTensor = None,
-        order: int | None = None,
+        order: int = None,
         **kwargs,
     ) -> torch.FloatTensor:
         timestep_list = args[0] if len(args) > 0 else kwargs.pop("timestep_list", None)
diff --git a/modules/schedulers/scheduler_unipc_flowmatch.py b/modules/schedulers/scheduler_unipc_flowmatch.py
index d981ac8bd..1adbd0799 100644
--- a/modules/schedulers/scheduler_unipc_flowmatch.py
+++ b/modules/schedulers/scheduler_unipc_flowmatch.py
@@ -54,7 +54,7 @@ class FlowUniPCMultistepScheduler(SchedulerMixin, ConfigMixin):
             Any other scheduler that if specified, the algorithm becomes `solver_p + UniC`.
         use_karras_sigmas (`bool`, *optional*, defaults to `False`):
             Whether to use Karras sigmas for step sizes in the noise schedule during the sampling process. If `True`,
-            the sigmas are determined according to a sequence of noise levels {sigma_i}.
+            the sigmas are determined according to a sequence of noise levels {σi}.
         use_exponential_sigmas (`bool`, *optional*, defaults to `False`):
             Whether to use exponential sigmas for step sizes in the noise schedule during the sampling process.
         timestep_spacing (`str`, defaults to `"linspace"`):
@@ -311,7 +311,7 @@ class FlowUniPCMultistepScheduler(SchedulerMixin, ConfigMixin):
             )
 
         sigma = self.sigmas[self.step_index]
-        _alpha_t, sigma_t = self._sigma_to_alpha_sigma_t(sigma)
+        alpha_t, sigma_t = self._sigma_to_alpha_sigma_t(sigma)
 
         if self.predict_x0:
             if self.config.prediction_type == "flow_prediction":
@@ -350,7 +350,7 @@ class FlowUniPCMultistepScheduler(SchedulerMixin, ConfigMixin):
         model_output: torch.Tensor,
         *args,
         sample: torch.Tensor = None,
-        order: int | None = None,  # pyright: ignore
+        order: int = None,  # pyright: ignore
         **kwargs,
     ) -> torch.Tensor:
         """
@@ -439,7 +439,7 @@ class FlowUniPCMultistepScheduler(SchedulerMixin, ConfigMixin):
         elif self.config.solver_type == "bh2":
             B_h = torch.expm1(hh)
         else:
-            raise NotImplementedError
+            raise NotImplementedError()
 
         for i in range(1, order + 1):
             R.append(torch.pow(rks, i - 1))
@@ -487,7 +487,7 @@ class FlowUniPCMultistepScheduler(SchedulerMixin, ConfigMixin):
         *args,
         last_sample: torch.Tensor = None,
         this_sample: torch.Tensor = None,
-        order: int | None = None,  # pyright: ignore
+        order: int = None,  # pyright: ignore
         **kwargs,
     ) -> torch.Tensor:
         """
@@ -582,7 +582,7 @@ class FlowUniPCMultistepScheduler(SchedulerMixin, ConfigMixin):
         elif self.config.solver_type == "bh2":
             B_h = torch.expm1(hh)
         else:
-            raise NotImplementedError
+            raise NotImplementedError()
 
         for i in range(1, order + 1):
             R.append(torch.pow(rks, i - 1))
diff --git a/modules/sd_models.py b/modules/sd_models.py
index c66871897..288d10ab3 100644
--- a/modules/sd_models.py
+++ b/modules/sd_models.py
@@ -15,9 +15,9 @@ from modules import timer, paths, shared, shared_items, modelloader, devices, sc
 from modules.memstats import memory_stats
 from modules.shared_helpers import walk_files
 from modules.modeldata import model_data
-from modules.sd_checkpoint import CheckpointInfo, select_checkpoint, list_models, checkpoint_titles, get_closest_checkpoint_match # pylint: disable=unused-import
+from modules.sd_checkpoint import CheckpointInfo, select_checkpoint, list_models, checkpoint_titles, get_closest_checkpoint_match, update_model_hashes, write_metadata, checkpoints_list # pylint: disable=unused-import
 from modules.sd_offload import get_module_names, disable_offload, set_diffuser_offload, apply_balanced_offload, set_accelerate # pylint: disable=unused-import
-from modules.sd_models_utils import NoWatermark, get_signature, path_to_repo, apply_function_to_model # pylint: disable=unused-import
+from modules.sd_models_utils import NoWatermark, get_signature, get_call, path_to_repo, apply_function_to_model, read_state_dict, get_state_dict_from_checkpoint # pylint: disable=unused-import
 
 
 model_dir = "Stable-diffusion"
@@ -331,6 +331,7 @@ def load_diffuser_initial(diffusers_load_config, op='model'):
 
 
 def load_diffuser_force(detected_model_type, checkpoint_info, diffusers_load_config, op='model'):
+    from modules import sdnq # pylint: disable=unused-import
     sd_model = None
     global allow_post_quant # pylint: disable=global-statement
     unload_model_weights(op=op)
diff --git a/modules/sdnq/layers/__init__.py b/modules/sdnq/layers/__init__.py
index d848b8655..a7b96ce23 100644
--- a/modules/sdnq/layers/__init__.py
+++ b/modules/sdnq/layers/__init__.py
@@ -28,7 +28,7 @@ class SDNQLayer(torch.nn.Module):
         return self.forward_func(self, *args, **kwargs)
 
     def __repr__(self):
-        return f"{self.__class__.__name__}(original_class={self.original_class} forward_func={self.forward_func} sdnq_dequantizer={getattr(self, 'sdnq_dequantizer', None)!r})"
+        return f"{self.__class__.__name__}(original_class={self.original_class} forward_func={self.forward_func} sdnq_dequantizer={repr(getattr(self, 'sdnq_dequantizer', None))})"
 
 
 class SDNQLinear(SDNQLayer, torch.nn.Linear):
diff --git a/modules/seedvr/src/utils/color_fix.py b/modules/seedvr/src/utils/color_fix.py
index 26445ea24..efe80b67d 100644
--- a/modules/seedvr/src/utils/color_fix.py
+++ b/modules/seedvr/src/utils/color_fix.py
@@ -2,8 +2,8 @@ import torch
 from PIL import Image
 from torch import Tensor
 from torch.nn import functional as F
+from ..common.half_precision_fixes import safe_pad_operation, safe_interpolate_operation
 from torchvision.transforms import ToTensor, ToPILImage
-from modules.seedvr.src.common.half_precision_fixes import safe_pad_operation, safe_interpolate_operation
 
 def adain_color_fix(target: Image.Image, source: Image.Image):
     # Convert images to tensors
diff --git a/modules/shared.py b/modules/shared.py
index 5445ca701..1a292c3dc 100644
--- a/modules/shared.py
+++ b/modules/shared.py
@@ -15,17 +15,21 @@ log.debug('Initializing: shared module')
 import modules.memmon
 import modules.paths as paths
 from modules.json_helpers import readfile # pylint: disable=W0611
-from modules.shared_helpers import listdir # pylint: disable=W0611
-from modules import errors, devices, shared_state, cmd_args, history, files_cache # pylint: disable=unused-import
+from modules.shared_helpers import listdir, req # pylint: disable=W0611
+from modules import errors, devices, shared_state, cmd_args, theme, history, files_cache # pylint: disable=unused-import
 from modules.shared_defaults import get_default_modes
 from modules.memstats import memory_stats # pylint: disable=unused-import
 
 log.debug('Initializing: pipelines')
+from modules import shared_items # pylint: disable=unused-import
+from modules.caption.openclip import get_clip_models, refresh_clip_models # pylint: disable=unused-import
+from modules.caption.vqa import vlm_models, vlm_prompts, vlm_system, vlm_default # pylint: disable=unused-import
 
 
 if TYPE_CHECKING:
     # Behavior modified by __future__.annotations
     from diffusers import DiffusionPipeline
+    from modules.shared_legacy import LegacyOption
     from modules.ui_extra_networks import ExtraNetworksPage
 
 
@@ -77,6 +81,7 @@ data_path = paths.data_path
 backend = Backend.DIFFUSERS
 if cmd_opts.use_openvino: # override for openvino
     os.environ.setdefault('PYTORCH_TRACING_MODE', 'TORCHFX')
+    from modules.intel.openvino import get_device_list as get_openvino_device_list # pylint: disable=ungrouped-imports,unused-import
 elif cmd_opts.use_ipex or devices.has_xpu():
     from modules.intel.ipex import ipex_init
     ok, e = ipex_init()
@@ -152,6 +157,7 @@ startup_offload_mode, startup_offload_min_gpu, startup_offload_max_gpu, startup_
 
 log.debug('Initializing: settings')
 from modules import ui_definitions
+from modules.ui_definitions import OptionInfo, options_section # pylint: disable=unused-import
 options_templates = ui_definitions.create_settings(cmd_opts)
 from modules.shared_legacy import get_legacy_options
 options_templates.update(get_legacy_options())
diff --git a/modules/sharpfin/cms.py b/modules/sharpfin/cms.py
index 30c71f902..18f88bfe3 100644
--- a/modules/sharpfin/cms.py
+++ b/modules/sharpfin/cms.py
@@ -131,7 +131,7 @@ def apply_srgb(
                             flags=flags
                         )
                     else:
-                        img = cast('Image', profileToProfile(
+                        img = cast(Image, profileToProfile(
                             img,
                             profile,
                             _SRGB,
diff --git a/modules/teacache/teacache_hidream.py b/modules/teacache/teacache_hidream.py
index f2f05c6a4..cb3767cab 100644
--- a/modules/teacache/teacache_hidream.py
+++ b/modules/teacache/teacache_hidream.py
@@ -1,6 +1,6 @@
 from typing import Any, Dict, List, Optional, Tuple
 from diffusers.models.modeling_outputs import Transformer2DModelOutput
-from diffusers.utils import deprecate, USE_PEFT_BACKEND, logging, scale_lora_layers, unscale_lora_layers
+from diffusers.utils import logging, deprecate, USE_PEFT_BACKEND, logging, scale_lora_layers, unscale_lora_layers
 
 import torch
 import numpy as np
diff --git a/modules/ui_models_load.py b/modules/ui_models_load.py
index 72da42c18..9246a10d6 100644
--- a/modules/ui_models_load.py
+++ b/modules/ui_models_load.py
@@ -222,7 +222,7 @@ def create_ui(gr_status, gr_file):
             if param.name == 'self' or param.name == 'args' or param.name == 'kwargs':
                 continue
             component = Component(param)
-            debug_log(f'Model component: {component!s}')
+            debug_log(f'Model component: {str(component)}')
             components.append(component)
         return components
 
diff --git a/modules/video_models/google_veo.py b/modules/video_models/google_veo.py
index 557499511..158ff05c0 100644
--- a/modules/video_models/google_veo.py
+++ b/modules/video_models/google_veo.py
@@ -6,7 +6,7 @@ import sys
 sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..')))
 
 from PIL import Image
-from installer import install
+from installer import install, reload
 from modules.logger import log
 
 
diff --git a/modules/video_models/video_load.py b/modules/video_models/video_load.py
index 642147e54..819706767 100644
--- a/modules/video_models/video_load.py
+++ b/modules/video_models/video_load.py
@@ -30,6 +30,7 @@ def load_custom(model_name: str):
 
 
 def load_model(selected: models_def.Model):
+    from modules import sdnq # pylint: disable=unused-import
     if selected is None or selected.repo is None:
         return ''
     global loaded_model # pylint: disable=global-statement
diff --git a/modules/video_models/video_ui.py b/modules/video_models/video_ui.py
index 5d2c71b2c..baab34bd1 100644
--- a/modules/video_models/video_ui.py
+++ b/modules/video_models/video_ui.py
@@ -64,7 +64,7 @@ def run_video(*args):
     selected = get_selected(engine, model)
     if not selected or engine is None or model is None or engine == 'None' or model == 'None':
         return video_utils.queue_err('model not selected')
-    debug(f'Video run: {selected!s}')
+    debug(f'Video run: {str(selected)}')
     if selected and 'Hunyuan' in selected.name:
         return video_run.generate(*args)
     elif selected and 'LTX' in selected.name:
diff --git a/pipelines/bria/bria_pipeline.py b/pipelines/bria/bria_pipeline.py
index 0c4d160d7..6049e3f45 100644
--- a/pipelines/bria/bria_pipeline.py
+++ b/pipelines/bria/bria_pipeline.py
@@ -622,7 +622,7 @@ class BriaPipeline(FluxPipeline):
 
     @staticmethod
     def _unpack_latents(latents, height, width, vae_scale_factor):
-        batch_size, _num_patches, channels = latents.shape
+        batch_size, num_patches, channels = latents.shape
 
         height = height // vae_scale_factor
         width = width // vae_scale_factor
diff --git a/pipelines/f_lite/f_lite.model.py b/pipelines/f_lite/f_lite.model.py
index 3adbb9b85..e56e6545b 100644
--- a/pipelines/f_lite/f_lite.model.py
+++ b/pipelines/f_lite/f_lite.model.py
@@ -233,7 +233,7 @@ class PatchEmbed(nn.Module):
         self.patch_size = patch_size
 
     def forward(self, x):
-        _B, _C, _H, _W = x.shape
+        B, C, H, W = x.shape
         x = self.patch_proj(x)
         x = rearrange(x, "b c h w -> b (h w) c")
         return x
@@ -380,7 +380,7 @@ class DiT(ModelMixin, ConfigMixin, FromOriginalModelMixin, PeftAdapterMixin):  #
 
     @apply_forward_hook
     def forward(self, x, context, timesteps):
-        b, _c, h, w = x.shape
+        b, c, h, w = x.shape
         x = self.patch_embed(x)  # b, T, d
 
         x = torch.cat([self.register_tokens.repeat(b, 1, 1), x], 1)  # b, T + N, d
diff --git a/pipelines/f_lite/model.py b/pipelines/f_lite/model.py
index 3adbb9b85..e56e6545b 100644
--- a/pipelines/f_lite/model.py
+++ b/pipelines/f_lite/model.py
@@ -233,7 +233,7 @@ class PatchEmbed(nn.Module):
         self.patch_size = patch_size
 
     def forward(self, x):
-        _B, _C, _H, _W = x.shape
+        B, C, H, W = x.shape
         x = self.patch_proj(x)
         x = rearrange(x, "b c h w -> b (h w) c")
         return x
@@ -380,7 +380,7 @@ class DiT(ModelMixin, ConfigMixin, FromOriginalModelMixin, PeftAdapterMixin):  #
 
     @apply_forward_hook
     def forward(self, x, context, timesteps):
-        b, _c, h, w = x.shape
+        b, c, h, w = x.shape
         x = self.patch_embed(x)  # b, T, d
 
         x = torch.cat([self.register_tokens.repeat(b, 1, 1), x], 1)  # b, T + N, d
diff --git a/pipelines/hidream/scheduler_flashfloweuler.py b/pipelines/hidream/scheduler_flashfloweuler.py
index 97b7fa16a..3d6f32c27 100644
--- a/pipelines/hidream/scheduler_flashfloweuler.py
+++ b/pipelines/hidream/scheduler_flashfloweuler.py
@@ -194,7 +194,7 @@ class FlashFlowMatchEulerDiscreteScheduler(SchedulerMixin, ConfigMixin):
 
     def set_timesteps(
             self,
-            num_inference_steps: int | None = None,
+            num_inference_steps: int = None,
             device: Union[str, torch.device] = None,
             sigmas: Optional[List[float]] = None,
             mu: Optional[float] = None,
diff --git a/pipelines/hidream/scheduler_flowunipc.py b/pipelines/hidream/scheduler_flowunipc.py
index a25a751dc..3b3d8ce29 100644
--- a/pipelines/hidream/scheduler_flowunipc.py
+++ b/pipelines/hidream/scheduler_flowunipc.py
@@ -53,7 +53,7 @@ class FlowUniPCMultistepScheduler(SchedulerMixin, ConfigMixin):
             Any other scheduler that if specified, the algorithm becomes `solver_p + UniC`.
         use_karras_sigmas (`bool`, *optional*, defaults to `False`):
             Whether to use Karras sigmas for step sizes in the noise schedule during the sampling process. If `True`,
-            the sigmas are determined according to a sequence of noise levels {sigma_i}.
+            the sigmas are determined according to a sequence of noise levels {σi}.
         use_exponential_sigmas (`bool`, *optional*, defaults to `False`):
             Whether to use exponential sigmas for step sizes in the noise schedule during the sampling process.
         timestep_spacing (`str`, defaults to `"linspace"`):
@@ -294,7 +294,7 @@ class FlowUniPCMultistepScheduler(SchedulerMixin, ConfigMixin):
             `torch.Tensor`:
                 The converted model output.
         """
-        _ = args[0] if len(args) > 0 else kwargs.pop("timestep", None)
+        timestep = args[0] if len(args) > 0 else kwargs.pop("timestep", None)
         if sample is None:
             if len(args) > 1:
                 sample = args[1]
@@ -303,7 +303,7 @@ class FlowUniPCMultistepScheduler(SchedulerMixin, ConfigMixin):
                     "missing `sample` as a required keyward argument")
 
         sigma = self.sigmas[self.step_index]
-        _alpha_t, sigma_t = self._sigma_to_alpha_sigma_t(sigma)
+        alpha_t, sigma_t = self._sigma_to_alpha_sigma_t(sigma)
 
         if self.predict_x0:
             if self.config.prediction_type == "flow_prediction":
@@ -342,7 +342,7 @@ class FlowUniPCMultistepScheduler(SchedulerMixin, ConfigMixin):
         model_output: torch.Tensor,
         *args,
         sample: torch.Tensor = None,
-        order: int | None = None,  # pyright: ignore
+        order: int = None,  # pyright: ignore
         **kwargs,
     ) -> torch.Tensor:
         """
@@ -362,7 +362,7 @@ class FlowUniPCMultistepScheduler(SchedulerMixin, ConfigMixin):
             `torch.Tensor`:
                 The sample tensor at the previous timestep.
         """
-        _ = args[0] if len(args) > 0 else kwargs.pop(
+        prev_timestep = args[0] if len(args) > 0 else kwargs.pop(
             "prev_timestep", None)
         if sample is None:
             if len(args) > 1:
@@ -473,7 +473,7 @@ class FlowUniPCMultistepScheduler(SchedulerMixin, ConfigMixin):
         *args,
         last_sample: torch.Tensor = None,
         this_sample: torch.Tensor = None,
-        order: int | None = None,  # pyright: ignore
+        order: int = None,  # pyright: ignore
         **kwargs,
     ) -> torch.Tensor:
         """
@@ -495,7 +495,7 @@ class FlowUniPCMultistepScheduler(SchedulerMixin, ConfigMixin):
             `torch.Tensor`:
                 The corrected sample tensor at the current timestep.
         """
-        _ = args[0] if len(args) > 0 else kwargs.pop(
+        this_timestep = args[0] if len(args) > 0 else kwargs.pop(
             "this_timestep", None)
         if last_sample is None:
             if len(args) > 1:
diff --git a/pipelines/lumina_dimmo/lumina_dimoo.py b/pipelines/lumina_dimmo/lumina_dimoo.py
index 44efbffef..1ce6298af 100644
--- a/pipelines/lumina_dimmo/lumina_dimoo.py
+++ b/pipelines/lumina_dimmo/lumina_dimoo.py
@@ -17,7 +17,8 @@ import sys
 from abc import abstractmethod
 from dataclasses import dataclass, fields
 from enum import Enum
-from typing import Callable, Dict, Iterable, List, NamedTuple, Optional, Sequence, Tuple, Union, cast
+from typing import Any, Callable, Dict, Iterable, List, NamedTuple, Optional, Sequence, Tuple, Union, cast
+from accelerate import init_empty_weights
 
 from tqdm.rich import tqdm
 import numpy as np
@@ -34,6 +35,7 @@ from diffusers import DiffusionPipeline, VQModel
 from diffusers.utils import BaseOutput, logging, replace_example_docstring
 from diffusers.image_processor import PipelineImageInput, VaeImageProcessor
 
+from diffusers.pipelines.pipeline_utils import ImagePipelineOutput
 
 
 logger = logging.get_logger(__name__)  # pylint: disable=invalid-name
@@ -51,7 +53,7 @@ class StrEnum(str, Enum):
         return self.value
 
     def __repr__(self) -> str:
-        return f"'{self!s}'"
+        return f"'{str(self)}'"
 
 
 class LayerNormType(StrEnum):
@@ -943,7 +945,7 @@ class LLaDALlamaBlock(LLaDABlock):
         cat="cond",
         to_compute_mask=None,
     ) -> Tuple[torch.Tensor, Optional[Tuple[torch.Tensor, torch.Tensor]]]:
-        _B, _T, D = x.shape
+        B, T, D = x.shape
 
         x_normed = self.attn_norm(x)
         q = self.q_proj(x_normed)
@@ -1610,7 +1612,7 @@ def get_num_transfer_tokens(mask_index, steps):
 
 
 def mask_by_random_topk(keep_n, probs, temperature=1.0, generator=None):
-    B, _S = probs.shape
+    B, S = probs.shape
     noise = gumbel_noise(probs, generator=generator)
 
     conf = probs / temperature + noise
@@ -2047,7 +2049,7 @@ class LuminaDiMOOPipeline(DiffusionPipeline):
         """
         device = next(model.parameters()).device
         prompt = prompt.to(device)
-        B, _P = prompt.shape
+        B, P = prompt.shape
         assert B == 1, "batch>1 not supported - wrap in loop if needed"
 
         x = prompt
@@ -2163,7 +2165,7 @@ class LuminaDiMOOPipeline(DiffusionPipeline):
 
         device = next(model.parameters()).device
         prompt = prompt.to(device)
-        B, _P = prompt.shape
+        B, P = prompt.shape
         assert B == 1, "batch>1 not supported - wrap in loop if needed"
 
         x = prompt
@@ -2492,7 +2494,7 @@ class LuminaDiMOOPipeline(DiffusionPipeline):
         uncon_prompt_token = self.tokenizer(uncon_prompt)["input_ids"]
 
         if painting_mode:
-            img_mask_token, _img_vis = encode_img_with_paint(
+            img_mask_token, img_vis = encode_img_with_paint(
                 painting_image,
                 vqvae=self.vqvae,
                 mask_h_ratio=mask_h_ratio,
@@ -2572,7 +2574,7 @@ class LuminaDiMOOPipeline(DiffusionPipeline):
         processed_image = var_center_crop(image, crop_size_list=crop_size_list)
 
         image_width, image_height = processed_image.size
-        _seq_len, _newline_every, _token_grid_height, _token_grid_width = calculate_vq_params(
+        seq_len, newline_every, _token_grid_height, _token_grid_width = calculate_vq_params(
             image_height, image_width, self.vae_scale_factor
         )
 
diff --git a/pipelines/meissonic/pipeline_img2img.py b/pipelines/meissonic/pipeline_img2img.py
index 12359d42f..2aaf9d987 100644
--- a/pipelines/meissonic/pipeline_img2img.py
+++ b/pipelines/meissonic/pipeline_img2img.py
@@ -17,7 +17,7 @@ import torch
 from transformers import CLIPTextModelWithProjection, CLIPTokenizer
 
 from diffusers.image_processor import PipelineImageInput, VaeImageProcessor
-from diffusers.models import VQModel
+from diffusers.models import UVit2DModel, VQModel
 # from diffusers.schedulers import AmusedScheduler
 from .scheduler import Scheduler
 from diffusers.utils import replace_example_docstring
@@ -276,7 +276,7 @@ class MeissonicImg2ImgPipeline(DiffusionPipeline):
             self.vqvae.float()
 
         latents = self.vqvae.encode(image.to(dtype=self.vqvae.dtype, device=self._execution_device)).latents
-        latents_bsz, _channels, latents_height, latents_width = latents.shape
+        latents_bsz, channels, latents_height, latents_width = latents.shape
         latents = self.vqvae.quantize(latents)[2][2].reshape(latents_bsz, latents_height, latents_width)
         latents = self.scheduler.add_noise(
             latents, self.scheduler.timesteps[start_timestep_idx - 1], generator=generator
diff --git a/pipelines/meissonic/pipeline_inpaint.py b/pipelines/meissonic/pipeline_inpaint.py
index f43290d3a..aa352d9b4 100644
--- a/pipelines/meissonic/pipeline_inpaint.py
+++ b/pipelines/meissonic/pipeline_inpaint.py
@@ -289,7 +289,7 @@ class MeissonicInpaintPipeline(DiffusionPipeline):
             self.vqvae.float()
 
         latents = self.vqvae.encode(image.to(dtype=self.vqvae.dtype, device=self._execution_device)).latents
-        latents_bsz, _channels, latents_height, latents_width = latents.shape
+        latents_bsz, channels, latents_height, latents_width = latents.shape
         latents = self.vqvae.quantize(latents)[2][2].reshape(latents_bsz, latents_height, latents_width)
 
         mask = self.mask_processor.preprocess(
diff --git a/pipelines/meissonic/transformer.py b/pipelines/meissonic/transformer.py
index 683e34947..c2336d323 100644
--- a/pipelines/meissonic/transformer.py
+++ b/pipelines/meissonic/transformer.py
@@ -22,7 +22,7 @@ import torch.nn.functional as F
 
 from diffusers.configuration_utils import ConfigMixin, register_to_config
 from diffusers.loaders import FromOriginalModelMixin, PeftAdapterMixin
-from diffusers.models.attention import FeedForward, SkipFFTransformerBlock
+from diffusers.models.attention import FeedForward, BasicTransformerBlock, SkipFFTransformerBlock
 from diffusers.models.attention_processor import (
     Attention,
     AttentionProcessor,
@@ -30,7 +30,7 @@ from diffusers.models.attention_processor import (
     # FusedFluxAttnProcessor2_0,
 )
 from diffusers.models.modeling_utils import ModelMixin
-from diffusers.models.normalization import AdaLayerNormZero, AdaLayerNormZeroSingle, GlobalResponseNorm, RMSNorm
+from diffusers.models.normalization import AdaLayerNormContinuous, AdaLayerNormZero, AdaLayerNormZeroSingle, GlobalResponseNorm, RMSNorm
 from diffusers.utils import USE_PEFT_BACKEND, is_torch_version, logging, scale_lora_layers, unscale_lora_layers
 from diffusers.utils.torch_utils import maybe_allow_in_graph
 from diffusers.models.embeddings import CombinedTimestepGuidanceTextProjEmbeddings, CombinedTimestepTextProjEmbeddings,TimestepEmbedding, get_timestep_embedding #,FluxPosEmbed
diff --git a/pipelines/model_nextstep.py b/pipelines/model_nextstep.py
index cf993a0df..b3b962c6c 100644
--- a/pipelines/model_nextstep.py
+++ b/pipelines/model_nextstep.py
@@ -1,6 +1,7 @@
 # import transformers
-from modules import sd_models # pylint: disable=unused-import
+from modules import shared, devices, sd_models, model_quant # pylint: disable=unused-import
 from modules.logger import log
+from pipelines import generic # pylint: disable=unused-import
 
 
 def load_nextstep(checkpoint_info, diffusers_load_config=None): # pylint: disable=unused-argument
diff --git a/pipelines/segmoe/segmoe_model.py b/pipelines/segmoe/segmoe_model.py
index d861bc776..a542c1fbb 100644
--- a/pipelines/segmoe/segmoe_model.py
+++ b/pipelines/segmoe/segmoe_model.py
@@ -1,6 +1,6 @@
 import gc
 from collections import OrderedDict
-from typing import Any
+from typing import Any, Dict, Callable
 import os
 from copy import deepcopy
 from math import ceil
@@ -166,7 +166,7 @@ class SegMoEPipeline:
             if not os.path.isfile("base/model.safetensors"):
                 os.system(
                     "wget -O "
-                     "base/model.safetensors"
+                    + "base/model.safetensors"
                     + self.config["base_model"]
                     + " --content-disposition"
                 )
@@ -221,8 +221,8 @@ class SegMoEPipeline:
                             if not os.path.isfile(f"expert_{i}/model.safetensors"):
                                 os.system(
                                     f"wget {exp['source_model']} -O "
-                                     f"expert_{i}/model.safetensors"
-                                     " --content-disposition"
+                                    + f"expert_{i}/model.safetensors"
+                                    + " --content-disposition"
                                 )
                         exp["source_model"] = f"expert_{i}/model.safetensors"
                         expert = DiffusionPipeline.from_single_file(
@@ -267,8 +267,8 @@ class SegMoEPipeline:
                                 ):
                                     os.system(
                                         f"wget {lora['source_model']} -O "
-                                         f"expert_{i}/lora_{j}/pytorch_lora_weights.safetensors"
-                                         " --content-disposition"
+                                        + f"expert_{i}/lora_{j}/pytorch_lora_weights.safetensors"
+                                        + " --content-disposition"
                                     )
                                 lora["source_model"] = f"expert_{j}/lora_{j}"
                                 expert.load_lora_weights(lora["source_model"])
@@ -299,8 +299,8 @@ class SegMoEPipeline:
                             ):
                                 os.system(
                                     f"wget {lora['source_model']} -O "
-                                     f"lora_{i}/pytorch_lora_weights.safetensors"
-                                     " --content-disposition"
+                                    + f"lora_{i}/pytorch_lora_weights.safetensors"
+                                    + " --content-disposition"
                                 )
                             lora["source_model"] = f"lora_{i}"
                             self.pipe.load_lora_weights(lora["source_model"])
@@ -338,8 +338,8 @@ class SegMoEPipeline:
                             ):
                                 os.system(
                                     f"wget {lora['source_model']} -O "
-                                     f"lora_{i}/pytorch_lora_weights.safetensors"
-                                     " --content-disposition"
+                                    + f"lora_{i}/pytorch_lora_weights.safetensors"
+                                    + " --content-disposition"
                                 )
                             lora["source_model"] = f"lora_{i}"
                             experts[j[i]].load_lora_weights(lora["source_model"])
diff --git a/pipelines/step1x/pipeline_step1x_edit.py b/pipelines/step1x/pipeline_step1x_edit.py
index 7c4f0e228..9584cfd18 100644
--- a/pipelines/step1x/pipeline_step1x_edit.py
+++ b/pipelines/step1x/pipeline_step1x_edit.py
@@ -507,7 +507,7 @@ User Prompt:'''
     @staticmethod
     # Copied from diffusers.pipelines.flux.pipeline_flux.FluxPipeline._unpack_latents
     def _unpack_latents(latents, height, width, vae_scale_factor):
-        batch_size, _num_patches, channels = latents.shape
+        batch_size, num_patches, channels = latents.shape
 
         # VAE applies 8x compression on images but we must also account for packing which requires
         # latent height and width to be divisible by 2.
diff --git a/pipelines/step1x/transformer_step1x_edit.py b/pipelines/step1x/transformer_step1x_edit.py
index 796833b86..fe09e71c5 100644
--- a/pipelines/step1x/transformer_step1x_edit.py
+++ b/pipelines/step1x/transformer_step1x_edit.py
@@ -2,13 +2,16 @@ import inspect
 from typing import Any, Dict, List, Optional, Tuple, Union
 
 import math
+from functools import partial
+import numpy as np
 import torch
 import torch.nn as nn
 import torch.nn.functional as F
 
 from diffusers.configuration_utils import ConfigMixin, register_to_config
 from diffusers.loaders import FromOriginalModelMixin, PeftAdapterMixin
-from diffusers.utils import USE_PEFT_BACKEND, logging, scale_lora_layers, unscale_lora_layers
+from diffusers.utils import USE_PEFT_BACKEND, deprecate, logging, scale_lora_layers, unscale_lora_layers
+from diffusers.utils.import_utils import is_torch_npu_available
 from diffusers.utils.torch_utils import maybe_allow_in_graph
 from diffusers.models.attention import AttentionMixin, AttentionModuleMixin, FeedForward
 from diffusers.models.attention_dispatch import dispatch_attention_fn
@@ -527,7 +530,7 @@ class Step1XEditCrossAttnBlock(torch.nn.Module):
         y: torch.Tensor=None,
 
     ):
-        gate_msa, _gate_mlp = self.adaLN_modulation(c).chunk(2, dim=1)
+        gate_msa, gate_mlp = self.adaLN_modulation(c).chunk(2, dim=1)
 
         norm_x = self.norm1(x)
         norm_y = self.norm1_2(y)
diff --git a/pipelines/ultraflux/autoencoder_kl.py b/pipelines/ultraflux/autoencoder_kl.py
index f624bec4a..5a47ba970 100644
--- a/pipelines/ultraflux/autoencoder_kl.py
+++ b/pipelines/ultraflux/autoencoder_kl.py
@@ -1,6 +1,7 @@
 # Code borrow from https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/autoencoders/autoencoder_kl.py
 from typing import Dict, Optional, Tuple, Union
 
+import os
 import torch
 import torch.nn as nn
 
diff --git a/pipelines/ultraflux/pipeline_flux.py b/pipelines/ultraflux/pipeline_flux.py
index 5874ba2c8..6ceb9f7bb 100644
--- a/pipelines/ultraflux/pipeline_flux.py
+++ b/pipelines/ultraflux/pipeline_flux.py
@@ -8,7 +8,7 @@ from transformers import CLIPTextModel, CLIPTokenizer, T5EncoderModel, T5Tokeniz
 
 
 from diffusers.image_processor import VaeImageProcessor
-from diffusers.loaders import FluxLoraLoaderMixin
+from diffusers.loaders import FluxLoraLoaderMixin, FromSingleFileMixin
 from pipelines.ultraflux.autoencoder_kl import AutoencoderUltraFluxKL
 from diffusers.models.transformers import FluxTransformer2DModel
 from diffusers.schedulers import FlowMatchEulerDiscreteScheduler
@@ -430,7 +430,7 @@ class UltraFluxPipeline(DiffusionPipeline, FluxLoraLoaderMixin):
 
     @staticmethod
     def _unpack_latents(latents, height, width, vae_scale_factor):
-        batch_size, _num_patches, channels = latents.shape
+        batch_size, num_patches, channels = latents.shape
 
         height = height // vae_scale_factor
         width = width // vae_scale_factor
diff --git a/pipelines/vibe/vibe_sana_editing.py b/pipelines/vibe/vibe_sana_editing.py
index aa1f6adcb..3b88bed2e 100644
--- a/pipelines/vibe/vibe_sana_editing.py
+++ b/pipelines/vibe/vibe_sana_editing.py
@@ -3,7 +3,7 @@
 from typing import Any
 
 import torch
-from diffusers import SanaTransformer2DModel
+from diffusers import ModelMixin, SanaTransformer2DModel
 from diffusers.configuration_utils import register_to_config
 from diffusers.models.attention_processor import Attention
 from diffusers.models.embeddings import PatchEmbed, PixArtAlphaTextProjection
diff --git a/pipelines/xomni/modeling_vit.py b/pipelines/xomni/modeling_vit.py
index 260098fc8..150571c1d 100644
--- a/pipelines/xomni/modeling_vit.py
+++ b/pipelines/xomni/modeling_vit.py
@@ -39,7 +39,7 @@ def _no_grad_trunc_normal_(tensor, mean, std, a, b):
         # Values are generated by using a truncated uniform distribution and
         # then using the inverse CDF for the normal distribution.
         # Get upper and lower cdf values
-        l = norm_cdf((a - mean) / std)
+        l = norm_cdf((a - mean) / std)  # noqa: E741
         u = norm_cdf((b - mean) / std)
 
         # Uniformly fill tensor with values from [l, u], then translate to
diff --git a/pyproject.toml b/pyproject.toml
index de1c4b741..eb2fd67e8 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -12,26 +12,43 @@ target-version = "py310"
 exclude = [
     "venv",
     ".git",
-    ".vscode",
     ".ruff_cache",
-    "__pycache__",
-    "node_modules",
-    "modules/teacache",
-    "modules/sharpfin",
-    "modules/seedvr/src",
-    "modules/postprocess/aurasr_arch.py",
-    "modules/flash_attn_triton_amd/utils.py",
-    "modules/control/units/xs_pipe.py",
+    ".vscode",
+    "modules/cfgzero",
+    "modules/flash_attn_triton_amd",
+    "modules/hidiffusion",
+    "modules/intel/ipex",
     "modules/pag",
-    "scripts/consistory",
-    "scripts/daam",
-    "scripts/freescale",
-    "scripts/instantir",
-    "scripts/lbm",
-    "scripts/pulid",
-    "pipelines/xomni",
+    "modules/schedulers",
+    "modules/teacache",
+    "modules/seedvr",
+    "modules/sharpfin",
+    "modules/control/proc",
+    "modules/control/units",
+    "modules/control/units/xs_pipe.py",
+    "modules/postprocess/aurasr_arch.py",
+    "pipelines/meissonic",
     "pipelines/omnigen2",
+    "pipelines/hdm",
+    "pipelines/hidream",
+    "pipelines/segmoe",
+    "pipelines/xomni",
+    "pipelines/chrono",
+    "pipelines/step1x",
+    "pipelines/vibe",
+    "pipelines/ultraflux",
+    "pipelines/lumina_dimmo",
+    "scripts/lbm",
+    "scripts/daam",
+    "scripts/xadapter",
+    "scripts/pulid",
+    "scripts/instantir",
+    "scripts/freescale",
+    "scripts/consistory",
+    "extensions-builtin/Lora",
     "extensions-builtin/sd-extension-chainner/nodes",
+    "extensions-builtin/sd-webui-agent-scheduler",
+    "extensions-builtin/sdnext-modernui/node_modules",
 ]
 
 [tool.ruff.lint]
@@ -64,23 +81,25 @@ ignore = [
     "B008",   # Do not perform function call in argument defaults
     "B905",   # Strict zip() usage
     "C408",   # Unnecessary `dict` call
-    "C417",   # Unnecessary `map` comprehension
-    "C420",   # Unnecessary `dict` comprehension
+    "C420",   # Unnecessary dict comprehension for iterable; use `dict.fromkeys` instead
     "E402",   # Module level import not at top of file
     "E501",   # Line too long
-    "E721",   # Do not compare types
-    "E731",   # Do not assign a `lambda` expression
+    "E721",   # Do not compare types, use `isinstance()`
+    "E731",   # Do not assign a `lambda` expression, use a `def`
     "E741",   # Ambiguous variable name
-    "F401",   # Import unused
-    "I001",   # Import block un-sorted
+    "EXE001", # file with shebang is not marked executable
+    "F401",   # Imported by unused
+    "I001",   # Import block is un-sorted or un-formatted
     "NPY002", # replace legacy random
     "RUF005", # Consider iterable unpacking
     "RUF008", # Do not use mutable default values for dataclass
+    "RUF010", # Use explicit conversion flag
     "RUF012", # Mutable class attributes
     "RUF015", # Prefer `next(...)` over single element slice
     "RUF022", # All is not sorted
     "RUF046", # Value being cast to `int` is already an integer
     "RUF051", # Prefer pop over del
+    "RUF059", # Unpacked variables are not used
 ]
 fixable = ["ALL"]
 unfixable = []
@@ -110,11 +129,12 @@ main.fail-on=""
 main.fail-under=10
 main.ignore="CVS"
 main.ignore-paths=[
+    "venv",
+    "node_modules",
     "__pycache__",
     ".git",
     ".ruff_cache",
     ".vscode",
-    "venv",
     "modules/apg",
     "modules/cfgzero",
     "modules/control/proc",
@@ -122,55 +142,58 @@ main.ignore-paths=[
     "modules/dml",
     "modules/face",
     "modules/flash_attn_triton_amd",
-    "modules/framepack/pipeline",
     "modules/ggml",
     "modules/hidiffusion",
     "modules/hijack/ddpm_edit.py",
     "modules/intel",
     "modules/intel/ipex",
+    "modules/framepack/pipeline",
     "modules/onnx_impl",
     "modules/pag",
     "modules/postprocess/aurasr_arch.py",
     "modules/prompt_parser_xhinker.py",
     "modules/ras",
-    "modules/res4lyf",
-    "modules/rife",
-    "modules/schedulers",
     "modules/seedvr",
     "modules/sharpfin",
+    "modules/rife",
+    "modules/schedulers",
     "modules/taesd",
     "modules/teacache",
     "modules/todo",
-    "node_modules",
+    "modules/res4lyf",
     "pipelines/bria",
-    "pipelines/chrono",
-    "pipelines/f_lite",
     "pipelines/flex2",
-    "pipelines/hdm",
+    "pipelines/f_lite",
     "pipelines/hidream",
-    "pipelines/lumina_dimmo",
+    "pipelines/hdm",
     "pipelines/meissonic",
     "pipelines/omnigen2",
     "pipelines/segmoe",
-    "pipelines/step1x",
-    "pipelines/ultraflux",
-    "pipelines/vibe",
     "pipelines/xomni",
+    "pipelines/chrono",
+    "pipelines/step1x",
+    "pipelines/vibe",
+    "pipelines/ultraflux",
+    "pipelines/lumina_dimmo",
     "scripts/consistory",
     "scripts/ctrlx",
     "scripts/daam",
     "scripts/demofusion",
-    "scripts/differential_diffusion.py",
     "scripts/freescale",
     "scripts/infiniteyou",
     "scripts/instantir",
-    "scripts/layerdiffuse",
     "scripts/lbm",
+    "scripts/layerdiffuse",
     "scripts/mod",
     "scripts/pixelsmith",
+    "scripts/differential_diffusion.py",
     "scripts/pulid",
     "scripts/xadapter",
+    "repositories",
     "extensions-builtin/sd-extension-chainner/nodes",
+    "extensions-builtin/sd-webui-agent-scheduler",
+    "extensions-builtin/sdnext-modernui/node_modules",
+    "extensions-builtin/sdnext-kanvas/node_modules",
 ]
 main.ignore-patterns=[
     ".*test*.py$",
diff --git a/scripts/consistory/consistory_unet_sdxl.py b/scripts/consistory/consistory_unet_sdxl.py
index 2c19f0de5..4e6e4b335 100644
--- a/scripts/consistory/consistory_unet_sdxl.py
+++ b/scripts/consistory/consistory_unet_sdxl.py
@@ -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."""
diff --git a/scripts/consistory_ext.py b/scripts/consistory_ext.py
index 4f077abc9..e0de9f1d4 100644
--- a/scripts/consistory_ext.py
+++ b/scripts/consistory_ext.py
@@ -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
diff --git a/scripts/custom_code.py b/scripts/custom_code.py
index 42133c22f..1701cdf8b 100644
--- a/scripts/custom_code.py
+++ b/scripts/custom_code.py
@@ -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):
diff --git a/scripts/differential_diffusion.py b/scripts/differential_diffusion.py
index 0ca8fc463..d0f13a078 100644
--- a/scripts/differential_diffusion.py
+++ b/scripts/differential_diffusion.py
@@ -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)
diff --git a/scripts/example.py b/scripts/example.py
index 61efe02f1..dafcd578f 100644
--- a/scripts/example.py
+++ b/scripts/example.py
@@ -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
 
diff --git a/scripts/freescale/free_lunch_utils.py b/scripts/freescale/free_lunch_utils.py
index 0852584b9..ebf165105 100644
--- a/scripts/freescale/free_lunch_utils.py
+++ b/scripts/freescale/free_lunch_utils.py
@@ -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)
diff --git a/scripts/infiniteyou/resampler.py b/scripts/infiniteyou/resampler.py
index f6f3d5c56..6d0011e83 100644
--- a/scripts/infiniteyou/resampler.py
+++ b/scripts/infiniteyou/resampler.py
@@ -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)
diff --git a/scripts/instantir/sdxl_instantir.py b/scripts/instantir/sdxl_instantir.py
index ea376ef02..bfb4f84e9 100644
--- a/scripts/instantir/sdxl_instantir.py
+++ b/scripts/instantir/sdxl_instantir.py
@@ -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:
diff --git a/scripts/mixture_of_diffusers.py b/scripts/mixture_of_diffusers.py
index 8d101ee78..601133590 100644
--- a/scripts/mixture_of_diffusers.py
+++ b/scripts/mixture_of_diffusers.py
@@ -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}')
diff --git a/scripts/mixture_tiling.py b/scripts/mixture_tiling.py
index e8315e84d..fcf7b7cf1 100644
--- a/scripts/mixture_tiling.py
+++ b/scripts/mixture_tiling.py
@@ -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:
diff --git a/scripts/prompt_enhance.py b/scripts/prompt_enhance.py
index a60857cd4..3162f0787 100644
--- a/scripts/prompt_enhance.py
+++ b/scripts/prompt_enhance.py
@@ -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')
diff --git a/scripts/pulid/eva_clip/factory.py b/scripts/pulid/eva_clip/factory.py
index 3051e7c6c..b33929625 100644
--- a/scripts/pulid/eva_clip/factory.py
+++ b/scripts/pulid/eva_clip/factory.py
@@ -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
 
 
diff --git a/scripts/pulid/eva_clip/hf_model.py b/scripts/pulid/eva_clip/hf_model.py
index 29d2f592c..1665ada0b 100644
--- a/scripts/pulid/eva_clip/hf_model.py
+++ b/scripts/pulid/eva_clip/hf_model.py
@@ -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
 
 
diff --git a/scripts/pulid/eva_clip/model.py b/scripts/pulid/eva_clip/model.py
index 5be65b752..05b055794 100644
--- a/scripts/pulid/eva_clip/model.py
+++ b/scripts/pulid/eva_clip/model.py
@@ -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,
diff --git a/scripts/pulid/eva_clip/timm_model.py b/scripts/pulid/eva_clip/timm_model.py
index 9b9233327..53bc4d469 100644
--- a/scripts/pulid/eva_clip/timm_model.py
+++ b/scripts/pulid/eva_clip/timm_model.py
@@ -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):
diff --git a/scripts/pulid/eva_clip/tokenizer.py b/scripts/pulid/eva_clip/tokenizer.py
index 45fa860a9..b76e2a3aa 100644
--- a/scripts/pulid/eva_clip/tokenizer.py
+++ b/scripts/pulid/eva_clip/tokenizer.py
@@ -12,6 +12,7 @@ import regex as re
 import torch
 
 # https://stackoverflow.com/q/62691279
+import os
 os.environ["TOKENIZERS_PARALLELISM"] = "false"
 
 
diff --git a/scripts/pulid/eva_clip/utils.py b/scripts/pulid/eva_clip/utils.py
index c5e3dfd3b..1c3c06201 100644
--- a/scripts/pulid/eva_clip/utils.py
+++ b/scripts/pulid/eva_clip/utils.py
@@ -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)
diff --git a/scripts/pulid/pulid_flux.py b/scripts/pulid/pulid_flux.py
index 8e90d6b27..13ea880c4 100644
--- a/scripts/pulid/pulid_flux.py
+++ b/scripts/pulid/pulid_flux.py
@@ -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
 
diff --git a/scripts/stablevideodiffusion.py b/scripts/stablevideodiffusion.py
index 779abef2d..6e023dd46 100644
--- a/scripts/stablevideodiffusion.py
+++ b/scripts/stablevideodiffusion.py
@@ -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
diff --git a/scripts/xyz/xyz_grid_classes.py b/scripts/xyz/xyz_grid_classes.py
index c13016ba4..ca78569ad 100644
--- a/scripts/xyz/xyz_grid_classes.py
+++ b/scripts/xyz/xyz_grid_classes.py
@@ -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,
diff --git a/scripts/xyz_grid.py b/scripts/xyz_grid.py
index 49ea4c9a2..d86e22af6 100644
--- a/scripts/xyz_grid.py
+++ b/scripts/xyz_grid.py
@@ -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
diff --git a/test/test-generation-api.py b/test/test-generation-api.py
index 98ec18982..1359d59e5 100644
--- a/test/test-generation-api.py
+++ b/test/test-generation-api.py
@@ -417,7 +417,7 @@ class GenerationAPITest:
             self.skip(f'param_{name}', 'baseline generation failed')
             return
 
-        data, _elapsed = self._txt2img(params)
+        data, elapsed = self._txt2img(params)
         if 'error' in data:
             self.record(False, f'param_{name}', f"generation error: {data}")
             return
@@ -505,7 +505,7 @@ class GenerationAPITest:
 
         # Vignette: corners should be darker than baseline corners
         def check_vignette(base, result, _data):
-            h, _w = base.shape[:2]
+            h, w = base.shape[:2]
             corner_size = h // 8
             base_corners = np.concatenate([
                 base[:corner_size, :corner_size].flatten(),
diff --git a/webui.py b/webui.py
index adf3b693d..b8d06697f 100644
--- a/webui.py
+++ b/webui.py
@@ -18,7 +18,7 @@ import modules.paths
 import modules.devices
 import modules.migrate
 from modules import shared
-from modules.call_queue import queue_lock, wrap_queued_call # pylint: disable=unused-import
+from modules.call_queue import queue_lock, wrap_queued_call, wrap_gradio_gpu_call # pylint: disable=unused-import
 import modules.gr_tempdir
 import modules.modeldata
 import modules.extensions