mirror of
https://github.com/vladmandic/automatic
synced 2026-09-19 01:04:32 +02:00
Merge pull request #4911 from QualiaRain/fix/upscale-postprocess-fixes
Fix four small bugs in upscale and postprocess paths
This commit is contained in:
@@ -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})
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user