Skip to content

Commit

Permalink
fix(api): keep aspect ratio of mask for non-square sources (#373)
Browse files Browse the repository at this point in the history
  • Loading branch information
ssube committed May 3, 2023
1 parent 98386cb commit c8bc175
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions api/onnx_web/chain/upscale_outpaint.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import numpy as np
import torch
from PIL import Image, ImageDraw
from PIL import Image, ImageDraw, ImageOps

from ..diffusers.load import load_pipeline
from ..diffusers.utils import get_latents_from_seed, get_tile_latents
Expand Down Expand Up @@ -58,7 +58,9 @@ def upscale_outpaint(
noise_source=noise_source,
mask_filter=mask_filter,
)
stage_mask = stage_mask.resize(source.size)
stage_mask = ImageOps.contain(stage_mask, source.size)
stage_mask = ImageOps.pad(stage_mask, source.size, centering=(0, 0))

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

draw_mask = ImageDraw.Draw(stage_mask)
Expand Down

0 comments on commit c8bc175

Please sign in to comment.