From 1225abc265b95339a8322a6fedca6df3aee9d554 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 11 Jun 2026 08:14:22 +0000 Subject: [PATCH 1/4] Fix Simple Upscale crash when upscaler name is not found A stale or renamed upscaler name fell through after the debug log and dereferenced None in upscale(), raising AttributeError. Return early like the standard upscale class does. https: //claude.ai/code/session_014QWKWgKvMevcuvfCnsYoT2 Co-Authored-By: Claude --- scripts/postprocessing_upscale.py | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/postprocessing_upscale.py b/scripts/postprocessing_upscale.py index 826a313ee..8f5144d6e 100644 --- a/scripts/postprocessing_upscale.py +++ b/scripts/postprocessing_upscale.py @@ -112,5 +112,6 @@ class ScriptPostprocessingUpscaleSimple(ScriptPostprocessingUpscale): upscaler1 = next(iter([x for x in shared.sd_upscalers if x.name == upscaler_name]), None) if upscaler1 is None: log.debug(f"Upscaler not found: {upscaler_name}") + return pp.image = self.upscale(pp.image, pp.info, upscaler1, 0, upscale_by, 0, 0, False) pp.info["Postprocess upscaler"] = upscaler1.name From 77f7fc61bd0076a6fc3c4204016c491d3b8b7105 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 11 Jun 2026 08:15:35 +0000 Subject: [PATCH 2/4] Fix UnboundLocalError when resize gets an invalid upscaler name The invalid-upscaler warning referenced selected_upscaler, which is only assigned when a matching upscaler was found, so an unknown name (stale infotext, removed upscaler) crashed the resize instead of falling back to plain resampling. https: //claude.ai/code/session_014QWKWgKvMevcuvfCnsYoT2 Co-Authored-By: Claude --- modules/image/resize.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/image/resize.py b/modules/image/resize.py index 22841e6e5..53a64b80a 100644 --- a/modules/image/resize.py +++ b/modules/image/resize.py @@ -51,7 +51,7 @@ def resize_image(resize_mode: int, im: Image.Image | torch.Tensor, width: int, h else: im = selected_upscaler.scaler.upscale(im, scale, selected_upscaler.name) else: - log.warning(f"Resize upscaler: invalid={upscaler_name} fallback={selected_upscaler.name}") + log.warning(f"Resize upscaler: invalid={upscaler_name} fallback=resample") log.debug(f"Resize upscaler: available={[u.name for u in shared.sd_upscalers]}") if isinstance(im, Image.Image) and (im.width != w or im.height != h): # probably downsample after upscaler created larger image im = sharpfin.resize(im, (w, h)) From 9c0ab938f29257ef51de7c859807f68c21e40d65 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 11 Jun 2026 08:14:46 +0000 Subject: [PATCH 3/4] Fix SD Upscale task_args image fallback never triggering hasattr() on the task_args dict checked for an attribute instead of a key, so it was always False and images passed via task_args were ignored. Use dict.get instead. https: //claude.ai/code/session_014QWKWgKvMevcuvfCnsYoT2 Co-Authored-By: Claude --- scripts/sd_upscale.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/sd_upscale.py b/scripts/sd_upscale.py index 2b1b87f81..0d19e5eb4 100644 --- a/scripts/sd_upscale.py +++ b/scripts/sd_upscale.py @@ -29,7 +29,7 @@ class SDUpscaleScript(scripts_manager.Script): init_img = None if hasattr(p, 'init_images') and p.init_images is not None: init_img = p.init_images[0] - elif hasattr(p.task_args, 'image') and p.task_args['image'] is not None: + elif p.task_args.get('image', None) is not None: init_img = p.task_args['image'][0] if init_img is None: From 92517f8a585fc607e9120afc7b4950090d7f9a66 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 11 Jun 2026 08:13:36 +0000 Subject: [PATCH 4/4] Fix Remove Background mask-only and merge-alpha options Both options inspected pp.image (the original input, normally RGB) instead of the background-removed RGBA result, so the checkboxes did nothing. merge_alpha also discarded the convert('RGB') return value. Operate on the rembg output and keep the converted image. https: //claude.ai/code/session_014QWKWgKvMevcuvfCnsYoT2 Co-Authored-By: Claude --- scripts/postprocessing_rembg.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/scripts/postprocessing_rembg.py b/scripts/postprocessing_rembg.py index 9e3bba6e4..41456aade 100644 --- a/scripts/postprocessing_rembg.py +++ b/scripts/postprocessing_rembg.py @@ -98,14 +98,13 @@ class ScriptPostprocessingRembg(scripts_postprocessing.ScriptPostprocessing): log.error(f'RemoveBackground: model={model} {e}') return pp - if mask_only and pp.image.mode == "RGBA": - _r, _g, _b, alpha = pp.image.split() + if mask_only and image.mode == "RGBA": + _r, _g, _b, alpha = image.split() image = alpha - if merge_alpha and pp.image.mode == "RGBA": - flattened = Image.new("RGBA", pp.image.size, "BLACK") - flattened.paste(pp.image, mask=pp.image) - flattened.convert("RGB") - image = flattened + if merge_alpha and image.mode == "RGBA": + flattened = Image.new("RGBA", image.size, "BLACK") + flattened.paste(image, mask=image) + image = flattened.convert("RGB") if isinstance(pp, Image.Image): pp = scripts_postprocessing.PostprocessedImage(image=image, info={**info, "Rembg": model})