mirror of
https://github.com/AUTOMATIC1111/stable-diffusion-webui.git
synced 2026-01-25 05:41:03 -08:00
Expose inpainting mask and composite
For inpainting, this exposes the mask and masked composite and gives the user the ability to display these in the web UI, save to disk, or both.
This commit is contained in:
parent
a9fed7c364
commit
caf84e8233
2 changed files with 20 additions and 0 deletions
|
|
@ -689,6 +689,22 @@ def process_images_inner(p: StableDiffusionProcessing) -> Processed:
|
|||
image.info["parameters"] = text
|
||||
output_images.append(image)
|
||||
|
||||
if hasattr(p, 'mask_for_overlay') and p.mask_for_overlay:
|
||||
image_mask = p.mask_for_overlay.convert('RGB')
|
||||
image_mask_composite = Image.composite(image.convert('RGBA').convert('RGBa'), Image.new('RGBa', image.size), p.mask_for_overlay.convert('L')).convert('RGBA')
|
||||
|
||||
if opts.save_mask:
|
||||
images.save_image(image_mask, p.outpath_samples, "", seeds[i], prompts[i], opts.samples_format, info=infotext(n, i), p=p, suffix="-mask")
|
||||
|
||||
if opts.save_mask_composite:
|
||||
images.save_image(image_mask_composite, p.outpath_samples, "", seeds[i], prompts[i], opts.samples_format, info=infotext(n, i), p=p, suffix="-mask-composite")
|
||||
|
||||
if opts.return_mask:
|
||||
output_images.append(image_mask)
|
||||
|
||||
if opts.return_mask_composite:
|
||||
output_images.append(image_mask_composite)
|
||||
|
||||
del x_samples_ddim
|
||||
|
||||
devices.torch_gc()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue