diff options
author | AUTOMATIC1111 <16777216c@gmail.com> | 2023-12-30 18:06:31 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-30 18:06:31 +0300 |
commit | cd12c0e15c4dc1545cac18ba902ca17488812953 (patch) | |
tree | 9c70df74d3e426341d1189b1ceadbd8afffeae91 /modules/images.py | |
parent | 05230c02606080527b65ace9eacb6fb835239877 (diff) | |
parent | 4ad0c0c0a805da4bac03cff86ea17c25a1291546 (diff) |
Merge pull request #14425 from akx/spandrel
Use Spandrel for upscaling and face restoration architectures
Diffstat (limited to 'modules/images.py')
-rw-r--r-- | modules/images.py | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/modules/images.py b/modules/images.py index 16f9ae7c..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
|