Skip to content

Commit

Permalink
hotfix xy coordinate crop if input file too small
Browse files Browse the repository at this point in the history
  • Loading branch information
MaraScott committed Jun 20, 2024
1 parent eccf763 commit c26c89c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
8 changes: 4 additions & 4 deletions py/inc/lib/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,6 @@ def get_tiled_grid_specs(self, image, tile_size, rows_qty = 3, cols_qty = 3, siz
tile_height = height
tile_width_units_qty = math.ceil(tile_width / size_unit)
tile_height_units_qty = math.ceil(tile_height / size_unit)
new_width = tile_size * cols_qty
new_height = tile_size * rows_qty
last_tile_width_diff = new_width - image.shape[2]
last_tile_height_diff = new_height - image.shape[1]
tile_order_rows = MS_Array.reorder_edges_to_center(list(range(rows_qty)))
tile_order_cols = MS_Array.reorder_edges_to_center(list(range(cols_qty)))

Expand All @@ -156,6 +152,8 @@ def get_tiled_grid_specs(self, image, tile_size, rows_qty = 3, cols_qty = 3, siz
x = image.shape[2] - _tile_width
else:
x = x_tile_coordinate - (1 * feather_size)
if x + _tile_width > image.shape[2]:
x = x - ((x + _tile_width) - image.shape[2])

# if first or last height tile
if row_index == 0:
Expand All @@ -164,6 +162,8 @@ def get_tiled_grid_specs(self, image, tile_size, rows_qty = 3, cols_qty = 3, siz
y = image.shape[1] - _tile_height
else:
y = y_tile_coordinate - (1 * feather_size)
if y + _tile_height > image.shape[1]:
y = y - ((y + _tile_height) - image.shape[1])

tiles.append([
row_index,
Expand Down
3 changes: 3 additions & 0 deletions py/nodes/UpscalerRefiner/McBoaty_v3.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,10 @@ def upscale_refine(self, image, iteration):

# grid_specs = MS_Image().get_dynamic_grid_specs(upscaled_image.shape[2], upscaled_image.shape[1], rows_qty, cols_qty, feather_mask)[0]
grid_specs = MS_Image().get_tiled_grid_specs(upscaled_image, self.KSAMPLER.tile_size, rows_qty, cols_qty, feather_mask)[0]
log(grid_specs)
grid_images = MS_Image().get_grid_images(upscaled_image, grid_specs)
for grid_image in grid_images:
log(grid_image.shape)

grid_prompts = ["No tile prompting"]
grid_latents = []
Expand Down

0 comments on commit c26c89c

Please sign in to comment.