From 2cb3c2da3f04f4a963d782173383de3c66b57954 Mon Sep 17 00:00:00 2001 From: Andray Date: Mon, 29 Jul 2024 03:28:47 +0400 Subject: [PATCH] fix x2 >= image_width and y2 >= image_height --- modules/masking.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/modules/masking.py b/modules/masking.py index 69ed467a6..40d7f811e 100644 --- a/modules/masking.py +++ b/modules/masking.py @@ -89,6 +89,10 @@ def expand_too_small_crop_region(crop_region, processing_width, processing_heigh diff_w_r = diff_w - diff_w_l x1 -= diff_w_l x2 += diff_w_r + if x2 >= image_width: + diff = x2 - image_width + x2 -= diff + x1 -= diff if x1 < 0: x2 -= x1 x1 -= x1 @@ -102,6 +106,10 @@ def expand_too_small_crop_region(crop_region, processing_width, processing_heigh diff_h_d = diff_h - diff_h_u y1 -= diff_h_u y2 += diff_h_d + if y2 >= image_height: + diff = y2 - image_height + y2 -= diff + y1 -= diff if y1 < 0: y2 -= y1 y1 -= y1