Skip to content

Commit

Permalink
fix spiral, override prompt
Browse files Browse the repository at this point in the history
  • Loading branch information
ssube committed Jan 29, 2023
1 parent 6f1ffaa commit 20beff8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
4 changes: 3 additions & 1 deletion api/onnx_web/chain/upscale_outpaint.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,14 @@ def upscale_outpaint(
source_image: Image.Image,
*,
expand: Border,
prompt: str = None,
mask_image: Image.Image = None,
fill_color: str = 'white',
mask_filter: Callable = mask_filter_none,
noise_source: Callable = noise_source_histogram,
**kwargs,
) -> Image.Image:
prompt = prompt or params.prompt
logger.info('upscaling image by expanding borders: %s', expand)

if mask_image is None:
Expand Down Expand Up @@ -85,7 +87,7 @@ def outpaint(image: Image.Image, dims: Tuple[int, int, int]):
rng = np.random.RandomState(params.seed)

result = pipe(
params.prompt,
prompt,
generator=rng,
guidance_scale=params.cfg,
height=size.height,
Expand Down
10 changes: 5 additions & 5 deletions api/onnx_web/chain/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ def process_tile_spiral(
image = Image.new('RGB', (width * scale, height * scale))
image.paste(source, (0, 0, width, height))

center_x = (width / 2) - (tile / 2)
center_y = (height / 2) - (tile / 2)
center_x = (width // 2) - (tile // 2)
center_y = (height // 2) - (tile // 2)

# TODO: only valid for overlap = 0.5
if overlap == 0.5:
Expand All @@ -64,9 +64,9 @@ def process_tile_spiral(
(tile * overlap, 0),
(tile * overlap, tile * overlap),
(0, tile * overlap),
(tile * -overlap, tile * -overlap),
(tile * -overlap, 0),
(tile * -overlap, tile * overlap),
(tile * -overlap, 0),
(tile * -overlap, tile * -overlap),
]

# tile tuples is source, multiply by scale for dest
Expand All @@ -75,8 +75,8 @@ def process_tile_spiral(
left = center_x + int(left)
top = center_y + int(top)

logger.info('processing tile %s of %s', counter, len(tiles))
counter += 1
logger.info('processing tile %s of %s', counter, len(tiles))

# TODO: only valid for scale == 1, resize source for others
tile_image = image.crop((left, top, left + tile, top + tile))
Expand Down

0 comments on commit 20beff8

Please sign in to comment.