Skip to content

Commit

Permalink
fix(api): calculate outpaint overlap factor before adding margins
Browse files Browse the repository at this point in the history
  • Loading branch information
ssube committed Feb 7, 2023
1 parent a9f4e19 commit b6fd288
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions api/onnx_web/chain/upscale_outpaint.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ def upscale_outpaint(
prompt = prompt or params.prompt
logger.info("upscaling image by expanding borders: %s", border)

margin_x = float(max(border.left, border.right))
margin_y = float(max(border.top, border.bottom))
overlap = min(margin_x / source_image.width, margin_y / source_image.height)

if mask_image is None:
# if no mask was provided, keep the full source image
mask_image = Image.new("RGB", source_image.size, "black")
Expand Down Expand Up @@ -108,10 +112,6 @@ def outpaint(image: Image.Image, dims: Tuple[int, int, int]):
draw_mask.rectangle((left, top, left + tile, top + tile), fill="black")
return result.images[0]

margin_x = float(max(border.left, border.right))
margin_y = float(max(border.top, border.bottom))
overlap = min(margin_x / source_image.width, margin_y / source_image.height)

if overlap == 0:
logger.debug("outpainting with 0 margin, using grid tiling")
output = process_tile_grid(source_image, SizeChart.auto, 1, [outpaint])
Expand Down

0 comments on commit b6fd288

Please sign in to comment.