Nodes/ComfyUI Serving toolkit/Serving Input Image as Latent
ComfyUI Node

Serving Input Image as Latent

The img2img shortcut that hands you a latent instead of a tensor

By matan1905·Created 3 years ago·Updated about a year ago· 71
Serving Input Image as Latent
  • serving_config
  • vae
  • default_latent
  • LATENT

ServingInputImageAsLatent is the serving toolkit's img2img convenience node: it takes the image a user attached to their command and hands your workflow a LATENT instead of an IMAGE tensor. That saves you the VAE Encode step in the graph - the node encodes the attachment for you and returns something you can feed straight into a KSampler. If you've ever built an img2img workflow in ComfyUI, you know VAE Encode is the boilerplate step in the middle; this node folds it in, which is one less node and one less wire to get wrong.

The vae input is the price of that convenience - you have to wire in your VAE model, and it must match the checkpoint your sampler is using. The node downloads the attached image, decodes it via OpenCV, normalizes it, then runs vae.encode() on it and wraps the result as a {"samples": ...} LATENT dict - the exact shape ComfyUI's sampler nodes expect. Mismatch your VAE with the checkpoint and you'll get the same weird latents you'd get from any VAE Encode mismatch, so treat the vae input as "the VAE for this workflow, don't improvise."

The star feature, and the reason the author shipped this in the 2024 update, is default_latent. It's listed as a required input (you'll wire something into it - often an empty latent or a VAE encode of a placeholder), and its job is the fallback: if the request has no attachment, the node returns default_latent and your workflow runs as txt2img. Same graph, same sampler, same everything - just "user attached a photo" vs. "user typed a prompt" determines whether you img2img or txt2img. In the author's own words, you get both modes "without even thinking," and it's honestly the best feature in the whole toolkit for bot builders.

If there's no attachment and no useful default_latent (you wired a placeholder), the fallback logic kicks in: the node sends "This command requires an image" through the serving layer and calls interrupt_processing to stop the run. So a missing attachment is a polite stop, not a corrupted render.

Inputs: serving_config, vae, default_latent. Output: LATENT. From there it wires straight into your sampler's latent input - no VAE Encode between it and the KSampler.

Install is the shared pack install: ComfyUI Manager, or git clone into custom_nodes + pip install -r requirements.txt. The encoding path pulls in opencv-python (already in the pack's requirements) plus your normal ComfyUI VAE machinery; no extra models download. Standing rule: Auto Queue on, or the node handles one request and goes quiet.

CategoryServing-Toolkit

Inputs (3)

NameTypeDefaultDescription
serving_configSERVING_CONFIG
vaeVAE
default_latentLATENT

Outputs (1)

NameTypeDescription
LATENTLATENT