diff options
author | AUTOMATIC1111 <16777216c@gmail.com> | 2024-01-02 04:05:05 +0000 |
---|---|---|
committer | AUTOMATIC1111 <16777216c@gmail.com> | 2024-01-02 04:05:05 +0000 |
commit | 80873b1538e6ca0c7ebe558f8ce4213b06fd8307 (patch) | |
tree | 65f3cc461f9b57fbf9bfffa3229387b34b697d8b | |
parent | 1341b2208185cd89b0019bda2df63b406ec0cb5e (diff) | |
download | stable-diffusion-webui-gfx803-80873b1538e6ca0c7ebe558f8ce4213b06fd8307.tar.gz stable-diffusion-webui-gfx803-80873b1538e6ca0c7ebe558f8ce4213b06fd8307.tar.bz2 stable-diffusion-webui-gfx803-80873b1538e6ca0c7ebe558f8ce4213b06fd8307.zip |
fix #14497
-rw-r--r-- | modules/img2img.py | 15 | ||||
-rw-r--r-- | modules/infotext_utils.py | 12 | ||||
-rw-r--r-- | modules/processing.py | 13 |
3 files changed, 25 insertions, 15 deletions
diff --git a/modules/img2img.py b/modules/img2img.py index 9e09c0a0..f81405df 100644 --- a/modules/img2img.py +++ b/modules/img2img.py @@ -222,21 +222,6 @@ def img2img(id_task: str, mode: int, prompt: str, negative_prompt: str, prompt_s if shared.opts.enable_console_prompts:
print(f"\nimg2img: {prompt}", file=shared.progress_print_out)
- if mask:
- p.extra_generation_params["Mask blur"] = mask_blur
-
- if inpainting_mask_invert is not None:
- p.extra_generation_params["Mask mode"] = inpainting_mask_invert
-
- if inpainting_fill is not None:
- p.extra_generation_params["Masked content"] = inpainting_fill
-
- if inpaint_full_res is not None:
- p.extra_generation_params["Inpaint area"] = inpaint_full_res
-
- if inpaint_full_res_padding is not None:
- p.extra_generation_params["Only masked padding, pixels"] = inpaint_full_res_padding
-
with closing(p):
if is_batch:
assert not shared.cmd_opts.hide_ui_dir_config, "Launched with --hide-ui-dir-config, batch img2img disabled"
diff --git a/modules/infotext_utils.py b/modules/infotext_utils.py index 26e9b949..e582ee47 100644 --- a/modules/infotext_utils.py +++ b/modules/infotext_utils.py @@ -312,6 +312,18 @@ Steps: 20, Sampler: Euler a, CFG scale: 7, Seed: 965400086, Size: 512x512, Model if "Hires negative prompt" not in res:
res["Hires negative prompt"] = ""
+ if "Mask mode" not in res:
+ res["Mask mode"] = "Inpaint masked"
+
+ if "Masked content" not in res:
+ res["Masked content"] = 'original'
+
+ if "Inpaint area" not in res:
+ res["Inpaint area"] = "Whole picture"
+
+ if "Masked area padding" not in res:
+ res["Masked area padding"] = 32
+
restore_old_hires_fix_params(res)
# Missing RNG means the default was set, which is GPU RNG
diff --git a/modules/processing.py b/modules/processing.py index 045c7d79..84e7b1b4 100644 --- a/modules/processing.py +++ b/modules/processing.py @@ -1530,6 +1530,7 @@ class StableDiffusionProcessingImg2Img(StableDiffusionProcessing): if self.inpainting_mask_invert:
image_mask = ImageOps.invert(image_mask)
+ self.extra_generation_params["Mask mode"] = "Inpaint not masked"
if self.mask_blur_x > 0:
np_mask = np.array(image_mask)
@@ -1543,6 +1544,9 @@ class StableDiffusionProcessingImg2Img(StableDiffusionProcessing): np_mask = cv2.GaussianBlur(np_mask, (1, kernel_size), self.mask_blur_y)
image_mask = Image.fromarray(np_mask)
+ if self.mask_blur_x > 0 or self.mask_blur_y > 0:
+ self.extra_generation_params["Mask blur"] = self.mask_blur
+
if self.inpaint_full_res:
self.mask_for_overlay = image_mask
mask = image_mask.convert('L')
@@ -1553,6 +1557,9 @@ class StableDiffusionProcessingImg2Img(StableDiffusionProcessing): mask = mask.crop(crop_region)
image_mask = images.resize_image(2, mask, self.width, self.height)
self.paste_to = (x1, y1, x2-x1, y2-y1)
+
+ self.extra_generation_params["Inpaint area"] = "Only masked"
+ self.extra_generation_params["Masked area padding"] = self.inpaint_full_res_padding
else:
image_mask = images.resize_image(self.resize_mode, image_mask, self.width, self.height)
np_mask = np.array(image_mask)
@@ -1594,6 +1601,9 @@ class StableDiffusionProcessingImg2Img(StableDiffusionProcessing): if self.inpainting_fill != 1:
image = masking.fill(image, latent_mask)
+ if self.inpainting_fill == 0:
+ self.extra_generation_params["Masked content"] = 'fill'
+
if add_color_corrections:
self.color_corrections.append(setup_color_correction(image))
@@ -1643,8 +1653,11 @@ class StableDiffusionProcessingImg2Img(StableDiffusionProcessing): # this needs to be fixed to be done in sample() using actual seeds for batches
if self.inpainting_fill == 2:
self.init_latent = self.init_latent * self.mask + create_random_tensors(self.init_latent.shape[1:], all_seeds[0:self.init_latent.shape[0]]) * self.nmask
+ self.extra_generation_params["Masked content"] = 'latent noise'
+
elif self.inpainting_fill == 3:
self.init_latent = self.init_latent * self.mask
+ self.extra_generation_params["Masked content"] = 'latent nothing'
self.image_conditioning = self.img2img_image_conditioning(image * 2 - 1, self.init_latent, image_mask, self.mask_round)
|