major documentation
@@ -1,63 +1,38 @@
|
||||
# Colormap Examples
|
||||
Keeping everything the same, but changing the color map to demonstrate visual differences.
|
||||
|
||||
## understanding Colormaps
|
||||
These apply a color gradient to the greyscale saliency values. Low values (less important) get one end of the gradient, high values (more important) get the other.
|
||||
inferno — Black → purple → orange → yellow. The default. Dramatic, high contrast.
|
||||
plasma — Purple → pink → yellow. Vibrant and synthetic-looking. Feels digital, almost neon.
|
||||
magma — Black → deep purple → pink-white. Darker and contrast than inferno.
|
||||
viridis — Purple → teal → yellow-green. The standard scientific colormap, designed to be perceptually uniform.
|
||||
hot — Black → red → orange → white. Classic heat map / thermal camera.
|
||||
cool — Cyan → magenta. Cold, clinical.
|
||||
spring — Magenta → yellow. Neon, synthetic, light greens.
|
||||
copper — Black → dark brown → copper-gold. Archival, almost daguerreotype-y.
|
||||
twilight — purple → white → orange → purple. Atmospheric brown.
|
||||
ocean — Black-blue → cyan → white. Deep and watery blue
|
||||
Colormaps apply a color gradient to the greyscale saliency values — low saliency gets one end, high saliency gets the other.
|
||||
|
||||
## What is it?
|
||||
> model: vgg16 · method: Guided IG · composition: invert · intensity: 0.75 · contrast: 1.5 · threshold: 0.25 · class_index: -1 · input_size: 224 · use_smoothgrad: true · smoothgrad_samples: 25 · **colormap: varies**
|
||||
|
||||
Model_name: vgg16
|
||||
method: guided IG
|
||||
composition: inverse
|
||||
colormap: THIS IS WHAT CHANGES
|
||||
intensity: 0.75
|
||||
contrast: 1.5
|
||||
threshold: 0.25
|
||||
class_index: -1
|
||||
input_size: 224
|
||||
uses_smooth_grad: true
|
||||
snoothgrad_samples: 25
|
||||
| Colormap | Range | Character |
|
||||
|----------|-------|-----------|
|
||||
| **inferno** | Black → purple → orange → yellow | Dramatic, high contrast. The default. |
|
||||
| **plasma** | Purple → pink → yellow | Vibrant, synthetic, neon |
|
||||
| **magma** | Black → deep purple → pink-white | Darker and moodier than inferno |
|
||||
| **viridis** | Purple → teal → yellow-green | Standard scientific colormap, perceptually uniform |
|
||||
| **hot** | Black → red → orange → white | Classic thermal camera aesthetic |
|
||||
| **cool** | Cyan → magenta | Cold, clinical |
|
||||
| **spring** | Magenta → yellow | Neon, synthetic |
|
||||
| **copper** | Black → brown → copper-gold | Archival, almost daguerreotype-like |
|
||||
| **twilight** | Purple → white → orange → purple | Smooth, atmospheric (cyclical) |
|
||||
| **ocean** | Black-blue → cyan → white | Deep, watery |
|
||||
|
||||
**cool** 
|
||||
|
||||
## listed
|
||||
**copper** 
|
||||
|
||||
**hot** 
|
||||
|
||||
cool
|
||||

|
||||
**inferno** 
|
||||
|
||||
hot
|
||||

|
||||
**magma** 
|
||||
|
||||
copper
|
||||

|
||||
**ocean** 
|
||||
|
||||
inferno
|
||||

|
||||
**plasma** 
|
||||
|
||||
magma
|
||||

|
||||
**spring** 
|
||||
|
||||
ocean
|
||||

|
||||
**twilight** 
|
||||
|
||||
plasma
|
||||

|
||||
|
||||
spring
|
||||

|
||||
|
||||
twilight
|
||||

|
||||
|
||||
viridis
|
||||

|
||||
**viridis** 
|
||||
@@ -1,63 +1,39 @@
|
||||
# Composition Examples
|
||||
Keeping everything the same, but changing the composition to demonstrate visual differences.
|
||||
|
||||
## Understanding compostion modes
|
||||
These control how the saliency map is composited back onto the original image. This is where the artistic intent lives.
|
||||
isolation — The default and most conceptually pointed for your project. Salient regions show in full color using the chosen colormap; everything else is converted to greyscale. The effect: the machine's gaze burns in color while everything it ignores fades to grey. Very direct visual commentary on algorithmic attention.
|
||||
overlay — Classic heatmap blend. The colormap is alpha-composited over the original at the intensity level. Familiar, readable, less subversive.
|
||||
spotlight — The salient regions are bright, everything else darkens dramatically. Feels like a searchlight or surveillance camera — forensic, clinical.
|
||||
ghost — The original image fades to 25% opacity and the saliency map glows over it. The subject becomes spectral, haunted by its own classification. Good for an uncanny effect.
|
||||
invert — Shows what the algorithm ignores instead of what it sees. The saliency map is flipped before compositing. Conceptually this is the most subversive mode — it visualizes the blind spots, the parts of a face that are invisible to the machine.
|
||||
cutout — Hard binary mask. Pixels above the threshold value show the original image; everything below shows a dim version of the heatmap. Creates a stark, graphic effect — the subject literally cut out by the algorithm's attention boundary.
|
||||
multiply — Photoshop-style multiply blend. Attention dims non-salient areas. Produces a dark, moody result where ignored regions sink into shadow.
|
||||
screen — Photoshop-style screen blend. Attention brightens salient regions. Lighter and more luminous than multiply — glowing rather than shadowed.
|
||||
triptych — Outputs three panels side by side: original | saliency map alone | composite. Designed for gallery or exhibition display — shows the full chain of the visualization in one image.
|
||||
mask_only — Just the colored saliency map with no original image. Pure algorithmic output, no human context.
|
||||
Composition modes control how the saliency map is rendered back onto the original image. This is where the artistic intent lives.
|
||||
|
||||
## What is it?
|
||||
> model: vgg16 · method: Guided IG · colormap: magma · intensity: 0.75 · contrast: 1.5 · threshold: 0.25 · class_index: -1 · input_size: 224 · use_smoothgrad: true · smoothgrad_samples: 25 · **composition: varies**
|
||||
|
||||
Model_name: vgg16
|
||||
method: guided IG
|
||||
composition: THIS IS WHAT CHANGES
|
||||
colormap: magma
|
||||
intensity: 0.75
|
||||
contrast: 1.5
|
||||
threshold: 0.25
|
||||
class_index: -1
|
||||
input_size: 224
|
||||
uses_smooth_grad: true
|
||||
snoothgrad_samples: 25
|
||||
| Mode | Effect |
|
||||
|------|--------|
|
||||
| **isolation** | Salient regions in full colormap color; everything else greyscale. The machine's gaze burns in color while what it ignores fades away. The default — most direct visual commentary on algorithmic attention. |
|
||||
| **overlay** | Classic heatmap alpha-blend over the original. Familiar and readable, less subversive. |
|
||||
| **spotlight** | Salient regions bright, everything else darkened dramatically. Feels like a searchlight or surveillance camera — forensic, clinical. |
|
||||
| **ghost** | Original fades to 25% opacity, saliency map glows over it. Subject becomes spectral, haunted by its own classification. |
|
||||
| **invert** | Shows what the algorithm *ignores* instead of what it sees. The most subversive mode — visualizes blind spots, the parts of a face invisible to the machine. |
|
||||
| **cutout** | Hard binary mask. Pixels above threshold show the original; below shows a dim heatmap. The subject literally cut out by the algorithm's attention boundary. |
|
||||
| **multiply** | Photoshop-style multiply blend. Ignored regions sink into shadow. Dark and moody. |
|
||||
| **screen** | Photoshop-style screen blend. Salient regions glow brighter. Lighter and more luminous than multiply. |
|
||||
| **triptych** | Three panels side by side: original · saliency map · composite. Full chain of the visualization in one frame. Gallery-ready. |
|
||||
| **mask_only** | Just the colored saliency map, no original. Pure algorithmic output, no human context. |
|
||||
| **pure_white** | Black background, saliency values mapped to white intensity. Like an x-ray or photogram — the raw shape of what the algorithm attended to, stripped of all color and context. |
|
||||
|
||||
**cutout** 
|
||||
|
||||
## What is it?
|
||||
**ghost** 
|
||||
|
||||
**invert** 
|
||||
|
||||
cutout
|
||||

