fix: MakeTileSEGS - invalid calculation

This commit is contained in:
Dr.Lt.Data
2024-01-07 15:20:44 +09:00
parent c6a5a0f98a
commit 3c25e6f52e
2 changed files with 10 additions and 5 deletions
+1 -1
View File
@@ -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
+9 -4
View File
@@ -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)