Make RGB SparseCtrl Preprocessor compatible with newest ComfyUI changes

This commit is contained in:
Jedrzej Kosinski
2024-02-19 10:42:39 -06:00
parent f8ba75f1a0
commit 03176480f0
+6 -2
View File
@@ -3,6 +3,7 @@ from torch import Tensor
import folder_paths
from nodes import VAEEncode
import comfy.utils
from comfy.sd import VAE
from .utils import TimestepKeyframeGroup
from .control_sparsectrl import SparseMethod, SparseIndexMethod, SparseSettings, SparseSpreadMethod, PreprocSparseRGBWrapper
@@ -148,12 +149,15 @@ class RgbSparseCtrlPreprocessor:
CATEGORY = "Adv-ControlNet 🛂🅐🅒🅝/SparseCtrl/preprocess"
def preprocess_images(self, vae, image: Tensor, latent_size: Tensor):
def preprocess_images(self, vae: VAE, image: Tensor, latent_size: Tensor):
# first, resize image to match latents
image = image.movedim(-1,1)
image = comfy.utils.common_upscale(image, latent_size["samples"].shape[3] * 8, latent_size["samples"].shape[2] * 8, 'nearest-exact', "center")
image = image.movedim(1,-1)
# then, vae encode
image = VAEEncode.vae_encode_crop_pixels(image)
try:
image = vae.vae_encode_crop_pixels(image)
except Exception:
image = VAEEncode.vae_encode_crop_pixels(image)
encoded = vae.encode(image[:,:,:,:3])
return (PreprocSparseRGBWrapper(condhint=encoded),)