From 3c25e6f52ebfd3bc55c88cfab4ab96e2f720e2ca Mon Sep 17 00:00:00 2001 From: "Dr.Lt.Data" Date: Sun, 7 Jan 2024 15:20:24 +0900 Subject: [PATCH] fix: MakeTileSEGS - invalid calculation --- modules/impact/config.py | 2 +- modules/impact/segs_nodes.py | 13 +++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/modules/impact/config.py b/modules/impact/config.py index 75503d8..aefb2be 100644 --- a/modules/impact/config.py +++ b/modules/impact/config.py @@ -2,7 +2,7 @@ import configparser import os -version_code = [4, 60] +version_code = [4, 60, 1] version = f"V{version_code[0]}.{version_code[1]}" + (f'.{version_code[2]}' if len(version_code) > 2 else '') dependency_version = 20 diff --git a/modules/impact/segs_nodes.py b/modules/impact/segs_nodes.py index 97c2b1a..6c9234c 100644 --- a/modules/impact/segs_nodes.py +++ b/modules/impact/segs_nodes.py @@ -1348,6 +1348,11 @@ class MakeTileSEGS: # calculate tile factors _, h, w, _ = images.size() + if bbox_size > h or bbox_size > w: + new_bbox_size = min(bbox_size, min(w, h)) + print(f"[MaskTileSEGS] bbox_size is greater than resolution (value changed: {bbox_size} => {new_bbox_size}") + bbox_size = new_bbox_size + n_horizontal = int(w / (bbox_size - min_overlap)) n_vertical = int(h / (bbox_size - min_overlap)) @@ -1394,14 +1399,14 @@ class MakeTileSEGS: if x+bbox_size < w-1: x2 = x+bbox_size else: - x2 = w-1 - x1 = w-1-bbox_size + x2 = w + x1 = w-bbox_size if y+bbox_size < h-1: y2 = y+bbox_size else: - y2 = h-1 - y1 = h-1-bbox_size + y2 = h + y1 = h-bbox_size bbox = x1, y1, x2, y2 crop_region = make_crop_region(w, h, bbox, crop_factor)