Skip to content

Commit

Permalink
fix(api): tile mask during outpaint stage
Browse files Browse the repository at this point in the history
  • Loading branch information
ssube committed Jan 28, 2023
1 parent d89437b commit d6193a9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
9 changes: 6 additions & 3 deletions api/onnx_web/chain/upscale_outpaint.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
OnnxStableDiffusionInpaintPipeline,
)
from PIL import Image, ImageDraw
from typing import Callable
from typing import Callable, Tuple

from ..diffusion import (
get_latents_from_seed,
Expand Down Expand Up @@ -64,8 +64,11 @@ def upscale_outpaint(
mask_image.save(base_join(ctx.output_path, 'last-mask.png'))
noise_image.save(base_join(ctx.output_path, 'last-noise.png'))

def outpaint(image: Image.Image):
def outpaint(image: Image.Image, dims: Tuple[int, int, int]):
top, left, tile = dims

size = Size(*image.size)
mask = mask_image.crop((left, top, left + tile, top + tile))
pipe = load_pipeline(OnnxStableDiffusionInpaintPipeline,
params.model, params.provider, params.scheduler)

Expand All @@ -79,7 +82,7 @@ def outpaint(image: Image.Image):
height=size.height,
image=image,
latents=latents,
mask_image=mask_image,
mask_image=mask,
negative_prompt=params.negative_prompt,
num_inference_steps=params.steps,
width=size.width,
Expand Down
2 changes: 1 addition & 1 deletion api/onnx_web/chain/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def process_tiles(
tile_image = source.crop((left, top, left + tile, top + tile))

for filter in filters:
tile_image = filter(tile_image)
tile_image = filter(tile_image, (left, top, tile))

image.paste(tile_image, (left * scale, top * scale))

Expand Down

0 comments on commit d6193a9

Please sign in to comment.