diff --git a/.pylintrc b/.pylintrc index 90a288a7c..00a59df29 100644 --- a/.pylintrc +++ b/.pylintrc @@ -23,6 +23,7 @@ ignore-paths=/usr/lib/.*$, modules/todo, modules/unipc, modules/xadapter, + modules/dcsolver, repositories, modules/prompt_parser_xhinker.py, extensions-builtin/sd-webui-agent-scheduler, @@ -136,6 +137,7 @@ disable=bad-inline-option, consider-using-get, consider-using-in, consider-using-min-builtin, + consider-using-max-builtin, consider-using-sys-exit, dangerous-default-value, deprecated-pragma, diff --git a/.ruff.toml b/.ruff.toml index f18b29ce2..52499859d 100644 --- a/.ruff.toml +++ b/.ruff.toml @@ -13,6 +13,7 @@ exclude = [ "modules/todo", "modules/unipc", "modules/xadapter", + "modules/dcsolver", "modules/intel/openvino", "modules/intel/ipex", "modules/segmoe", diff --git a/installer.py b/installer.py index 10e41051f..d5170fb89 100644 --- a/installer.py +++ b/installer.py @@ -530,7 +530,7 @@ def install_rocm_zluda(): log.info('Using CPU-only torch') torch_command = os.environ.get('TORCH_COMMAND', 'torch torchvision') #else: - # TODO TBD after ROCm for Windows is released + # TODO after ROCm for Windows is released else: if rocm.version is None or float(rocm.version) > 6.1: # assume the latest if version check fails torch_command = os.environ.get('TORCH_COMMAND', 'torch torchvision --index-url https://download.pytorch.org/whl/rocm6.1') diff --git a/modules/images.py b/modules/images.py index c777a07d9..6882e97f5 100644 --- a/modules/images.py +++ b/modules/images.py @@ -221,7 +221,7 @@ def resize_image(resize_mode, im, width, height, upscaler_name=None, output_type def latent(im, w, h, upscaler): from modules.processing_vae import vae_encode, vae_decode import torch - latents = vae_encode(im, shared.sd_model, full_quality=False) # TODO enable full VAE mode + latents = vae_encode(im, shared.sd_model, full_quality=False) # TODO enable full VAE mode for resize-latent latents = torch.nn.functional.interpolate(latents, size=(int(h // 8), int(w // 8)), mode=upscaler["mode"], antialias=upscaler["antialias"]) im = vae_decode(latents, shared.sd_model, output_type='pil', full_quality=False)[0] return im diff --git a/modules/processing_diffusers.py b/modules/processing_diffusers.py index 9bc6f0ad6..2233a0798 100644 --- a/modules/processing_diffusers.py +++ b/modules/processing_diffusers.py @@ -179,7 +179,7 @@ def process_diffusers(p: processing.StableDiffusionProcessing): shared.state.job_count = 2 * p.n_iter shared.sd_model = sd_models.set_diffuser_pipe(shared.sd_model, sd_models.DiffusersTaskType.IMAGE_2_IMAGE) shared.log.info(f'HiRes: class={shared.sd_model.__class__.__name__} sampler="{p.hr_sampler_name}"') - if 'Upscale' in shared.sd_model.__class__.__name__ or 'Flux in shared.sd_refiner.__class__.__name__': + if 'Upscale' in shared.sd_model.__class__.__name__ or 'Flux' in shared.sd_model.__class__.__name__: output.images = processing_vae.vae_decode(latents=output.images, model=shared.sd_model, full_quality=p.full_quality, output_type='pil', width=p.width, height=p.height) if p.is_control and hasattr(p, 'task_args') and p.task_args.get('image', None) is not None: if hasattr(shared.sd_model, "vae") and output.images is not None and len(output.images) > 0: @@ -248,7 +248,7 @@ def process_diffusers(p: processing.StableDiffusionProcessing): image = output.images[i] noise_level = round(350 * p.denoising_strength) output_type='latent' if hasattr(shared.sd_refiner, 'vae') else 'np' - if 'Upscale' in shared.sd_refiner.__class__.__name__ or 'Flux in shared.sd_refiner.__class__.__name__': + if 'Upscale' in shared.sd_refiner.__class__.__name__ or 'Flux' in shared.sd_refiner.__class__.__name__: image = processing_vae.vae_decode(latents=image, model=shared.sd_model, full_quality=p.full_quality, output_type='pil', width=p.width, height=p.height) p.extra_generation_params['Noise level'] = noise_level output_type = 'np' diff --git a/modules/processing_vae.py b/modules/processing_vae.py index 3626fc5cd..cc2a9196c 100644 --- a/modules/processing_vae.py +++ b/modules/processing_vae.py @@ -124,6 +124,7 @@ def vae_decode(latents, model, output_type='np', full_quality=True, width=None, t0 = time.time() prev_job = shared.state.job shared.state.job = 'VAE' + decoded = None if not torch.is_tensor(latents): # already decoded return latents if latents.shape[0] == 0: @@ -134,24 +135,28 @@ def vae_decode(latents, model, output_type='np', full_quality=True, width=None, if not hasattr(model, 'vae'): shared.log.error('VAE not found in model') return [] + if hasattr(model, "_unpack_latents") and hasattr(model, "vae_scale_factor") and width is not None and height is not None: # FLUX latents = model._unpack_latents(latents, height, width, model.vae_scale_factor) # pylint: disable=protected-access if len(latents.shape) == 3: # lost a batch dim in hires latents = latents.unsqueeze(0) if latents.shape[0] == 4 and latents.shape[1] != 4: # likely animatediff latent latents = latents.permute(1, 0, 2, 3) - if any(s >= 512 for s in latents.shape): - imgs = latents.float().cpu().numpy() + + if any(s >= 512 for s in latents.shape): # not a latent, likely an image + decoded = latents.float().cpu().numpy() elif full_quality and hasattr(shared.sd_model, "vae"): decoded = full_vae_decode(latents=latents, model=shared.sd_model) else: decoded = taesd_vae_decode(latents=latents) + if hasattr(model, 'image_processor'): imgs = model.image_processor.postprocess(decoded, output_type=output_type) else: import diffusers - image_processor = diffusers.image_processor.VaeImageProcessor() - imgs = image_processor.postprocess(decoded, output_type=output_type) + model.image_processor = diffusers.image_processor.VaeImageProcessor() + imgs = model.image_processor.postprocess(decoded, output_type=output_type) + shared.state.job = prev_job if shared.cmd_opts.profile or debug: t1 = time.time()