diff options
author | Aarni Koskela <akx@iki.fi> | 2023-12-27 09:01:45 +0000 |
---|---|---|
committer | Aarni Koskela <akx@iki.fi> | 2023-12-30 14:24:01 +0000 |
commit | 12c6f37f8e4b1d1d643c9d8d5dfc763c3203c728 (patch) | |
tree | 10a6cf0d9cc5841458621d264d6acd7c6d3585f8 /modules/images.py | |
parent | 7aa27b000a3087dcb5cc7254600064bf70cacd3e (diff) | |
download | stable-diffusion-webui-gfx803-12c6f37f8e4b1d1d643c9d8d5dfc763c3203c728.tar.gz stable-diffusion-webui-gfx803-12c6f37f8e4b1d1d643c9d8d5dfc763c3203c728.tar.bz2 stable-diffusion-webui-gfx803-12c6f37f8e4b1d1d643c9d8d5dfc763c3203c728.zip |
Add tile_count property to Grid
Diffstat (limited to 'modules/images.py')
-rw-r--r-- | modules/images.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/modules/images.py b/modules/images.py index d30e8865..87a7bf22 100644 --- a/modules/images.py +++ b/modules/images.py @@ -61,7 +61,13 @@ 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: Image.Image, tile_w: int = 512, tile_h: int = 512, overlap: int = 64) -> Grid:
|