Skip to content

Commit

Permalink
fix(api): do not downscale source images for panorama pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
ssube committed Apr 28, 2023
1 parent 980cba1 commit d9f7971
Showing 1 changed file with 19 additions and 14 deletions.
33 changes: 19 additions & 14 deletions api/onnx_web/server/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,10 +188,11 @@ def img2img(server: ServerContext, pool: DevicePoolExecutor):
server, "img2img", params, size, extras=[strength], count=output_count
)

job_name = output[0]
logger.info("img2img job queued for: %s", job_name)
if params.get_valid_pipeline("img2img") != "panorama":
logger.info("resizing input image for limited pipeline, use panorama pipeline for full-size")
source = valid_image(source, min_dims=size, max_dims=size)

source = valid_image(source, min_dims=size, max_dims=size)
job_name = output[0]
pool.submit(
job_name,
run_img2img_pipeline,
Expand All @@ -206,6 +207,8 @@ def img2img(server: ServerContext, pool: DevicePoolExecutor):
source_filter=source_filter,
)

logger.info("img2img job queued for: %s", job_name)

return jsonify(json_params(output, params, size, upscale=upscale, highres=highres))


Expand All @@ -215,9 +218,8 @@ def txt2img(server: ServerContext, pool: DevicePoolExecutor):
highres = highres_from_request()

output = make_output_name(server, "txt2img", params, size)
job_name = output[0]
logger.info("txt2img job queued for: %s", job_name)

job_name = output[0]
pool.submit(
job_name,
run_txt2img_pipeline,
Expand All @@ -230,6 +232,8 @@ def txt2img(server: ServerContext, pool: DevicePoolExecutor):
needs_device=device,
)

logger.info("txt2img job queued for: %s", job_name)

return jsonify(json_params(output, params, size, upscale=upscale, highres=highres))


Expand Down Expand Up @@ -273,11 +277,8 @@ def inpaint(server: ServerContext, pool: DevicePoolExecutor):
tile_order,
],
)
job_name = output[0]
logger.info("inpaint job queued for: %s", job_name)

source = valid_image(source, min_dims=size, max_dims=size)
mask = valid_image(mask, min_dims=size, max_dims=size)
job_name = output[0]
pool.submit(
job_name,
run_inpaint_pipeline,
Expand All @@ -297,6 +298,8 @@ def inpaint(server: ServerContext, pool: DevicePoolExecutor):
needs_device=device,
)

logger.info("inpaint job queued for: %s", job_name)

return jsonify(
json_params(
output, params, size, upscale=upscale, border=expand, highres=highres
Expand All @@ -316,10 +319,11 @@ def upscale(server: ServerContext, pool: DevicePoolExecutor):
highres = highres_from_request()

output = make_output_name(server, "upscale", params, size)
job_name = output[0]
logger.info("upscale job queued for: %s", job_name)

logger.info("resizing source image for limited pipeline")
source = valid_image(source, min_dims=size, max_dims=size)

job_name = output[0]
pool.submit(
job_name,
run_upscale_pipeline,
Expand All @@ -333,6 +337,8 @@ def upscale(server: ServerContext, pool: DevicePoolExecutor):
needs_device=device,
)

logger.info("upscale job queued for: %s", job_name)

return jsonify(json_params(output, params, size, upscale=upscale, highres=highres))


Expand Down Expand Up @@ -429,7 +435,6 @@ def blend(server: ServerContext, pool: DevicePoolExecutor):
return error_reply("mask image is required")

mask = Image.open(BytesIO(mask_file.read())).convert("RGBA")
mask = valid_image(mask)

max_sources = 2
sources = []
Expand All @@ -448,8 +453,6 @@ def blend(server: ServerContext, pool: DevicePoolExecutor):

output = make_output_name(server, "upscale", params, size)
job_name = output[0]
logger.info("upscale job queued for: %s", job_name)

pool.submit(
job_name,
run_blend_pipeline,
Expand All @@ -464,6 +467,8 @@ def blend(server: ServerContext, pool: DevicePoolExecutor):
needs_device=device,
)

logger.info("upscale job queued for: %s", job_name)

return jsonify(json_params(output, params, size, upscale=upscale))


Expand Down

0 comments on commit d9f7971

Please sign in to comment.