Merge pull request #4911 from QualiaRain/fix/upscale-postprocess-fixes

Fix four small bugs in upscale and postprocess paths
This commit is contained in:
Vladimir Mandic
2026-06-12 10:40:12 +02:00
committed by GitHub
4 changed files with 9 additions and 9 deletions
+6 -7
View File
@@ -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})
+1
View File
@@ -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
+1 -1
View File
@@ -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: