ArtificialGuyBR

Home / Blog / ComfyUI

Modular ComfyUI: One Graph for txt2img, img2img, Upscale

Build a single ComfyUI graph for txt2img, img2img, and upscale using bypass, KSampler denoise, and reusable templates.

6 sources cited ComfyUI

Modular ComfyUI Workflows: One Graph for txt2img, img2img, Upscale

TL;DR


Why Modular Workflows Matter

ComfyUI workflows are directed acyclic graphs. Every task — load model, encode prompt, sample, decode, upscale — is a discrete node with typed inputs and outputs. Because the graph is data-flow rather than imperative code, you can rewire, bypass, or duplicate branches without rewriting logic. A modular workflow keeps optional stages (ControlNet, IPAdapter, upscaler) in separate bypassable branches so the same .json serves text-to-image, image-to-image, and high-res fix without duplication.


The Toggle Mechanism: Bypass, Don't Delete

How bypass works

Select any node and press Ctrl + B. ComfyUI removes it from the execution graph and stitches inputs directly to outputs. The node stays on the canvas (dimmed) so you can re-enable it instantly with another Ctrl + B.

Source: ComfyUI README: "Ctrl + B — Bypass selected nodes (acts like the node was removed from the graph and the wires reconnected through)" [^1]

A right-click "Bypass Node" may exist in recent UI builds, but the documented mechanism is Ctrl + B.

When to bypass vs. delete

ScenarioAction
Temporary disableCtrl + B
Permanent removalDelete and rewire manually
Swap modelKeep node, change loader input

One Graph, Three Modes

The pivot is KSampler. Its latent_image input and denoise parameter determine the generation mode.

txt2img (pure generation)

EmptyLatentImage → KSampler (denoise = 1.0) → VAEDecode

EmptyLatentImage creates pure noise at your target resolution. denoise = 1.0 means the sampler ignores input latent structure entirely.

img2img (guided transformation)

LoadImage → VAEEncode → KSampler (denoise < 1.0) → VAEDecode

VAEEncode compresses the input image to latent space. The KSampler docs say "lower values will maintain the structure of the initial image allowing for image to image sampling" [^2]. denoise &lt; 1.0 preserves that structure; lower values stay closer to the source, higher values allow more creative deviation.

upscale (high-res fix)

KSampler → VAEDecode → UpscaleModelLoader → ImageUpscale → (optional) VAEDecode again

UpscaleModelLoader reads a model file from models/upscale_models/ (for example 4x-UltraSharp.pth). For a true high-res fix, insert a second KSampler after ImageScale → VAEEncode, matching the two-pass pattern linked in ComfyUI's examples [^1].


Optional Conditioning Branches

ControlNet (built-in)

ControlNetApply and ControlNetApplyAdvanced are built-in nodes. They take:

Output is modified conditioning. To disable: bypass ControlNetApply.

Source: ControlNetApply docs: "Controls the strength of network adjustments, value range 0~10. Recommended values between 0.5~1.5 are reasonable." [^3]

IPAdapter (third-party)

IPAdapter is not a built-in node. It comes from community custom node packs (for example comfyui-ipadapter). The typical chain:

LoadImage → IPAdapterEncoder → IPAdapterApply → conditioning

To disable: bypass IPAdapterApply. IPAdapter has no built-in on/off switch separate from bypass.


Grouping: Visual Only, Not Reusable

Ctrl + G creates a collapsible visual group. It helps readability but does not create a callable sub-graph, allow drag-and-drop reuse, or export a standalone component.

For true reuse:

ApproachHow it worksTrade-off
Workflow templatesSave a .json with only the sub-graph; import via Workflows → OpenManual wiring each time
Custom node (Python)Write a node that internally builds the sub-graphRequires Python, cleanest API
Copy-paste + regroupCtrl + C / Ctrl + V across tabsFastest for ad-hoc reuse
Source: ComfyUI README: "Ctrl + G — Group selected nodes" — grouping is a UI shortcut, not a module system [^1].