|
||||
**isolation** 
|
||||
|
||||
ghost
|
||||

|
||||
**mask_only** 
|
||||
|
||||
invert
|
||||

|
||||
**multiply** 
|
||||
|
||||
isolation
|
||||

|
||||
**overlay** 
|
||||
|
||||
mask only
|
||||

|
||||
**pure_white** 
|
||||
|
||||
multiply
|
||||

|
||||
**screen** 
|
||||
|
||||
overlay
|
||||

|
||||
|
||||
pure white
|
||||

|
||||
|
||||
screen
|
||||

|
||||
|
||||
triplych
|
||||

|
||||
**triptych** 
|
||||
@@ -1,85 +1,75 @@
|
||||
# Colormap Examples
|
||||
Keeping everything the same, but changing the color map to demonstrate visual differences.
|
||||
# Other Parameters
|
||||
|
||||
> model: vgg16 · method: Guided IG · composition: invert · colormap: magma · **parameter: varies** · all others at default
|
||||
|
||||
Other Parameters
|
||||
intensity — How strongly the saliency visualization is blended onto the original. 0 = invisible, 1 = full. Most compositions look best between 0.6–0.85.
|
||||
contrast (gamma) — Applies a power function to the saliency values before visualization. Values above 1.0 compress the low end and expand the high end — making the most salient regions pop dramatically while less important regions fade further. Cranking this to 2.5–3.0 produces extreme, high-drama results where only the very top attention regions survive.
|
||||
threshold — Used primarily by isolation and cutout modes. Sets the minimum saliency value to be considered "attended to." Higher values make the visualization sparser and more selective — only the regions the model is most confident about survive.
|
||||
class_index — ImageNet has 1000 classes. By default (-1) the node auto-detects what the model predicted and visualizes attention for that class. You can override this to force the visualization to show what the model would attend to if it were trying to classify the image as a specific thing — for example, forcing class 207 (golden retriever) on a human portrait produces attention patterns for a question the model was never meant to answer, which has interesting artistic implications.
|
||||
input_size — All these models were trained on fixed-size inputs. 224×224 is standard for most; InceptionV3 requires 299×299. The image is resized to this before processing, which is why the output appears at that resolution.
|
||||
use_smoothgrad — When enabled on top of any method (except SmoothGrad which already does this), applies the SmoothGrad averaging process to smooth the result. Generally produces more aesthetically pleasing outputs at the cost of being slower.
|
||||
smoothgrad_samples — How many noisy samples to average when SmoothGrad is active. 25 is a good balance; 50+ produces very smooth results but takes proportionally longer.
|
||||
| Parameter | Default | Effect |
|
||||
|-----------|---------|--------|
|
||||
| **intensity** | 0.75 | How strongly the saliency map blends onto the original. 0 = invisible, 1 = full replacement. |
|
||||
| **contrast** | 1.5 | Power function applied to saliency values. Above 1.0 makes top regions pop and low regions fade. 2.5–3.0 is extreme — only the very highest attention survives. |
|
||||
| **threshold** | 0.25 | Minimum saliency value to count as "attended to." Used mainly by `isolation` and `cutout`. Higher = sparser, more selective output. |
|
||||
| **class_index** | -1 (auto) | Which ImageNet class to visualize attention for. -1 auto-detects the model's top prediction. Overriding forces the model to answer a different question — e.g. class 207 (golden retriever) on a human portrait shows attention for a question it was never meant to answer. |
|
||||
| **input_size** | 224 | Models require fixed-size square inputs. 224×224 is standard; InceptionV3 requires 299. Not adjusted here — most models require 224 to run correctly. |
|
||||
| **use_smoothgrad** | true | Adds SmoothGrad noise-averaging on top of any method. Produces smoother, more aesthetically stable results at the cost of speed. |
|
||||
| **smoothgrad_samples** | 25 | How many noisy passes to average when SmoothGrad is active. 25 balances smoothness and speed; 50+ is noticeably smoother but proportionally slower. |
|
||||
|
||||
---
|
||||
|
||||
## What is it?
|
||||
### Intensity
|
||||
|
||||
Model_name: vgg16
|
||||
method: guided IG
|
||||
composition: inverse
|
||||
colormap: magma
|
||||
[the following IS WHAT CHANGES]
|
||||
default values:
|
||||
Default **0.75** — chosen as the point where the saliency map clearly dominates while still leaving enough of the original image readable as context.
|
||||
|
||||
intensity: 0.75
|
||||
contrast: 1.5
|
||||
threshold: 0.25
|
||||
class_index: -1
|
||||
input_size: 224
|
||||
uses_smooth_grad: true
|
||||
snoothgrad_samples: 25
|
||||
**0.5** (lower) 
|
||||
|
||||
**1.0** (full) 
|
||||
|
||||
## listed out
|
||||
should explain why i picked the default values i did.
|
||||
|
||||
### Intensity
|
||||
|
||||
intensity = 0.5
|
||||
(lower)
|
||||

