mirror of
https://github.com/vladmandic/automatic
synced 2026-09-18 16:54:33 +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:
@@ -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))
|
||||
|
||||
@@ -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