Nodes/creative-code/Saliency Method Comparison Grid
ComfyUI Node

Saliency Method Comparison Grid

Six Saliency Methods, One Grid, Zero Guesswork

By cvlases·Created 6 months ago·Updated 3 months ago· 0
Saliency Method Comparison Grid
  • image
  • comparison_grid
model_namevgg16
class_index-1
ig_steps50
input_size224

If you've ever stood in front of a saliency node wondering whether Vanilla Gradients or Guided IG "looks better" for a given image, this node is the answer to a question you were about to ask the hard way. Saliency Method Comparison Grid - class SaliencyComparison, from the creative-code pack - runs all six saliency methods on the same image, model, and class, and lays them out in a 2×3 grid so you can eyeball the differences in one frame.

There's no method dropdown, because that's the point: it does all six - Vanilla Gradients, SmoothGrad, Integrated Gradients, Blur IG, Guided IG, and XRAI - each rendered as a heatmap overlay on your resized image, three across, two rows down. The whole pack shares the same machinery (one saliency_nodes.py file; this node literally calls into SaliencyMap's render code for each method), so the grid is consistent with what you'd get running each method individually. It's the pack's compare-and-contrast view, and it works exactly as advertised.

Inputs

Only five, and you'll mostly touch two:

  • image - any IMAGE; it gets resized to input_size before classification.
  • model_name - same seven torchvision CNNs as the rest of the pack (VGG16, VGG19, ResNet50/101, DenseNet121, InceptionV3, MobileNetV3). The model changes the character of every method's attention, so this is where most of the variety actually comes from.
  • class_index - -1 (default) auto-detects the model's top prediction; override to probe a specific ImageNet class.
  • ig_steps - interpolation steps for the IG-family methods (10–200, default 50). More = smoother/more accurate attribution but slower; this is the one knob that meaningfully affects how the IG/Blur IG/Guided IG panels look.
  • input_size - 224, or 299 if you pick InceptionV3 (it was trained at that resolution).

Output

One IMAGE: comparison_grid. Wire it to Preview or Save Image. The panels are labeled only by their position - first row Vanilla, SmoothGrad, Integrated Gradients; second row Blur IG, Guided IG, XRAI - so screenshot it if you want to remember which corner is which. That's the whole node.

Installing it

Same as the rest of the pack - ComfyUI Manager, search creative-code, install. Or:

cd ComfyUI/custom_nodes
git clone https://github.com/cvlases/creative-code-comfyui
pip install saliency torchvision matplotlib

Restart; it's under creative-code/explainability. First run auto-downloads model weights (~500MB for VGG16) via torchvision and caches them, and it runs happily on CPU - the author built it on an M-series MacBook.

Where people get burned

  • It's slow, by design. Six methods × forward/backward passes, and XRAI is the heavyweight of the bunch. This is a "change model, queue once, compare" node - not something to wire into a real-time preview loop.
  • No styling control. The grid is always the same viridis heatmap overlay. If you want per-method coloring or artistic composition, that's what SaliencyArt is for; if you want one method in isolation, use SaliencyMap. This node's only job is the side-by-side.
  • Same name-collision warning as the rest of the pack: install cvlases/creative-code-comfyui, not the unrelated GLSL-shader CreativeCode pack.
Categorycreative-code/explainability

Inputs (5)

NameTypeDefaultDescription
imageIMAGE
model_nameCOMBOvgg167 options: vgg16, vgg19, resnet50, resnet101, inception_v3, mobilenet_v3_large, +1
class_indexINT-1-1–999
ig_stepsINT5010–200
input_sizeINT224224–512

Outputs (1)

NameTypeDescription
comparison_gridIMAGE