|
||||
|
||||
intensity = 1.0
|
||||
(higher)
|
||||

|
||||
---
|
||||
|
||||
### Contrast
|
||||
|
||||
contrast = 1.0
|
||||
(lower)
|
||||

|
||||
Default **1.5** — adds drama without becoming so aggressive that only a handful of pixels survive. Values above 2.0 start to feel like thresholding.
|
||||
|
||||
contrast = 2.0
|
||||
(higher)
|
||||

|
||||
**1.0** (flat, no adjustment) 
|
||||
|
||||
### threshold
|
||||
threshold = 0.0
|
||||
(lower)
|
||||

|
||||
**2.0** (more aggressive) 
|
||||
|
||||
threshold = 0.5
|
||||
(higher)
|
||||

|
||||
---
|
||||
|
||||
### class index
|
||||
class index = 1
|
||||
(a little change)
|
||||

|
||||
### Threshold
|
||||
|
||||
class index = 10
|
||||
(a larger change)
|
||||

|
||||
Default **0.25** — eliminates low-confidence gradient noise while preserving the meaningful attended region. At 0.0 everything is included; at 0.5 only the top quarter of saliency values show.
|
||||
|
||||
### input size
|
||||
Didn't adjust this because most models require this size (224) to run properly.
|
||||
**0.0** (nothing filtered) 
|
||||
|
||||
### uses smooth grad
|
||||
Without (uses smooth grad = false)
|
||||

|
||||
**0.5** (aggressive filtering) 
|
||||
|
||||
---
|
||||
|
||||
### Class Index
|
||||
|
||||
### smooth grad samples
|
||||
samples = 50
|
||||

|
||||
Default **-1 (auto)** — visualizes attention for whatever the model actually predicted. Overriding this forces the model to attend to features of a class it wasn't trying to find, producing maps that can feel alien or misaligned — attention patterns searching for something that isn't there.
|
||||
|
||||
**class 1** (slight displacement) 
|
||||
|
||||
**class 10** (larger displacement) 
|
||||
|
||||
---
|
||||
|
||||
### Input Size
|
||||
|
||||
Default **224** — not demonstrated here because most models require this exact size to run correctly. InceptionV3 is the only exception, requiring 299.
|
||||
|
||||
---
|
||||
|
||||
### Use SmoothGrad
|
||||
|
||||
Default **true** — the smoothing improvement is significant and 25 samples is fast enough that the tradeoff is worth it for almost all use cases.
|
||||
|
||||
**false** (raw gradients, no smoothing) 
|
||||
|
||||
---
|
||||
|
||||
### Smoothgrad Samples
|
||||
|
||||
Default **25** — a reliable balance. Below 10 starts to look patchy; above 50 the improvement becomes marginal relative to the time cost.
|
||||
|
||||
**50 samples** 
|
||||
@@ -1,48 +1,28 @@
|
||||
# Methods Examples
|
||||
Keeping everything the same, but changing the model to demonstrate visual differences.
|
||||
# Method Examples
|
||||
|
||||
## Understanding methods
|
||||
These are the mathematical techniques used to ask "what pixels mattered to this model's decision?" Each has a different visual character.
|
||||
Vanilla Gradients — The simplest approach: take the derivative of the output with respect to each input pixel. Fast and raw. The result is noisy and looks almost like static or grain — shows every pixel that had any influence at all, including spurious ones. Visually the most aggressive and chaotic.
|
||||
SmoothGrad — Takes Vanilla Gradients but runs it many times with small random noise added to the image each time, then averages the results. This cancels out the noise and reveals more stable patterns. Visually smoother and more "reliable" looking than vanilla, but still texture-rich. The smoothgrad_samples parameter controls how many noisy runs are averaged — more = smoother but slower.
|
||||
Integrated Gradients — Instead of just looking at gradients at the input image, this traces a path from a blank black image to your actual image and accumulates gradients along that path. This gives it a strong theoretical foundation (it satisfies mathematical axioms about attribution). Produces clean, smooth maps that highlight meaningful regions rather than just any active pixels. The ig_steps parameter controls how many steps along that path — more = more accurate but slower. This is usually the best starting method.
|
||||
Blur IG — A variant of Integrated Gradients where instead of interpolating from black to the image, it interpolates from a heavily blurred version to the sharp image. This tends to produce maps focused on edges and structural details rather than color/texture. Produces a different aesthetic — more architectural-looking.
|
||||
Guided IG — Another IG variant that uses gradient information to choose a smarter integration path, concentrating steps where the gradients are largest. Produces sharper, higher-contrast attribution maps with more defined edges. Often the most visually striking for portraits.
|
||||
XRAI — Completely different approach. Instead of pixel-level gradients, it segments the image into regions and attributes importance to each region as a whole. Produces a patchwork/segmented look — almost like stained glass or a heat map made of irregular shapes. Very different aesthetic from the gradient methods. Uses algorithm="fast" by default; changing to "full" in the code gives higher quality but is much slower.
|
||||
Methods are the mathematical techniques used to ask "what pixels mattered to this model's decision?" Each produces a fundamentally different visual character.
|
||||
|
||||
> model: vgg16 · composition: pure_white · colormap: magma · intensity: 0.75 · contrast: 1.5 · threshold: 0.25 · class_index: -1 · input_size: 224 · use_smoothgrad: true · smoothgrad_samples: 25 · **method: varies**
|
||||
|
||||
## What is it?
|
||||
| Method | Approach | Character |
|
||||
|--------|----------|-----------|
|
||||
| **Vanilla Gradients** | Derivative of output w.r.t. each pixel | Raw, noisy, chaotic — every pixel with any influence at all, including spurious ones |
|
||||
| **SmoothGrad** | Vanilla Gradients averaged over many noise-perturbed runs | Smoother and more stable than vanilla, but still texture-rich |
|
||||
| **Integrated Gradients** | Accumulates gradients along a path from black image → input | Clean, theoretically grounded, highlights semantically meaningful regions. Usually the best starting method. |
|
||||
| **Blur IG** | Like IG, but interpolates from a blurred image → sharp input | Focused on edges and structural transitions rather than color/texture. More architectural. |
|
||||
| **Guided IG** | IG with an adaptive path that concentrates steps where gradients are largest | Sharpest, highest-contrast results. Most visually striking for portraits. |
|
||||
| **XRAI** | Segments image into regions, attributes importance per region rather than per pixel | Patchwork/stained glass aesthetic — very different from gradient methods. Slower. |
|
||||
|
||||
Model_name: vgg16
|
||||
method: THIS IS WHAT CHANGES
|
||||
composition: pure_white
|
||||
colormap: magma
|
||||
intensity: 0.75
|
||||
contrast: 1.5
|
||||
threshold: 0.25
|
||||
class_index: -1
|
||||
input_size: 224
|
||||
uses_smooth_grad: true
|
||||
snoothgrad_samples: 25
|
||||
---
|
||||
|
||||
**Vanilla Gradients** 
|
||||
|
||||
## What is it?
|
||||
**SmoothGrad** 
|
||||
|
||||
**Integrated Gradients** 
|
||||
|
||||
Vanilla Gradient
|
||||

