Skip to content

Commit 0428ce7

Browse files
committed
Add early cancellation to SpandrelImageToImageInvocation.
1 parent d0d2955 commit 0428ce7

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

invokeai/app/invocations/spandrel_image_to_image.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
)
1515
from invokeai.app.invocations.model import ModelIdentifierField
1616
from invokeai.app.invocations.primitives import ImageOutput
17+
from invokeai.app.services.session_processor.session_processor_common import CanceledException
1718
from invokeai.app.services.shared.invocation_context import InvocationContext
1819
from invokeai.backend.spandrel_image_to_image_model import SpandrelImageToImageModel
1920
from invokeai.backend.tiles.tiles import calc_tiles_min_overlap
@@ -104,6 +105,10 @@ def invoke(self, context: InvocationContext) -> ImageOutput:
104105
image_tensor = image_tensor.to(device=spandrel_model.device, dtype=spandrel_model.dtype)
105106

106107
for tile, scaled_tile in tqdm(list(zip(tiles, scaled_tiles, strict=True)), desc="Upscaling Tiles"):
108+
# Exit early if the invocation has been canceled.
109+
if context.util.is_canceled():
110+
raise CanceledException
111+
107112
# Extract the current tile from the input tensor.
108113
input_tile = image_tensor[
109114
:, :, tile.coords.top : tile.coords.bottom, tile.coords.left : tile.coords.right

0 commit comments

Comments
 (0)