Settings Reference Table

Parametertxt2imgimg2imgUpscale (HR fix)Source
KSampler latent_imageEmptyLatentImageVAEEncode(LoadImage)First pass: EmptyLatentImage; second pass: VAEEncode(ImageScale)[^2]
KSampler denoise1.0any value below 1.0First pass: 1.0; second pass: below 1.0[^2]
ControlNet strength0.5–1.5 if used0.5–1.5Usually off for upscale pass[^3]
Upscale modelexample 4x-UltraSharp.pth in models/upscale_models/[^4]
Checkpoint loaderCheckpointLoaderSimpleCheckpointLoaderSimpleshared across all passes[^5]

Common Errors and Fixes

SymptomCauseFix
"Load > Load (custom nodes)" not foundCustom-node installation is not workflow loadingUse Workflows → Open (Ctrl+O) or drag .json onto the canvas [^6]
IPAdapter node missingIPAdapter is not built-inInstall a custom node pack via ComfyUI Manager
ControlNet does nothingPreprocessor missing or wrong image formatInstall comfyui-controlnet-preprocessors; match preprocessor to input type
UpscaleModelLoader shows no modelsModel file not in models/upscale_models/Place .pth/.onnx there, then refresh or restart [^4]
img2img ignores input imagedenoise left at 1.0Set denoise below 1.0 [^2]
Bypassed node still runsNode not actually bypassedRe-select node, press Ctrl + B, verify dimming/wire pass-through

FAQ

How do I toggle a workflow stage on and off? Select the node and press Ctrl + B. Press again to re-enable.

Can one ComfyUI graph handle txt2img, img2img, AND upscale? Yes. Feed KSampler an EmptyLatentImage for txt2img, a VAEEncode latent with denoise &lt; 1.0 for img2img, and chain UpscaleModelLoader → ImageUpscale after decode for upscaling. All modes share the same checkpoint, CLIP, and VAE.

Is "ComfyUI Modular Node System" an official feature name? No. ComfyUI's tagline is "the most powerful and modular diffusion model GUI," referring to its node-graph architecture. There is no product or API called "Modular Node System."

How do I load a workflow JSON into ComfyUI? Drag the .json onto the canvas, or use Workflows → Open (Ctrl+O). The "Load (custom nodes)" menu installs Python custom-node packages, not workflows.

Does ComfyUI have a right-click "Bypass Node"? The documented bypass is Ctrl + B. A right-click option may exist in recent UI builds but is not in the official shortcuts table.

Are IPAdapter and ControlNet nodes built into ComfyUI? ControlNetApply and ControlNetApplyAdvanced are built-in. IPAdapter is a third-party custom node.

What does the KSampler denoise parameter actually do? At 1.0 (default), the sampler treats the input latent as pure noise. Below 1.0, it blends the input latent's structure with the denoised output — lower values preserve more of the original image.

How do I make a truly reusable node group? Save a sub-graph as a .json template and import manually, write a custom Python node, or copy-paste nodes across workflow tabs.


Sources

[^1]: ComfyUI GitHub README — shortcuts and architecture — https://github.com/Comfy-Org/ComfyUI [^2]: KSampler built-in node documentation — https://docs.comfy.org/built-in-nodes/KSampler.md [^3]: ControlNetApply built-in node documentation — https://docs.comfy.org/built-in-nodes/ControlNetApply.md [^4]: UpscaleModelLoader built-in node documentation — https://docs.comfy.org/built-in-nodes/UpscaleModelLoader.md [^5]: CheckpointLoaderSimple built-in node documentation — https://docs.comfy.org/built-in-nodes/CheckpointLoaderSimple.md [^6]: ComfyUI text-to-image tutorial (workflow loading) — https://docs.comfy.org/tutorials/basic/text-to-image