aboutsummaryrefslogtreecommitdiff
path: root/modules/images.py
diff options
context:
space:
mode:
authorSj-Si <sjw.jetty@gmail.com>2024-01-11 16:37:35 -0500
committerSj-Si <sjw.jetty@gmail.com>2024-01-11 16:37:35 -0500
commit036500223de0a3caaa86360a8ad3ed301e4367b0 (patch)
treef05f0d5fc503d9c35d57bad077a5dab1dfd6569e /modules/images.py
parent0726a6e12e85a37d1e514f5603acf9f058c11783 (diff)
parentcb5b335acddd126d4f6c990982816c06beb0d6ae (diff)
Merge changes from dev
Diffstat (limited to 'modules/images.py')
-rw-r--r--modules/images.py14
1 files changed, 10 insertions, 4 deletions
diff --git a/modules/images.py b/modules/images.py
index daf4eebe..87a7bf22 100644
--- a/modules/images.py
+++ b/modules/images.py
@@ -61,12 +61,17 @@ def image_grid(imgs, batch_size=1, rows=None):
return grid
-Grid = namedtuple("Grid", ["tiles", "tile_w", "tile_h", "image_w", "image_h", "overlap"])
+class Grid(namedtuple("_Grid", ["tiles", "tile_w", "tile_h", "image_w", "image_h", "overlap"])):
+ @property
+ def tile_count(self) -> int:
+ """
+ The total number of tiles in the grid.
+ """
+ return sum(len(row[2]) for row in self.tiles)
-def split_grid(image, tile_w=512, tile_h=512, overlap=64):
- w = image.width
- h = image.height
+def split_grid(image: Image.Image, tile_w: int = 512, tile_h: int = 512, overlap: int = 64) -> Grid:
+ w, h = image.size
non_overlap_width = tile_w - overlap
non_overlap_height = tile_h - overlap
@@ -791,3 +796,4 @@ def flatten(img, bgcolor):
img = background
return img.convert('RGB')
+