diff options
author | AUTOMATIC1111 <16777216c@gmail.com> | 2024-01-01 16:39:51 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-01 16:39:51 +0300 |
commit | dfd64382211317cc46ad337c373492bfc420fa18 (patch) | |
tree | 3b1b2f5f3648da07430f54d1c155ce379a6fa3f7 /modules/images.py | |
parent | 3d15e58b0a30f2ef1e731f9e429f4d3cf1c259c5 (diff) | |
parent | 0ce67cb61806cf43f4d726d4705a4f6fdc2540e6 (diff) |
Merge branch 'dev' into feat/interrupted-end
Diffstat (limited to 'modules/images.py')
-rw-r--r-- | modules/images.py | 14 |
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')
+
|