aboutsummaryrefslogtreecommitdiff
path: root/modules/processing.py
diff options
context:
space:
mode:
authorCodeHatchling <steve@codehatch.com>2023-11-28 15:05:01 -0700
committerCodeHatchling <steve@codehatch.com>2023-11-28 15:05:01 -0700
commitdec791d35ddcd02ca33563d3d0355e05e45de8ad (patch)
treea318aa94381148b30182ea2960653e8980e79ade /modules/processing.py
parent4afaaf8a020c1df457bcf7250cb1c7f609699fa7 (diff)
Removed code which forces the inpainting mask to be 0 or 1. Now fractional values (e.g. 0.5) are accepted.
Diffstat (limited to 'modules/processing.py')
-rw-r--r--modules/processing.py6
1 files changed, 1 insertions, 5 deletions
diff --git a/modules/processing.py b/modules/processing.py
index e124e7f0..317458f5 100644
--- a/modules/processing.py
+++ b/modules/processing.py
@@ -83,7 +83,7 @@ def apply_overlay(image, paste_loc, index, overlays):
def create_binary_mask(image):
if image.mode == 'RGBA' and image.getextrema()[-1] != (255, 255):
- image = image.split()[-1].convert("L").point(lambda x: 255 if x > 128 else 0)
+ image = image.split()[-1].convert("L")
else:
image = image.convert('L')
return image
@@ -319,9 +319,6 @@ class StableDiffusionProcessing:
conditioning_mask = np.array(image_mask.convert("L"))
conditioning_mask = conditioning_mask.astype(np.float32) / 255.0
conditioning_mask = torch.from_numpy(conditioning_mask[None, None])
-
- # Inpainting model uses a discretized mask as input, so we round to either 1.0 or 0.0
- conditioning_mask = torch.round(conditioning_mask)
else:
conditioning_mask = source_image.new_ones(1, 1, *source_image.shape[-2:])
@@ -1504,7 +1501,6 @@ class StableDiffusionProcessingImg2Img(StableDiffusionProcessing):
latmask = init_mask.convert('RGB').resize((self.init_latent.shape[3], self.init_latent.shape[2]))
latmask = np.moveaxis(np.array(latmask, dtype=np.float32), 2, 0) / 255
latmask = latmask[0]
- latmask = np.around(latmask)
latmask = np.tile(latmask[None], (4, 1, 1))
self.mask = torch.asarray(1.0 - latmask).to(shared.device).type(self.sd_model.dtype)