feat(api): make chain pipeline work without a source image
This commit is contained in:
parent
fd3e65eafc
commit
af416c252d
|
@ -99,27 +99,36 @@ class ChainPipeline:
|
||||||
callback = ChainProgress.from_progress(callback)
|
callback = ChainProgress.from_progress(callback)
|
||||||
|
|
||||||
start = monotonic()
|
start = monotonic()
|
||||||
logger.info(
|
|
||||||
"running pipeline on source image with dimensions %sx%s",
|
|
||||||
source.width,
|
|
||||||
source.height,
|
|
||||||
)
|
|
||||||
image = source
|
image = source
|
||||||
|
|
||||||
|
if source is not None:
|
||||||
|
logger.info(
|
||||||
|
"running pipeline on source image with dimensions %sx%s",
|
||||||
|
source.width,
|
||||||
|
source.height,
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
logger.info("running pipeline without source image")
|
||||||
|
|
||||||
for stage_pipe, stage_params, stage_kwargs in self.stages:
|
for stage_pipe, stage_params, stage_kwargs in self.stages:
|
||||||
name = stage_params.name or stage_pipe.__name__
|
name = stage_params.name or stage_pipe.__name__
|
||||||
kwargs = stage_kwargs or {}
|
kwargs = stage_kwargs or {}
|
||||||
kwargs = {**pipeline_kwargs, **kwargs}
|
kwargs = {**pipeline_kwargs, **kwargs}
|
||||||
|
|
||||||
logger.debug(
|
if image is not None:
|
||||||
"running stage %s on image with dimensions %sx%s, %s",
|
logger.debug(
|
||||||
name,
|
"running stage %s on source image with dimensions %sx%s, %s",
|
||||||
image.width,
|
name,
|
||||||
image.height,
|
image.width,
|
||||||
kwargs.keys(),
|
image.height,
|
||||||
)
|
kwargs.keys(),
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
logger.debug(
|
||||||
|
"running stage %s without source image, %s", name, kwargs.keys()
|
||||||
|
)
|
||||||
|
|
||||||
if (
|
if image is not None and (
|
||||||
image.width > stage_params.tile_size
|
image.width > stage_params.tile_size
|
||||||
or image.height > stage_params.tile_size
|
or image.height > stage_params.tile_size
|
||||||
):
|
):
|
||||||
|
|
|
@ -3,7 +3,13 @@ from typing import Any, List, Optional
|
||||||
|
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
|
|
||||||
from ..chain import blend_img2img, blend_mask, upscale_highres, upscale_outpaint
|
from ..chain import (
|
||||||
|
blend_img2img,
|
||||||
|
blend_mask,
|
||||||
|
source_txt2img,
|
||||||
|
upscale_highres,
|
||||||
|
upscale_outpaint,
|
||||||
|
)
|
||||||
from ..chain.base import ChainPipeline
|
from ..chain.base import ChainPipeline
|
||||||
from ..output import save_image
|
from ..output import save_image
|
||||||
from ..params import (
|
from ..params import (
|
||||||
|
@ -36,7 +42,7 @@ def run_txt2img_pipeline(
|
||||||
# prepare the chain pipeline and first stage
|
# prepare the chain pipeline and first stage
|
||||||
chain = ChainPipeline()
|
chain = ChainPipeline()
|
||||||
stage = StageParams()
|
stage = StageParams()
|
||||||
chain.append((blend_img2img, stage, None))
|
chain.append((source_txt2img, stage, None))
|
||||||
|
|
||||||
# apply upscaling and correction, before highres
|
# apply upscaling and correction, before highres
|
||||||
first_upscale, after_upscale = split_upscale(upscale)
|
first_upscale, after_upscale = split_upscale(upscale)
|
||||||
|
|
Loading…
Reference in New Issue