|
||||
**Blur IG** 
|
||||
|
||||
Smooth Gradient
|
||||

|
||||
**Guided IG** 
|
||||
|
||||
Integrated Gradient
|
||||

|
||||
|
||||
Blur Integrated Gradients
|
||||

|
||||
|
||||
Guided Integrated Gradients
|
||||

|
||||
|
||||
XRAI
|
||||

|
||||
**XRAI** 
|
||||
@@ -1,36 +1,77 @@
|
||||
# Model Examples
|
||||
Keeping everything the same, but changing the model to demonstrate visual differences.
|
||||
|
||||
## Understanding Models
|
||||
Models
|
||||
The model is the "brain" being interrogated — it's a pretrained ImageNet classifier whose internal decision-making we're visualizing. Different models have different "personalities" in how they look at images.
|
||||
The model is the "brain" being interrogated — a pretrained ImageNet classifier whose internal decision-making we're visualizing. Different architectures have different visual personalities.
|
||||
|
||||
need to explain why these models, where they came from. explain reasoning behind choices
|
||||
> method: Guided IG · composition: pure_white · colormap: magma · intensity: 0.75 · contrast: 1.5 · threshold: 0.25 · class_index: -1 · input_size: 224 · use_smoothgrad: true · smoothgrad_samples: 25 · **model: varies**
|
||||
|
||||
VGG16 / VGG19 — Old, deep, sequential architecture from 2014. For portraits, these are the most interesting because they're blunt and spatially crude. The attention patterns feel almost aggressive — big, blocky regions. Good for the "surveillance" feeling you're going for. VGG16 is the default for a reason.
|
||||
ResNet50 / ResNet101 — More modern, uses skip connections. Produces cleaner, more distributed attention. Less visually dramatic than VGG but more "honest" about what it's actually classifying.
|
||||
<!-- EfficientNet-B0 — Very modern, highly optimized. Produces fine-grained, sparse attention maps. Interesting for showing how efficiently a model can locate a subject with minimal "gaze." -->
|
||||
DenseNet121 — Dense connectivity means attention is highly distributed across the image. Produces diffuse, almost painterly saliency maps.
|
||||
MobileNetV3 — Designed for mobile devices, so it's aggressively compressed. Produces the sparsest, most stripped-down attention — shows only the absolute minimum the model needs to make a decision.
|
||||
InceptionV3 — Uses parallel convolutions at multiple scales. Produces multi-scale attention that can look almost fractal. Requires input_size 299 instead of 224.
|
||||
**TLDR:** Coarse and blunt (VGG) → distributed and semantic (ResNet) → diffuse and layered (DenseNet) → multi-scale (Inception) → sparse and shortcut-prone (MobileNet)
|
||||
|
||||
## What is it?
|
||||
| Model | Architecture | Attention character |
|
||||
|-------|-------------|-------------------|
|
||||
| **vgg16 / vgg19** | Deep sequential, 3×3 filters, fully-connected head | Large, blocky, coarse — surveillance-like |
|
||||
| **resnet50 / resnet101** | Residual (skip) connections | Distributed, semantically coherent, more "honest" |
|
||||
| **densenet121** | Every layer connects to every subsequent layer | Diffuse, multi-scale, almost painterly |
|
||||
| **inception_v3** | Parallel convolutions at 1×1, 3×3, 5×5 simultaneously | Multi-scale, can look fractal. Requires input_size 299. |
|
||||
| **mobilenet_v3_large** | Depthwise separable convolutions, mobile-optimized | Sparsest — fixates on the single cheapest distinguishing feature |
|
||||
|
||||
Model_name: THIS IS WHAT CHANGES
|
||||
method: guided IG
|
||||
composition: pure_white
|
||||
colormap: magma
|
||||
intensity: 0.75
|
||||
contrast: 1.5
|
||||
threshold: 0.25
|
||||
class_index: -1
|
||||
input_size: 224
|
||||
uses_smooth_grad: true
|
||||
snoothgrad_samples: 25
|
||||
---
|
||||
|
||||
### VGG16 and VGG19
|
||||
|
||||
## listed out
|
||||
Among the oldest and simplest networks still in use (2014). Deliberately minimal: stack many small 3×3 convolutional filters in sequence, going deeper and deeper, with max-pooling layers periodically halving spatial resolution. VGG16 has 16 layers with learned weights; VGG19 has 19. Both end with three large fully-connected layers that make the final classification decision.
|
||||
|
||||
Each convolutional layer detects increasingly abstract features — early layers find edges and color gradients, middle layers find textures and simple shapes, later layers find object parts. Because the architecture is purely sequential with no shortcuts, the network has to "look hard" at large regions to make decisions rather than pinpointing specific features. The result is the **largest, most spatially coarse attention patterns** of any model here — blunt, blocky, and aggressive. Good for a surveillance aesthetic.
|
||||
|
||||
cool
|
||||

