From 7350c712598b748c3cedc2a224887bd839a27d76 Mon Sep 17 00:00:00 2001 From: AUTOMATIC <16777216c@gmail.com> Date: Sun, 4 Sep 2022 01:29:43 +0300 Subject: added poor man's inpainting script --- modules/images.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'modules/images.py') diff --git a/modules/images.py b/modules/images.py index b05276c3..4b9667d2 100644 --- a/modules/images.py +++ b/modules/images.py @@ -39,23 +39,26 @@ def split_grid(image, tile_w=512, tile_h=512, overlap=64): w = image.width h = image.height - now = tile_w - overlap # non-overlap width - noh = tile_h - overlap + non_overlap_width = tile_w - overlap + non_overlap_height = tile_h - overlap - cols = math.ceil((w - overlap) / now) - rows = math.ceil((h - overlap) / noh) + cols = math.ceil((w - overlap) / non_overlap_width) + rows = math.ceil((h - overlap) / non_overlap_height) + + dx = (w - tile_w) // (cols-1) if cols > 1 else 0 + dy = (h - tile_h) // (rows-1) if rows > 1 else 0 grid = Grid([], tile_w, tile_h, w, h, overlap) for row in range(rows): row_images = [] - y = row * noh + y = row * dy if y + tile_h >= h: y = h - tile_h for col in range(cols): - x = col * now + x = col * dx if x+tile_w >= w: x = w - tile_w -- cgit v1.2.1