add threshold; remove integer_only_masked

This commit is contained in:
Andray 2024-10-29 00:34:46 +04:00
parent 0d7a17add5
commit c21be9601e
3 changed files with 12 additions and 45 deletions

View file

@ -65,11 +65,18 @@ def apply_color_correction(correction, original_image):
def uncrop(image, dest_size, paste_loc):
x, y, w, h = paste_loc
base_image = Image.new('RGBA', dest_size)
factor_x = w // image.size[0]
factor_y = h // image.size[1]
if image.width > shared.opts.img2img_inpaint_correct_paste_xy_side_length_threshold:
paste_x = max(x - w // image.width, 0)
else:
paste_x = x
if image.height > shared.opts.img2img_inpaint_correct_paste_xy_side_length_threshold:
paste_y = max(y - h // image.height, 0)
else:
paste_y = y
image = images.resize_image(1, image, w, h)
paste_x = max(x - factor_x, 0)
paste_y = max(y - factor_y, 0)
base_image.paste(image, (paste_x, paste_y))
image = base_image
@ -1643,8 +1650,6 @@ 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.integer_only_masked:
crop_region = masking.fix_crop_region_integer_scale(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)