Nodes/tdxh_node_comfyui/TdxhImg2ImgLatent
ComfyUI Node

TdxhImg2ImgLatent

A hardware switch between txt2img and img2img

By youyegit·Created 3 years ago·Updated 5 months ago· 2
TdxhImg2ImgLatent
  • main_latent
  • pixels
  • vae
  • LATENT
  • width_INT
  • height_INT
  • denoise
bool_int1
main_width1024
main_height1024
amount1
pixels_width1024
pixels_height1024
denoise_img2img0.50

TdxhImg2ImgLatent is an A/B switch between two latents, and it's one of the genuinely clever nodes in this pack. It takes your normal "main" latent (the one from EmptyLatentImage, i.e. the txt2img path) and an image-based latent (the img2img path), and a bool_int decides which one flows out. But it also carries the denoise value along with it, which is what makes the toggle actually usable.

Here's the mechanism. With bool_int set to 0, it returns main_latent untouched, along with your main_width, main_height, and a fixed denoise of 1.0 - the txt2img signature. Flip it to 1 and it VAE-encodes pixels into a latent, repeats it amount times (via the core RepeatLatentBatch), and returns that latent with pixels_width, pixels_height, and your denoise_img2img value (default 0.5). Four outputs: LATENT, width_INT, height_INT, denoise (FLOAT).

Why the denoise output is the point: in a plain workflow you'd have to remember to flip both the latent source and the KSampler's denoise when switching modes. Here you wire this node's denoise straight into the KSampler's denoise input, and flipping bool_int flips everything together - fresh generation at denoise 1.0, or an image-edit pass at 0.5, from one switch. It's the same "one switch rules a whole branch" philosophy as the rest of the pack, applied to the txt2img/img2img fork specifically. If you want to compare "what does the model make from scratch" against "what does it do starting from this photo" on the same graph, this is a tidy way to A/B it.

One trap worth naming: when bool_int is 0, the node reports denoise 1.0 - so if you've routed the KSampler's denoise through this node, you genuinely cannot run img2img on the "main" path without flipping the switch. That's by design, but it'll confuse you the first time you leave the switch off and wonder why your "edit" looks like a fresh generation. Also note amount (1–64) is the batch repeat for the image branch - useful if you want the img2img start point to be more than one image.

The other inputs are the usual suspects: main_latent, main_width, main_height, pixels, vae, pixels_width, pixels_height, denoise_img2img. Standard wiring is EmptyLatentImagemain_latent and a loaded image → pixels, with the shared VAE from your checkpoint going to the vae socket.

Installing it

ComfyUI Manager → search tdxh_node_comfyui → install → restart, or:

cd ComfyUI/custom_nodes
git clone https://github.com/youyegit/tdxh_node_comfyui

Restart and it's under TDXH → tdxh_efficiency. No models to download. Hobbyist pack, GPL-3.0; the README warns nodes can change between versions, and since this wraps core VAEEncode/RepeatLatentBatch logic, an update could in theory lag a ComfyUI change - stock nodes are the fallback.

The honest take

If you never toggle between text-to-image and image-to-image, skip it - stock nodes are fine. If you live in img2img workflows and keep swapping which latent feeds the sampler, the "one switch, denoise rides along" behavior genuinely saves you from misconfiguring a run. It's the pack's thesis in its most useful form.

CategoryTDXH/tdxh_efficiency

Inputs (10)

NameTypeDefaultDescription
bool_intINT10–1
main_latentLATENT
main_widthINT102464–16384
main_heightINT102464–16384
pixelsIMAGE
vaeVAE
amountINT11–64
pixels_widthINT102464–16384
pixels_heightINT102464–16384
denoise_img2imgFLOAT0.500–1

Outputs (4)

NameTypeDescription
LATENTLATENT
width_INTINT
height_INTINT
denoiseFLOAT