Skip to content

Commit

Permalink
Add an error message when a controlnet needs a VAE but none is given.
Browse files Browse the repository at this point in the history
  • Loading branch information
comfyanonymous committed Sep 21, 2024
1 parent a355f38 commit 9f7e9f0
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions comfy/controlnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ def set_cond_hint(self, cond_hint, strength=1.0, timestep_percent_range=(0.0, 1.
self.strength = strength
self.timestep_percent_range = timestep_percent_range
if self.latent_format is not None:
if vae is None:
logging.warning("WARNING: no VAE provided to the controlnet apply node when this controlnet requires one.")
self.vae = vae
self.extra_concat_orig = extra_concat.copy()
if self.concat_mask and len(self.extra_concat_orig) == 0:
Expand Down Expand Up @@ -222,6 +224,9 @@ def get_control(self, x_noisy, t, cond, batched_number):
compression_ratio = self.compression_ratio
if self.vae is not None:
compression_ratio *= self.vae.downscale_ratio
else:
if self.latent_format is not None:
raise ValueError("This Controlnet needs a VAE but none was provided, please use a different ControlNetApply node with a VAE input.")
self.cond_hint = comfy.utils.common_upscale(self.cond_hint_original, x_noisy.shape[3] * compression_ratio, x_noisy.shape[2] * compression_ratio, self.upscale_algorithm, "center")
if self.vae is not None:
loaded_models = comfy.model_management.loaded_models(only_currently_used=True)
Expand Down

0 comments on commit 9f7e9f0

Please sign in to comment.