Algorithmic Attention Art
An AI That Judges Your Photo, Turned Into Art
- image
- artwork
- classification_label
The name makes it sound like something that calls an API. It doesn't. Algorithmic Attention Art - class name SaliencyArt - is a fully local art generator that points a pretrained image classifier at your photo, works out which pixels drove its decision, and renders that attention as a piece of art. No API key, no model download beyond what torchvision fetches itself, no diffusion checkpoint involved. You feed it an IMAGE, you get back an IMAGE that looks like a surveillance still from the inside of a neural network's head.
It comes from creative-code, a small three-node pack by Claire Vlases, built while researching explainable AI with Katelyn Morrison at CMU. The other two nodes in the pack are the clinical versions; this is the one she actually makes art with. The README's own examples are the pitch: old family photos reinterpreted as "croquet ball, goldfish, mailbox."
How it works
The seven model choices (VGG16/19, ResNet50/101, DenseNet121, InceptionV3, MobileNetV3) are all ImageNet classifiers trained on 1,000 categories. Classifiers are differentiable, so the node can compute the gradient of the model's confidence in some class with respect to every input pixel: if I nudged this pixel, how much would the score move? High gradient = the model is looking there. That's the saliency map.
You then pick a method for how to compute that attention - Vanilla Gradients (noisy raw derivative), SmoothGrad (averaged over noise, smoother), Integrated Gradients, Blur IG, Guided IG, or XRAI (region-based, slowest) - and the node composites it onto your original. That's where the art actually happens: 11 composition modes (isolation, overlay, spotlight, ghost, invert, cutout, multiply, screen, triptych, mask_only, pure_white) and 10 colormaps (inferno, magma, hot, copper, twilight, and friends). Which model you pick changes the character of the attention: VGG is coarse and blunt, ResNet more semantic, MobileNet sparsely fixates on one cheap feature - itself a decent commentary on algorithmic shortcuts.
The inputs that matter
For a beginner, three things do most of the work:
- method - start with Guided IG or SmoothGrad; they're the prettiest and least static-y. Vanilla is the "what raw gradients look like" baseline.
- composition -
isolation(salient regions in color, rest greyscaled) andtriptych(original | map | composite side by side) are the two most immediately impressive. - colormap - inferno is the default and is dramatic for a reason; copper reads almost archival.
intensity (0–1, default 0.75) blends the heatmap over the original, contrast (gamma on the saliency values) and threshold control how much low-level noise survives. class_index defaults to -1 = auto-detect the model's top prediction; override it to force attention for some other ImageNet class (the README calls this out: "the categorical violence of being misclassified"). Leave input_size at 224 - except InceptionV3, which wants 299.
You get two outputs: artwork (wire into Save Image / Preview) and classification_label, a STRING that's really a caption like "goldfish (class 1), vgg16 / Guided IG" - handy for Show Text or as a filename suffix.
Installing it
ComfyUI Manager: search creative-code and install. Or manually:
cd ComfyUI/custom_nodes
git clone https://github.com/cvlases/creative-code-comfyui
pip install saliency torchvision matplotlib
Restart ComfyUI. The node appears under creative-code/art. First run auto-downloads the model weights (torchvision handles this; ~500MB for VGG16), so that first run needs internet and takes a minute. Every run after is cached. It runs fine on CPU - the author developed on an M-series MacBook.
Where people get burned
- The one real gotcha: this classifies your image, it doesn't diffuse anything. People wire in a Stable Diffusion checkpoint and wonder why nothing renders. You don't need a checkpoint at all - just Load Image → SaliencyArt → Preview.
- "creative-code" is a crowded name. There's an unrelated, more famous CreativeCode pack (GLSL shaders by SKBv0) with a nearly identical name. Install this repo -
cvlases/creative-code-comfyui- not the shader one. - XRAI and IG-with-SmoothGrad are slow on CPU. Drop
smoothgrad_samplesto 10–15 or switch method if you're waiting on every queue. - Some colormaps (
spring,cool) look actively bad on photos; that's you, not a bug.
Inputs (12)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| model_name | COMBO | vgg16 | 7 options: vgg16, vgg19, resnet50, resnet101, inception_v3, mobilenet_v3_large, +1 |
| method | COMBO | Integrated Gradients | 6 options: Vanilla Gradients, SmoothGrad, Integrated Gradients, Blur IG, Guided IG, XRAI |
| composition | COMBO | isolation | 11 options: isolation, overlay, spotlight, ghost, invert, cutout, +5 |
| colormap | COMBO | inferno | 10 options: inferno, plasma, magma, viridis, hot, cool, +4 |
| intensity | FLOAT | 0.750–1 | — |
| contrast | FLOAT | 1.50.5–4 | — |
| threshold | FLOAT | 0.250–0.95 | — |
| class_index | INT | -1-1–999 | — |
| input_size | INT | 224224–512 | — |
| use_smoothgradopt | BOOLEAN | true | — |
| smoothgrad_samplesopt | INT | 255–50 | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| artwork | IMAGE | — |
| classification_label | STRING | — |