From e7bf53c899b97e6771e026c21bd1cfcf225517ce Mon Sep 17 00:00:00 2001 From: chflame Date: Thu, 21 Mar 2024 09:57:09 +0800 Subject: [PATCH] CropByMask and V2 nodes is forced to size in multiples of 8 --- py/crop_by_mask.py | 3 +++ py/crop_by_mask_v2.py | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/py/crop_by_mask.py b/py/crop_by_mask.py index 4fa89fa..b1d01cb 100644 --- a/py/crop_by_mask.py +++ b/py/crop_by_mask.py @@ -65,6 +65,9 @@ class CropByMask: (x, y, width, height) = max_inscribed_rect(bluredmask) else: (x, y, width, height) = mask_area(_mask) + + width = num_round_to_multiple(width, 8) + height = num_round_to_multiple(height, 8) log(f"{NODE_NAME}: Box detected. x={x},y={y},width={width},height={height}") canvas_width, canvas_height = tensor2pil(torch.unsqueeze(image[0], 0)).convert('RGB').size x1 = x - left_reserve if x - left_reserve > 0 else 0 diff --git a/py/crop_by_mask_v2.py b/py/crop_by_mask_v2.py index d56a697..707a441 100644 --- a/py/crop_by_mask_v2.py +++ b/py/crop_by_mask_v2.py @@ -69,6 +69,10 @@ class CropByMaskV2: (x, y, width, height) = max_inscribed_rect(bluredmask) else: (x, y, width, height) = mask_area(_mask) + + width = num_round_to_multiple(width, 8) + height = num_round_to_multiple(height, 8) + log(f"{NODE_NAME}: Box detected. x={x},y={y},width={width},height={height}") canvas_width, canvas_height = tensor2pil(torch.unsqueeze(image[0], 0)).convert('RGB').size x1 = x - left_reserve if x - left_reserve > 0 else 0