mirror of
https://github.com/AUTOMATIC1111/stable-diffusion-webui.git
synced 2025-08-04 03:10:21 +00:00
get_crop_region_v2
This commit is contained in:
@@ -1611,19 +1611,23 @@ class StableDiffusionProcessingImg2Img(StableDiffusionProcessing):
|
||||
if self.inpaint_full_res:
|
||||
self.mask_for_overlay = image_mask
|
||||
mask = image_mask.convert('L')
|
||||
crop_region = masking.get_crop_region(mask, self.inpaint_full_res_padding)
|
||||
if crop_region[0] >= crop_region[2] and crop_region[1] >= crop_region[3]:
|
||||
crop_region = None
|
||||
image_mask = None
|
||||
self.mask_for_overlay = None
|
||||
else:
|
||||
crop_region = masking.get_crop_region_v2(mask, self.inpaint_full_res_padding)
|
||||
if crop_region:
|
||||
crop_region = masking.expand_crop_region(crop_region, self.width, self.height, mask.width, mask.height)
|
||||
x1, y1, x2, y2 = crop_region
|
||||
mask = mask.crop(crop_region)
|
||||
image_mask = images.resize_image(2, mask, self.width, self.height)
|
||||
self.inpaint_full_res = False
|
||||
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
|
||||
self.extra_generation_params["Inpaint area"] = "Only masked"
|
||||
self.extra_generation_params["Masked area padding"] = self.inpaint_full_res_padding
|
||||
else:
|
||||
crop_region = None
|
||||
image_mask = None
|
||||
self.mask_for_overlay = None
|
||||
massage = 'Unable to perform "Inpaint Only mask" because mask is blank, switch to img2img mode.'
|
||||
model_hijack.comments.append(massage)
|
||||
logging.info(massage)
|
||||
else:
|
||||
image_mask = images.resize_image(self.resize_mode, image_mask, self.width, self.height)
|
||||
np_mask = np.array(image_mask)
|
||||
|
Reference in New Issue
Block a user