aboutsummaryrefslogtreecommitdiff
path: root/modules/images.py
diff options
context:
space:
mode:
authorAUTOMATIC1111 <16777216c@gmail.com>2024-01-01 17:01:06 +0300
committerGitHub <noreply@github.com>2024-01-01 17:01:06 +0300
commit7ba02e0b7cfc85d5d237eba71ab4d66564857d55 (patch)
treeb317227a0e63c42aa8c4b06147761dfd37ae24fc /modules/images.py
parentbe31e7e71a08dc27543d31aa6e6532463ccbf20f (diff)
parent15156cde18844f459ba101b1356d162aa7f39c47 (diff)
Merge branch 'dev' into finer-settings-freezing-control
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')
+