|
||||
**vgg16** 
|
||||
|
||||
**vgg19** 
|
||||
|
||||
---
|
||||
|
||||
### ResNet50 and ResNet101
|
||||
|
||||
ResNets (2015) introduced the **residual connection**: instead of forcing every layer to learn a full transformation, each block learns only the *residual* — the difference between its input and desired output — and adds the original input back to the result. This allows gradients to flow much more cleanly through the network during training.
|
||||
|
||||
Because residual connections preserve information across layers more faithfully, saliency maps tend to reflect what the model actually uses to make its decision. Attention is **more distributed and semantically coherent** than VGG — multiple relevant regions rather than one dominant blob. Less visually aggressive, more structurally legible.
|
||||
|
||||
**resnet50** 
|
||||
|
||||
**resnet101** 
|
||||
|
||||
---
|
||||
|
||||
### DenseNet121
|
||||
|
||||
Where ResNet connects each block only to the next, DenseNet (2016) connects **every layer directly to every subsequent layer** in its dense block. The 121 refers to the total number of layers.
|
||||
|
||||
Because every layer receives feature maps from all previous layers, the network never discards information — early features like edges and color gradients remain directly accessible all the way through. Each layer has a "collective memory" of everything seen at every level of abstraction. This produces the **most distributed, multi-scale attention patterns**: low-level and high-level features highlighted simultaneously, overlapping at different scales. The result is diffuse and layered, almost painterly.
|
||||
|
||||
**densenet121** 
|
||||
|
||||
---
|
||||
|
||||
### InceptionV3
|
||||
|
||||
Inception (2015) introduced **parallel convolutions at multiple scales within a single layer**. Each inception module simultaneously applies 1×1, 3×3, and 5×5 convolutions plus max-pooling, then concatenates all outputs — the network learns which scale is useful for which features rather than committing to one. V3 adds factorized convolutions and batch normalization throughout.
|
||||
|
||||
Because features are detected at multiple scales simultaneously at every level, Inception can respond to both fine-grained texture and large structural shapes together. Attention maps can look **almost fractal** — broad regions of moderate attention with sharp peaks at specific features within them.
|
||||
|
||||
> Requires `input_size: 299` — it was trained at that resolution, giving slightly more spatial detail in output maps.
|
||||
|
||||
**inception_v3** 
|
||||
|
||||
---
|
||||
|
||||
### MobileNetV3 Large
|
||||
|
||||
Explicitly designed for smartphones and embedded devices (2019). Uses **depthwise separable convolutions** — splitting a standard convolution into a depthwise step (filters each channel independently) and a pointwise step (combines channels) — reducing computational cost by roughly 8–9×.
|
||||
|
||||
The aggressive compression forces the network to extract the most discriminative features with minimal computation, pruning everything that doesn't directly help classification. The result is the **sparsest, most minimal attention maps**: often fixating on a single small region because that's the cheapest path to a confident prediction. Conceptually interesting as commentary on algorithmic shortcuts — it's not trying to understand the image, just find the easiest distinguishing feature. The attention can feel almost arbitrary.
|
||||
|
||||
**mobilenet_v3_large** 
|
||||
|
||||
---
|
||||
|
||||
### What's Absent and Why
|
||||
|
||||
Transformer-based vision models (ViT, CLIP) were excluded because they use explicit attention heads rather than convolutions — their attention is already readable through other means, which would change the conceptual framing. This project is specifically about making the *implicit* computational gaze of convolutional networks visible, which is a different claim than reading the explicit attention weights of a transformer.
|
||||
|
After Width: | Height: | Size: 65 KiB |
|
After Width: | Height: | Size: 68 KiB |
|
After Width: | Height: | Size: 69 KiB |
|
After Width: | Height: | Size: 60 KiB |
|
After Width: | Height: | Size: 61 KiB |
|
After Width: | Height: | Size: 66 KiB |
|
After Width: | Height: | Size: 67 KiB |
@@ -0,0 +1,446 @@
|
||||
# Algorithmic Attention — Saliency Visualization Tool Documentation
|
||||
|
||||
This tool interrogates pretrained image classifiers using gradient-based saliency methods from Google's [PAIR saliency library](https://github.com/PAIR-code/saliency), exposing the hidden attentional logic of neural networks as visual artifacts. Built as a custom ComfyUI node set.
|
||||
|
||||
The core question it answers: *when a model classifies an image, which pixels drove that decision?*
|
||||
|
||||
---
|
||||
|
||||
## Table of Contents
|
||||
|
||||
1. [How It Works](#how-it-works)
|
||||
2. [Models](#models)
|
||||
3. [Methods](#methods)
|
||||
4. [Composition Modes](#composition-modes)
|
||||
5. [Colormaps](#colormaps)
|
||||
6. [Other Parameters](#other-parameters)
|
||||
|
||||
---
|
||||
|
||||
## How It Works
|
||||
|
||||
All eight supported models are **convolutional neural networks (CNNs)** trained on ImageNet — a dataset of 1.2 million images across 1,000 categories. The training process adjusts millions of numerical weights until the network can reliably distinguish between categories like "Labrador retriever," "espresso maker," and "kimono."
|
||||
|
||||
What makes them useful for saliency visualization is that they're all **differentiable** — built from mathematical operations (matrix multiplications, convolutions, activation functions), so you can calculate the derivative of the classification output with respect to any input pixel. That derivative is the gradient: *if I changed this pixel slightly, how much would the model's confidence change?* High gradient = the model is paying attention to that pixel.
|
||||
|
||||
The models differ in architecture, which changes not just their accuracy but the *character* of their attention — where they look, how diffuse or concentrated it is, how coarse or fine-grained.
|
||||
|
||||
---
|
||||
|
||||
## Models
|
||||
|
||||
The model is the "brain" being interrogated. Different architectures have different visual personalities.
|
||||
|
||||
> **Demo settings:** method: Guided IG · composition: pure_white · colormap: magma · intensity: 0.75 · contrast: 1.5 · threshold: 0.25 · class_index: -1 · input_size: 224 · use_smoothgrad: true · smoothgrad_samples: 25
|
||||
|
||||
**TLDR:** Coarse and blunt (VGG) → distributed and semantic (ResNet) → diffuse and layered (DenseNet) → multi-scale (Inception) → sparse and shortcut-prone (MobileNet/EfficientNet)
|
||||
|
||||
---
|
||||
|
||||
### VGG16 and VGG19
|
||||
|
||||
Among the oldest and simplest networks still in common use, developed at Oxford's Visual Geometry Group in 2014. The design is deliberately minimal: stack many small 3×3 convolutional filters in sequence, going deeper and deeper, with max-pooling layers periodically halving the spatial resolution. VGG16 has 16 layers with learned weights; VGG19 has 19. Both end with three large fully-connected layers that make the final classification decision.
|
||||
|
||||
Each convolutional layer detects increasingly abstract features — early layers find edges and color gradients, middle layers find textures and simple shapes, later layers find object parts. The fully-connected layers at the end combine everything into a single verdict. Because the architecture is purely sequential with no shortcuts, everything must compress through a bottleneck.
|
||||
|
||||
VGG models have the **largest, most spatially coarse attention patterns** of any model here. Because the architecture is old and inefficient, it has to "look hard" at large regions rather than pinpointing specific features. The saliency maps feel blunt, aggressive, and somewhat unpredictable — they often grab large swaths of the face, background, or contextual objects. This reads more like surveillance than recognition. VGG16 and VGG19 produce slightly different patterns because the extra three layers in VGG19 allow slightly more abstraction, but both share this coarseness.
|
||||
|
||||
*Parameter count: VGG16 — 138M · VGG19 — 144M. Famously inefficient for their accuracy.*
|
||||
|
||||
**VGG16**
|
||||

|
||||
|
||||
**VGG19**
|
||||

|
||||
|
||||
---
|
||||
|
||||
### ResNet50 and ResNet101
|
||||
|
||||
Developed at Microsoft Research in 2015. ResNets introduced the **residual connection** (skip connection): instead of forcing every layer to learn a full transformation, each block of layers learns only the *residual* — the difference between its input and desired output. The input is added back to the output before passing to the next block. This allows networks to be made much deeper without gradients vanishing during training.
|
||||
|
||||
The residual connections create a scaffold — information can skip over groups of layers and travel directly toward the output, meaning the network doesn't have to compress everything through every layer. ResNet50 has 50 layers organized into four stages of residual blocks; ResNet101 doubles the middle stages.
|
||||
|
||||
ResNets produce **more distributed, semantically coherent attention** than VGG. Because residual connections allow gradients to flow more cleanly, the saliency maps tend to reflect what the model actually uses to make its decision more faithfully. Attention looks more "considered" — multiple relevant regions rather than one dominant blob. The difference between ResNet50 and ResNet101 is subtle: the deeper model tends toward slightly more refined, higher-level attention.
|
||||
|
||||
*Parameter count: ResNet50 — 25M · ResNet101 — 44M. Far more efficient than VGG.*
|
||||
|
||||
**ResNet50**
|
||||

|
||||
|
||||
**ResNet101**
|
||||

|
||||
|
||||
---
|
||||
|
||||
### DenseNet121
|
||||
|
||||
Developed at Cornell in 2016. DenseNet takes the residual connection idea from ResNet and pushes it to an extreme: while ResNet connects each block only to the next, in DenseNet **every layer connects directly to every subsequent layer** in its dense block. The 121 refers to the total number of layers.
|
||||
|
||||
Because every layer receives feature maps from all previous layers, the network never discards information. Early features — edges, simple textures, color gradients — remain directly accessible all the way through the network. Each layer has access to a "collective memory" of everything seen at every previous level of abstraction. This is the opposite of VGG's progressive compression.
|
||||
|
||||
DenseNet produces the **most distributed, multi-scale attention patterns**. Because every layer draws on both low-level and high-level features simultaneously, saliency maps highlight many overlapping regions at different scales — fine texture details and large structural regions at the same time. The results are diffuse and layered, almost painterly.
|
||||
|
||||
*Parameter count: 8M.*
|
||||
|
||||
**DenseNet121**
|
||||

|
||||
|
||||
---
|
||||
|
||||
### InceptionV3
|
||||
|
||||
Developed at Google in 2015. Inception introduced **parallel convolutions at multiple scales within a single layer**. Each "inception module" simultaneously applies 1×1, 3×3, and 5×5 convolutions plus a max-pooling operation, then concatenates all the outputs. The network learns which scale is useful for which features rather than committing to one.
|
||||
|
||||
Because features are detected at multiple scales simultaneously throughout the network, Inception can respond to both fine-grained texture (small filters) and large structural shapes (large filters) at every level. The 1×1 convolutions act as dimensionality reduction to keep computation manageable. V3 adds factorized convolutions (replacing 5×5 with two sequential 3×3 filters for efficiency) and batch normalization throughout.
|
||||
|
||||
Inception produces **multi-scale attention that can look almost fractal** — fine and coarse detail highlighted simultaneously, with a layered quality: broad regions of moderate attention containing sharp peaks at specific features within them.
|
||||
|
||||
> **Note:** InceptionV3 requires `input_size: 299` instead of 224, because it was trained at that resolution. This produces slightly more spatial detail in the output.
|
||||
|
||||
*Parameter count: 23.8M.*
|
||||
|
||||
**InceptionV3**
|
||||

|
||||
|
||||
---
|
||||
|
||||
### MobileNetV3 Large
|
||||
|
||||
Developed at Google in 2017–2019, explicitly designed to run on smartphones and embedded devices with limited compute. It uses **depthwise separable convolutions** — splitting a standard convolution into two steps (a depthwise step that filters each channel separately, then a pointwise step that combines channels) — reducing computational cost by roughly 8–9×. V3 added neural architecture search (NAS) and squeeze-and-excitation blocks that explicitly learn which feature channels matter most.
|
||||
|
||||
The aggressive computational compression means MobileNet achieves classification using far fewer operations than any other model here. The network is forced to extract the most discriminative features with minimal computation, pruning everything that doesn't directly help.
|
||||
|
||||
MobileNet produces the **sparsest, most minimal attention maps**. It often fixates on a single small region — sometimes not the face itself, but a piece of clothing, a background element, or a texture patch — because that's the cheapest path to a confident classification. This makes it conceptually interesting as commentary on algorithmic shortcuts: it's not trying to "understand" the image, just find the easiest distinguishing feature. The attention can feel almost arbitrary, which is itself a statement.
|
||||
|
||||
*Parameter count: 5.5M.*
|
||||
|
||||
**MobileNetV3**
|
||||

|
||||
|
||||
---
|
||||
|
||||
### EfficientNet-B0
|
||||
|
||||
Developed at Google Brain in 2019. EfficientNet rethought how to scale neural networks — instead of independently making networks wider, deeper, or taking higher-resolution inputs, it scales all three dimensions together in a mathematically derived fixed ratio. B0 is the smallest model in the family (scaling up to B7).
|
||||
|
||||
EfficientNet uses MBConv blocks (mobile inverted bottleneck convolution, borrowed from MobileNet): each block expands channel count, applies depthwise convolution, then compresses back down. It also includes squeeze-and-excitation blocks that rescale feature channels by learned importance weights — a form of built-in attention to its own internal representations.
|
||||
|
||||
EfficientNet produces the most **surgically precise saliency maps**. Designed to maximize classification information per computation, its attention patterns are extremely sparse — it finds the minimum signal needed to make a decision and ignores everything else. For portraits, this often means isolating very specific facial features (an eye, a jawline segment) while essentially ignoring the rest. This is conceptually striking: it shows how little the machine needs to see to classify confidently.
|
||||
|
||||
*Parameter count: 5.3M — an order of magnitude smaller than VGG for comparable accuracy.*
|
||||
|
||||
---
|
||||
|
||||
### What's Absent and Why
|
||||
|
||||
Transformer-based vision models (ViT, CLIP) were excluded because they use explicit attention heads rather than convolutions, making gradient-based saliency methods less directly applicable — their attention is already readable through other means. This project is specifically about making the *implicit* computational gaze of convolutional networks visible, which is a different conceptual claim than reading explicit attention weights from a transformer.
|
||||
|
||||
---
|
||||
|
||||
## Methods
|
||||
|
||||
These are the mathematical techniques used to ask "what pixels mattered to this model's decision?" Each produces a fundamentally different visual character.
|
||||
|
||||
> **Demo settings:** model: vgg16 · composition: pure_white · colormap: magma · intensity: 0.75 · contrast: 1.5 · threshold: 0.25 · class_index: -1 · input_size: 224 · use_smoothgrad: true · smoothgrad_samples: 25
|
||||
|
||||
---
|
||||
|
||||
### Vanilla Gradients
|
||||
|
||||
The simplest approach: take the partial derivative of the classification output with respect to each input pixel. Fast and raw. The result is noisy — almost like static or grain — because it shows every pixel that had *any* influence at all, including spurious ones. Produces the most aggressive, chaotic, high-frequency visual results.
|
||||
|
||||

|
||||
|
||||
---
|
||||
|
||||
### SmoothGrad
|
||||
|
||||
Takes Vanilla Gradients but runs it many times with small random noise added to the image each time, then averages the results. The noise cancels out spurious gradients while stable signals reinforce, revealing more structurally reliable patterns. Visually smoother and more coherent than vanilla, but still texture-rich.
|
||||
|
||||
The `smoothgrad_samples` parameter controls how many noisy runs are averaged — more = smoother but proportionally slower.
|
||||
|
||||

|
||||
|
||||
---
|
||||
|
||||
### Integrated Gradients
|
||||
|
||||
Instead of computing gradients at only the input image, this traces a path from a blank black image to the actual image and accumulates gradients at every step along that path. This gives it strong theoretical grounding — it satisfies formal mathematical axioms about attribution (completeness, sensitivity, linearity). Produces clean, smooth maps that highlight semantically meaningful regions rather than just any active pixels.
|
||||
|
||||
The `ig_steps` parameter controls how many interpolation steps are taken — more steps = more accurate attribution but slower computation. This is usually the best starting method for portrait work.
|
||||
|
||||

|
||||
|
||||
---
|
||||
|
||||
### Blur IG
|
||||
|
||||
A variant of Integrated Gradients where instead of interpolating from a black image to the input, it interpolates from a *heavily blurred version* of the image to the sharp version. The difference in what's being integrated changes what gets attributed — this tends to produce maps concentrated on edges and structural transitions rather than color or texture. The results look more architectural — sharper outlines, less fill.
|
||||
|
||||

|
||||
|
||||
---
|
||||
|
||||
### Guided IG
|
||||
|
||||
Another IG variant that uses gradient information to choose a smarter integration path, concentrating steps where the gradients are largest rather than taking uniform steps. This produces sharper, higher-contrast attribution maps with more defined edges — it's spending its computational budget on the most informative parts of the integration. Often the most visually striking method for portraits.
|
||||
|
||||

|
||||
|
||||
---
|
||||
|
||||
### XRAI
|
||||
|
||||
A completely different approach. Instead of pixel-level gradient computation, XRAI segments the image into regions using an oversegmentation algorithm, then attributes importance to each region as a whole by measuring how much removing it changes the model's output. Produces a patchwork, segmented appearance — almost like stained glass or an irregular heat map. Very distinct aesthetic from gradient methods.
|
||||
|
||||
> **Note:** XRAI returns a 2D region map rather than a 3D gradient volume, so it is handled differently in the rendering pipeline. It is also slower than the gradient-based methods.
|
||||
|
||||

|
||||
|
||||
---
|
||||
|
||||
## Composition Modes
|
||||
|
||||
These control how the saliency map is composited back onto the original image. This is where the artistic and conceptual intent lives.
|
||||
|
||||
> **Demo settings:** model: vgg16 · method: Guided IG · colormap: magma · intensity: 0.75 · contrast: 1.5 · threshold: 0.25 · class_index: -1 · input_size: 224 · use_smoothgrad: true · smoothgrad_samples: 25
|
||||
|
||||
---
|
||||
|
||||
### isolation
|
||||
|
||||
The default and most conceptually pointed mode. Salient regions appear in full color using the chosen colormap; everything else converts to greyscale. The machine's gaze burns in color while what it ignores fades to grey — a direct visual statement about algorithmic attention and selective visibility.
|
||||
|
||||

|
||||
|
||||
---
|
||||
|
||||
### overlay
|
||||
|
||||
Classic heatmap blend. The colormap is alpha-composited over the original at the `intensity` level. Familiar and readable, but less subversive — the most conventional visualization approach.
|
||||
|
||||

|
||||
|
||||
---
|
||||
|
||||
### spotlight
|
||||
|
||||
Salient regions are bright; everything else darkens dramatically. Feels like a searchlight or surveillance camera — forensic, clinical, authoritarian.
|
||||
|
||||

|
||||
|
||||
---
|
||||
|
||||
### ghost
|
||||
|
||||
The original image fades to 25% opacity and the saliency map glows over it. The subject becomes spectral, haunted by its own classification. Good for uncanny or dissociative effects.
|
||||
|
||||

|
||||
|
||||
---
|
||||
|
||||
### invert
|
||||
|
||||
Shows what the algorithm *ignores* instead of what it sees. The saliency map is inverted before compositing. Conceptually the most subversive mode — it visualizes the blind spots, the parts of a face that are invisible to the machine.
|
||||
|
||||

|
||||
|
||||
---
|
||||
|
||||
### cutout
|
||||
|
||||
Hard binary mask. Pixels above the `threshold` value show the original image in full; everything below shows a dim version of the heatmap. Creates a stark graphic effect — the subject literally cut from the image by the algorithm's attention boundary.
|
||||
|
||||

|
||||
|
||||
---
|
||||
|
||||
### multiply
|
||||
|
||||
Photoshop-style multiply blend. Attention modulates brightness multiplicatively, dimming non-salient areas. Dark and moody — ignored regions sink into shadow.
|
||||
|
||||

|
||||
|
||||
---
|
||||
|
||||
### screen
|
||||
|
||||
Photoshop-style screen blend. Attention brightens salient regions. Lighter and more luminous than multiply — glowing rather than shadowed.
|
||||
|
||||

|
||||
|
||||
---
|
||||
|
||||
### triptych
|
||||
|
||||
Outputs three panels side by side: original image | saliency map alone | composite. Shows the full chain of the visualization in one frame. Designed for gallery or documentation contexts.
|
||||
|
||||

|
||||
|
||||
---
|
||||
|
||||
### mask_only
|
||||
|
||||
Just the colored saliency map with no original image. Pure algorithmic output — no human context, no original reference. The map exists alone.
|
||||
|
||||

|
||||
|
||||
---
|
||||
|
||||
### pure_white
|
||||
|
||||
Black background, saliency values mapped directly to white intensity. No color, no original — just the raw shape of what the algorithm attended to, like an x-ray or photogram. The contrast and threshold parameters still apply, making this mode range from soft and diffuse (low contrast, low threshold) to sparse and clinical (high contrast, high threshold).
|
||||
|
||||

|
||||
|
||||
---
|
||||
|
||||
## Colormaps
|
||||
|
||||
These apply a color gradient to the greyscale saliency values. Low values (less attended) map to one end of the gradient; high values (more attended) map to the other.
|
||||
|
||||
> **Demo settings:** model: vgg16 · method: Guided IG · composition: invert · intensity: 0.75 · contrast: 1.5 · threshold: 0.25 · class_index: -1 · input_size: 224 · use_smoothgrad: true · smoothgrad_samples: 25
|
||||
|
||||
---
|
||||
|
||||
| Colormap | Range | Character |
|
||||
|----------|-------|-----------|
|
||||
| **inferno** | Black → purple → orange → yellow | High contrast, dramatic. The default — feels urgent, slightly threatening |
|
||||
| **plasma** | Purple → pink → yellow | Vibrant and synthetic-looking, digital, almost neon |
|
||||
| **magma** | Black → deep purple → pink-white | Darker and moodier than inferno, more melancholic |
|
||||
| **viridis** | Purple → teal → yellow-green | Standard scientific colormap, perceptually uniform, readable but less dramatic |
|
||||
| **hot** | Black → red → orange → white | Classic heat vision / thermal camera aesthetic |
|
||||
| **cool** | Cyan → magenta | Cold, clinical, almost medical |
|
||||
| **spring** | Magenta → yellow | Neon, synthetic, maximally artificial |
|
||||
| **copper** | Black → brown → copper-gold | Metallic, archival, almost daguerreotype-like |
|
||||
| **twilight** | Purple → white → orange → purple (cyclical) | Smooth and atmospheric |
|
||||
| **ocean** | Black-blue → cyan → white | Deep and watery |
|
||||
|
||||
---
|
||||
|
||||
**cool**
|
||||

|
||||
|
||||
**hot**
|
||||

|
||||
|
||||
**copper**
|
||||

|
||||
|
||||
**inferno**
|
||||

|
||||
|
||||
**magma**
|
||||

|
||||
|
||||
**ocean**
|
||||

|
||||
|
||||
**plasma**
|
||||

|
||||
|
||||
**spring**
|
||||

|
||||
|
||||
**twilight**
|
||||

|
||||
|
||||
**viridis**
|
||||

|
||||
|
||||
---
|
||||
|
||||
## Other Parameters
|
||||
|
||||
> **Demo settings:** model: vgg16 · method: Guided IG · composition: invert · colormap: magma · class_index: -1 · input_size: 224
|
||||
|
||||
### Intensity
|
||||
|
||||
Controls how strongly the saliency visualization blends onto the original. 0 = invisible, 1 = full replacement. Most compositions look best between 0.6–0.85.
|
||||
|
||||
Default: **0.75** — chosen as the midpoint that preserves enough of the original image for readability while letting the saliency map dominate visually.
|
||||
|
||||
**intensity = 0.5** (lower)
|
||||

|
||||
|
||||
**intensity = 1.0** (higher / full)
|
||||

|
||||
|
||||
---
|
||||
|
||||
### Contrast (Gamma)
|
||||
|
||||
Applies a power function to the saliency values before visualization: `value^(1/contrast)`. Values above 1.0 compress the low end and expand the high end — the most salient regions pop while less important regions fade further. Cranking to 2.5–3.0 produces extreme, high-drama results where only the very top attention regions survive. Values below 1.0 flatten differences, making attention look more uniformly distributed.
|
||||
|
||||
Default: **1.5** — chosen to add drama without becoming so extreme that only a few pixels survive.
|
||||
|
||||
**contrast = 1.0** (flat, no adjustment)
|
||||

|
||||
|
||||
**contrast = 2.0** (more aggressive)
|
||||

|
||||
|
||||
---
|
||||
|
||||
### Threshold
|
||||
|
||||
Sets the minimum saliency value to be considered "attended to," used primarily by `isolation` and `cutout` modes. Higher values make the visualization sparser — only the regions the model is most confident about survive. At 0.0, everything is included; at 0.5, only the top half of saliency values show.
|
||||
|
||||
Default: **0.25** — chosen to eliminate low-confidence gradient noise while preserving the meaningful attended region.
|
||||
|
||||
**threshold = 0.0** (nothing filtered)
|
||||

|
||||
|
||||
**threshold = 0.5** (aggressive filtering)
|
||||

|
||||
|
||||
---
|
||||
|
||||
### Class Index
|
||||
|
||||
ImageNet has 1,000 classes. By default (`-1`), the node auto-detects the model's top prediction and visualizes attention for that class — the attention pattern for the question the model is actually answering.
|
||||
|
||||
You can override this to force visualization of a different class. For example, forcing class 207 (golden retriever) on a human portrait produces attention patterns for a question the model was never meant to answer — it looks for golden retriever features in a human face. This produces attention patterns that feel alien and misaligned, which has significant artistic implications: it makes visible the categorical violence of being misclassified, or the absurdity of applying animal classification to a human subject.
|
||||
|
||||
The classification label output of the node always shows what class is actually being visualized.
|
||||
|
||||
**class_index = 1** (a modest override)
|
||||

|
||||
|
||||
**class_index = 10** (a larger displacement)
|
||||

|
||||
|
||||
---
|
||||
|
||||
### Input Size
|
||||
|
||||
All these models were trained on fixed-size square inputs. 224×224 is standard for most models; InceptionV3 requires 299×299 because it was trained at that resolution. The image is resized to this before processing, so the output appears at that resolution. Changing this for non-Inception models produces undefined behavior and is not recommended.
|
||||
|
||||
Default: **224** — not adjusted in demos because most models require it.
|
||||
|
||||
---
|
||||
|
||||
### Use SmoothGrad
|
||||
|
||||
When enabled on top of any method (except SmoothGrad itself), applies the SmoothGrad noise-averaging process to smooth the result. Generally produces more aesthetically pleasing, less noisy outputs at the cost of being proportionally slower (it runs the full forward/backward pass `smoothgrad_samples` times).
|
||||
|
||||
Default: **true** — the aesthetic improvement is significant and the default sample count of 25 is fast enough for most use.
|
||||
|
||||
**use_smoothgrad = false**
|
||||

|
||||
|
||||
---
|
||||
|
||||
### Smoothgrad Samples
|
||||
|
||||
How many noisy samples to average when SmoothGrad is active. 25 is a good balance between smoothness and speed. 50+ produces noticeably smoother results but takes proportionally longer — on CPU with VGG16, 50 samples takes roughly twice as long as 25.
|
||||
|
||||
Default: **25**
|
||||
|
||||
**samples = 50**
|
||||

|
||||
|
||||
---
|
||||
|
||||
*Tool built with [PAIR Saliency](https://github.com/PAIR-code/saliency), [PyTorch](https://pytorch.org/), and [ComfyUI](https://github.com/comfyanonymous/ComfyUI).*
|
||||