Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #148 expected rgb but got rgba #167

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion backend/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,12 @@ def f_img2img(req: Img2ImgRequest):

def apply_mask(img):
"""Mask inpaint using original mask, including alpha."""
r, g, b = img.split() # img2img/inpaint gives rgb image
# img2img/inpaint gives rgb image
r, g, b = img.split()[:3]

# (a1111 > settings > img2img > include masked composite) enabled will return rgba
# we can use the alpha channel instead of the mask or cut it off after rgb

a = ImageOps.invert(mask) if req.invert_mask else mask
return Image.merge("RGBA", (r, g, b, a))

Expand Down