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

Image transparency can be used as mask for inpainting #921

Merged
merged 1 commit into from
Sep 9, 2022
Merged
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
3 changes: 2 additions & 1 deletion scripts/webui.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@
from einops import rearrange, repeat
from itertools import islice
from omegaconf import OmegaConf
from PIL import Image, ImageFont, ImageDraw, ImageFilter, ImageOps
from io import BytesIO
import base64
import re
Expand Down Expand Up @@ -1364,10 +1363,12 @@ def img2img(prompt: str, image_editor_mode: str, mask_mode: str, mask_blur_stren

if image_editor_mode == 'Mask':
init_img = init_info_mask["image"]
init_img_transparency = ImageOps.invert(init_img.split()[-1]).convert('L').point(lambda x: 255 if x > 0 else 0, mode='1')
init_img = init_img.convert("RGB")
init_img = resize_image(resize_mode, init_img, width, height)
init_img = init_img.convert("RGB")
init_mask = init_info_mask["mask"]
init_mask = ImageChops.lighter(init_img_transparency, init_mask.convert('L')).convert('RGBA')
init_mask = init_mask.convert("RGB")
init_mask = resize_image(resize_mode, init_mask, width, height)
init_mask = init_mask.convert("RGB")
Expand Down