From 2ef5f5c4d8de1257b70b2780d15f4bf9fe5b995c Mon Sep 17 00:00:00 2001 From: apsntian Date: Fri, 19 Apr 2024 16:13:05 +0900 Subject: [PATCH] fix : minor bug fix in mask bound --- modules/image_tool.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/modules/image_tool.py b/modules/image_tool.py index 40f6520..c3f4f00 100644 --- a/modules/image_tool.py +++ b/modules/image_tool.py @@ -530,17 +530,16 @@ class CalcMaskBound: ori_height = max_row - min_row desired_height = max(ori_width, ori_height) - + + if desired_height > mask.shape[1]: + desired_height = mask.shape[1] + desired_width = int(desired_height * ratio) - shrink_ratio_w = ori_width/desired_width - shrink_ratio_h = ori_height/desired_height + if desired_width > mask.shape[2]: + desired_width = mask.shape[2] + desired_height = desired_width / ratio - shrink_ratio = max(shrink_ratio_w, shrink_ratio_h) - - desired_width *= shrink_ratio - desired_height *= shrink_ratio - optional_padding_col = int((desired_width - ori_width) / 2) optional_padding_row = int((desired_height - ori_height)/2)