Skip to content

Commit

Permalink
fix(api): match mask and image size before adding noise (#373)
Browse files Browse the repository at this point in the history
  • Loading branch information
ssube committed May 4, 2023
1 parent d66bf9e commit 23aaf65
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions api/onnx_web/chain/upscale_outpaint.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ def upscale_outpaint(
# if no mask was provided, keep the full source image
stage_mask = Image.new("RGB", source.size, "black")

# masks start as 512x512, resize to cover the source, then trim the extra
mask_max = max(source.width, source.height)
stage_mask = ImageOps.contain(stage_mask, (mask_max, mask_max))
stage_mask = stage_mask.crop((0, 0, source.width, source.height))

source, stage_mask, noise, full_size = expand_image(
source,
stage_mask,
Expand All @@ -59,11 +64,6 @@ def upscale_outpaint(
mask_filter=mask_filter,
)

# masks start as 512x512, resize to cover the source, then trim the extra
mask_max = max(source.width, source.height)
stage_mask = ImageOps.contain(stage_mask, (mask_max, mask_max))
stage_mask = stage_mask.crop((0, 0, source.width, source.height))

full_latents = get_latents_from_seed(params.seed, Size(*full_size))

draw_mask = ImageDraw.Draw(stage_mask)
Expand Down

0 comments on commit 23aaf65

Please sign in to comment.