Skip to content

Commit 849c993

Browse files
author
root
committed
Modify apply_overlay for inpainting
1 parent 2e2684f commit 849c993

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/diffusers/image_processor.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -659,13 +659,11 @@ def apply_overlay(
659659
overlay the inpaint output to the original image
660660
"""
661661

662-
width, height = image.width, image.height
663-
664-
init_image = self.resize(init_image, width=width, height=height)
665-
mask = self.resize(mask, width=width, height=height)
662+
width, height = init_image.width, init_image.height
666663

667664
init_image_masked = PIL.Image.new("RGBa", (width, height))
668665
init_image_masked.paste(init_image.convert("RGBA").convert("RGBa"), mask=ImageOps.invert(mask.convert("L")))
666+
669667
init_image_masked = init_image_masked.convert("RGBA")
670668

671669
if crop_coords is not None:
@@ -676,14 +674,15 @@ def apply_overlay(
676674
image = self.resize(image, height=h, width=w, resize_mode="crop")
677675
base_image.paste(image, (x, y))
678676
image = base_image.convert("RGB")
679-
680-
image = image.convert("RGBA")
677+
678+
image = image.convert("RGBA")
681679
image.alpha_composite(init_image_masked)
682680
image = image.convert("RGB")
683681

684682
return image
685683

686684

685+
687686
class VaeImageProcessorLDM3D(VaeImageProcessor):
688687
"""
689688
Image processor for VAE LDM3D.

0 commit comments

Comments
 (0)