Skip to content

Commit

Permalink
fix(api): switch between available pipelines
Browse files Browse the repository at this point in the history
  • Loading branch information
ssube committed Apr 15, 2023
1 parent 3170293 commit b20df68
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 12 deletions.
3 changes: 2 additions & 1 deletion api/onnx_web/chain/blend_img2img.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,10 @@ def blend_img2img(
"blending image using img2img, %s steps: %s", params.steps, params.prompt
)

pipe_type = "lpw" if params.lpw() else "img2img"
pipe = load_pipeline(
server,
"img2img",
pipe_type,
params.model,
params.scheduler,
job.get_device(),
Expand Down
3 changes: 2 additions & 1 deletion api/onnx_web/chain/blend_inpaint.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,10 @@ def blend_inpaint(
save_image(server, "last-mask.png", stage_mask)
save_image(server, "last-noise.png", noise)

pipe_type = "lpw" if params.lpw() else "inpaint"
pipe = load_pipeline(
server,
"inpaint",
pipe_type,
params.model,
params.scheduler,
job.get_device(),
Expand Down
3 changes: 2 additions & 1 deletion api/onnx_web/chain/source_txt2img.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,10 @@ def source_txt2img(
)

latents = get_latents_from_seed(params.seed, size)
pipe_type = "lpw" if params.lpw() else "txt2img"
pipe = load_pipeline(
server,
"txt2img",
pipe_type,
params.model,
params.scheduler,
job.get_device(),
Expand Down
15 changes: 8 additions & 7 deletions api/onnx_web/chain/upscale_outpaint.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,10 @@ def outpaint(tile_source: Image.Image, dims: Tuple[int, int, int]):
save_image(server, "tile-mask.png", tile_mask)

latents = get_tile_latents(full_latents, dims)
pipe_type = "lpw" if params.lpw() else "inpaint"
pipe = load_pipeline(
server,
"inpaint",
pipe_type,
params.model,
params.scheduler,
job.get_device(),
Expand All @@ -100,14 +101,14 @@ def outpaint(tile_source: Image.Image, dims: Tuple[int, int, int]):
result = pipe(
params.prompt,
tile_source,
generator=rng,
guidance_scale=params.cfg,
tile_mask,
height=size.height,
latents=latents,
mask_image=tile_mask,
negative_prompt=params.negative_prompt,
num_inference_steps=params.steps,
width=size.width,
num_inference_steps=params.steps,
guidance_scale=params.cfg,
negative_prompt=params.negative_prompt,
generator=rng,
latents=latents,
callback=callback,
)

Expand Down
6 changes: 4 additions & 2 deletions api/onnx_web/diffusers/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,10 @@ def run_highres(
)

# load img2img pipeline once
pipe_type = "lpw" if params.lpw() else "img2img"
highres_pipe = load_pipeline(
server,
"img2img",
pipe_type,
params.model,
params.scheduler,
job.get_device(),
Expand Down Expand Up @@ -168,9 +169,10 @@ def run_txt2img_pipeline(
(prompt, inversions) = get_inversions_from_prompt(prompt)
params.prompt = prompt

pipe_type = "lpw" if params.lpw() else "txt2img"
pipe = load_pipeline(
server,
"txt2img",
pipe_type,
params.model,
params.scheduler,
job.get_device(),
Expand Down

0 comments on commit b20df68

Please sign in to comment.