MD: Image Guardian
Catch NaN and blown-out pixels before they reach your save node
- images
- images
Somewhere in a long batch, one image is going to come out of the VAE wrong - a NaN sneaking in, an Inf, or RGB values blown past the valid 0–1 range. Left alone, that corrupt tensor can crash the queue, produce a black or static image you don't notice for hours, or get saved as a garbage file. MD_Image_Guardian is a tripwire: it scans the image tensor right after VAE decode and decides what to do about corruption - interrupt the run, clamp the values, or replace the frame.
It's part of the pack's Guardian Suite (the NaN and Audio guardians are siblings), and the whole family exists for the same reason: long unattended queues need a sentry at the door.
How it works
The node scans the incoming [B, H, W, C] float32 image tensor for NaN, Inf, and out-of-bounds values. The tooltip recommends connecting it immediately after VAE Decode - that's the moment corruption appears, before anything downstream has a chance to mangle it further. Then action decides the response:
- Raise Hard Error - stop execution with an error.
- Graceful Interrupt - hook into ComfyUI's native interrupt system (the source does exactly this -
comfy.model_management.interrupt_current_processing()), aborting the run cleanly. - Clamp to [0.0, 1.0] (Rescue) - the recommended default: clip blown-out pixels back into range and let the image through. Salvages slightly overcooked frames.
- Output Black Frame (Rescue) - replace the whole thing with black pixels rather than pass corruption through.
The output is the (possibly repaired) images tensor, so it's a transparent in-line node - nothing changes unless something's wrong.
The inputs that matter
images- the tensor to guard.action- the four-way policy above.debug_mode- silent/info/verbose; Info gives you a console report when corruption is caught, which is how you learn your workflow has a problem at all.enable_profiling- scan timing, for the paranoid.
The scan itself uses optimized torch.isnan().any() checks, so the overhead is minimal - the tooltip calls it "minimal overhead," and for a node sitting on every frame in a batch, that matters.
The honest take
This is insurance, and like most insurance it's boring until it's not. The "Graceful Interrupt" mode is the one that saves real hours: instead of a corrupted frame poisoning the rest of a batch, the run stops at the first bad frame and you fix the cause. If you run long queues unattended, one instance after VAE decode is cheap peace of mind. If you're always watching single renders interactively, you'll rarely see it do anything - and that's the desired behavior.
Installing
It's part of MD Nodes:
cd path/to/ComfyUI/custom_nodes
git clone https://github.com/MDMAchine/ComfyUI_MD_Nodes.git
cd ComfyUI_MD_Nodes && pip install -r requirements.txt
Or via ComfyUI Manager (search MD Nodes), then restart. The pack's requirements are heavy for a single debugging node, but if you're already in the ecosystem it's a zero-thought addition after VAE decode.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| images | IMAGE | INPUT IMAGES • Purpose: The decoded image tensor from VAE or post-processing. • Range: [B, H, W, C] float32 tensor. • Trade-offs: Minimal overhead. ⭐ Recommended: Connect immediately after VAE Decode. | |
| action | COMBO | Graceful Interrupt | DEFENSE ACTION • Purpose: Handle NaN, Inf, or Out-of-bounds (>1.0 or <0.0) RGB values. • Options: - Clamp to [0.0, 1.0]: Safely limits blown-out pixels. - Output Black Frame: Replaces entirely with black pixels. ⭐ Recommended: Clamp to [0.0, 1.0] to rescue slightly blown-out images. |
| debug_mode | COMBO | 0 - Silent | LOGGING VERBOSITY • Purpose: Controls console output detail level. ⭐ Recommended: 0 - Silent. |
| enable_profiling | BOOLEAN | false | PERFORMANCE PROFILING • Enable detailed tensor scan timing. |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| images | IMAGE | — |