add "Forbid too small crop region" option

This commit is contained in:
Andray 2024-10-29 00:49:13 +04:00
parent 9f5a98d576
commit 11971e81c8
3 changed files with 41 additions and 0 deletions

View file

@ -1639,6 +1639,8 @@ class StableDiffusionProcessingImg2Img(StableDiffusionProcessing):
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)
if shared.opts.forbid_too_small_crop_region:
crop_region = masking.expand_too_small_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)