Skip to content

Commit

Permalink
fix: 🚀 use the comfy util to handle graph interruption
Browse files Browse the repository at this point in the history
  • Loading branch information
melMass committed Jul 6, 2023
1 parent 2f455aa commit 9752f3e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions nodes/faceswap.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
from ..utils import pil2tensor, tensor2pil
from ..log import mklog, NullWriter
import sys
import comfy.model_management as model_management


# endregion

Expand Down Expand Up @@ -100,6 +102,7 @@ def swap(
debug="false",
):
def do_swap(img):
model_management.throw_exception_if_processing_interrupted()
img = tensor2pil(img)
ref = tensor2pil(reference)
face_ids = {
Expand Down
3 changes: 3 additions & 0 deletions nodes/image_interpolation.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import comfy

import tensorflow as tf
import comfy.model_management as model_management


class LoadFilmModel:
Expand Down Expand Up @@ -104,6 +105,7 @@ def do_interpolation(
out_tensors.append(
torch.from_numpy(frame) if isinstance(frame, np.ndarray) else frame
)
model_management.throw_exception_if_processing_interrupted()
pbar.update(1)

out_tensors = torch.cat([tens.unsqueeze(0) for tens in out_tensors], dim=0)
Expand Down Expand Up @@ -228,6 +230,7 @@ def export_prores(
process = subprocess.Popen(command, stdin=subprocess.PIPE)

for frame in frames:
model_management.throw_exception_if_processing_interrupted()
process.stdin.write(frame.tobytes())

process.stdin.close()
Expand Down
3 changes: 3 additions & 0 deletions nodes/image_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
from PIL.PngImagePlugin import PngInfo
import json
import os
import comfy.model_management as model_management


try:
from cv2.ximgproc import guidedFilter
Expand Down Expand Up @@ -514,6 +516,7 @@ def resize_image(
resample="lanczos",
mask=None,
) -> torch.Tensor:
model_management.throw_exception_if_processing_interrupted()
batch_count = 1
img = tensor2pil(image)

Expand Down

0 comments on commit 9752f3e

Please sign in to comment.