lint fixes

This commit is contained in:
Vladimir Mandic
2024-09-09 11:30:15 -04:00
parent 7fdb5e68da
commit daa206ed73
6 changed files with 16 additions and 8 deletions
+2
View File
@@ -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,
+1
View File
@@ -13,6 +13,7 @@ exclude = [
"modules/todo",
"modules/unipc",
"modules/xadapter",
"modules/dcsolver",
"modules/intel/openvino",
"modules/intel/ipex",
"modules/segmoe",
+1 -1
View File
@@ -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')
+1 -1
View File
@@ -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
+2 -2
View File
@@ -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'
+9 -4
View File
@@ -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()