feat:compatible with inconsistent/empty mask

Signed-off-by: storyicon <storyicon@foxmail.com>
This commit is contained in:
storyicon
2024-04-18 11:59:25 +00:00
parent 0980fdfe8c
commit 71314e47b1
2 changed files with 15 additions and 12 deletions

View File

@@ -9,8 +9,8 @@ def get_crop_region(mask, pad=0):
if box:
x1, y1, x2, y2 = box
else: # when no box is found
x1 = y1 = 0
x2, y2 = mask_img.size
x1, y1 = mask_img.size
x2 = y2 = 0
return max(x1 - pad, 0), max(y1 - pad, 0), min(x2 + pad, mask_img.size[0]), min(y2 + pad, mask_img.size[1])