1
0
Fork 0

improve logging, provide rng within filter

This commit is contained in:
Sean Sube 2023-01-26 22:58:36 -06:00
parent 936ebba510
commit 670bc1ced5
2 changed files with 15 additions and 9 deletions

View File

@ -7,7 +7,6 @@ import numpy as np
from .utils import (
Border,
Point,
Size,
)
@ -197,16 +196,23 @@ def process_tiles(
width, height = source.size
image = Image.new('RGB', (width * scale, height * scale))
for x in range(width // tile):
for y in range(height // tile):
tiles_x = width // tile
tiles_y = height // tile
total = tiles_x * tiles_y
rng = random.RandomState(0)
for y in range(tiles_y):
for x in range(tiles_x):
idx = (y * tiles_x) + x
left = x * tile
top = y * tile
print('processing tile', x, y, left, top)
tile = source.crop((left, top, left + tile, top + tile))
print('processing tile %s of %s, %s.%s', idx, total, x, y)
tile_image = source.crop((left, top, left + tile, top + tile))
for filter in filters:
tile = filter(tile)
tile_image = filter(tile_image)
image.paste(tile, (left * scale, top * scale))
image.paste(tile_image, (left * scale, top * scale))
return image

View File

@ -147,8 +147,8 @@ def upscale_stable_diffusion(ctx: ServerContext, params: UpscaleParams, image: I
# result = pipeline('', image=image)
pipeline = StableDiffusionUpscalePipeline.from_pretrained('stabilityai/stable-diffusion-x4-upscaling')
upscale = lambda i: pipeline('an astronaut eating a hamburger', image=i).images[0]
result = process_tiles(image, 64, 4, [upscale])
upscale = lambda i: pipeline('an astronaut eating a hamburger', image=i, rng=np.random.RandomState(0)).images[0]
result = process_tiles(image, 128, 4, [upscale])
return result