aboutsummaryrefslogtreecommitdiff
path: root/modules/img2img.py
diff options
context:
space:
mode:
authorRobin Fernandes <robin@soal.org>2022-09-08 15:59:42 +1000
committerGitHub <noreply@github.com>2022-09-08 15:59:42 +1000
commit21a375e6b2a1738b6e9b58ca40e92487809e6654 (patch)
tree2fa1251b9dbe014e8c83c6c8a066864e4f5d3fde /modules/img2img.py
parentbc12eddb408c3503717b234e1a8bb635049f4a91 (diff)
parent0959fa2d027e7a093adb3cfab9be2343ec7348e2 (diff)
Merge branch 'master' into img2img2-color-correction
Diffstat (limited to 'modules/img2img.py')
-rw-r--r--modules/img2img.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/modules/img2img.py b/modules/img2img.py
index 52971785..c2392305 100644
--- a/modules/img2img.py
+++ b/modules/img2img.py
@@ -1,7 +1,7 @@
import math
import cv2
import numpy as np
-from PIL import Image
+from PIL import Image, ImageOps, ImageChops
from modules.processing import Processed, StableDiffusionProcessingImg2Img, process_images
from modules.shared import opts, state
@@ -18,7 +18,9 @@ def img2img(prompt: str, init_img, init_img_with_mask, steps: int, sampler_index
if is_inpaint:
image = init_img_with_mask['image']
- mask = init_img_with_mask['mask']
+ alpha_mask = ImageOps.invert(image.split()[-1]).convert('L').point(lambda x: 255 if x > 0 else 0, mode='1')
+ mask = ImageChops.lighter(alpha_mask, init_img_with_mask['mask'].convert('L')).convert('RGBA')
+ image = image.convert('RGB')
else:
image = init_img
mask = None