Contra-Saliency

A portrait booth that distorts whatever a vision model finds most important.

The booth through its four filters, computed with the project’s own saliency and distortion code.
Role
UI Designer & Software Developer
Team
Selina Zhou, Cassie Cai
Timeline
Spring 2026
Type
  • Interactive Installation
  • UI/UX
  • Computer Vision
Tools
  • Python
  • OpenCV
  • PyTorch
  • Rhino
  • Enscape

Overview

Contra-Saliency is a photo booth that reads you the way a vision model would, then breaks the picture where the model looks hardest. A saliency map runs on the live webcam feed. The code finds the regions it ranks highest and warps them. Each visitor leaves with a strip of four frames: their portrait, and three ways a machine weighs it.

Course
SCI 6513, AI and the Physical Imaginary. Harvard GSD, Spring 2026.
My role
Designed the booth interface. Developed its software with Selina Zhou.
We made
A working photo booth: saliency code, a four-step interface, a built enclosure.

Research question

Is a salient region robust evidence, or simply a convenient cue?

The Idea

Saliency maps are built to explain. Laid over an image, a heatmap shows which pixels a model leaned on. Research on shortcut learning shows how little that lean can mean. A classifier can label a cow correctly because of the grass behind it, then fail when the same cow stands on a beach. It was right for the wrong reason.

We gave the map a different job. In the booth, saliency doesn’t report where the machine looks; it decides what happens to the picture. Whatever the code marks as most important is what bulges, smears or breaks apart. If the hierarchy were sound, the face would take the damage. Usually it doesn’t. A cap brim, a phone, a leaf or the edge of a monitor outranks the person in front of the lens, and the portrait shows, in our words from the review, “the instability of the hierarchy it depends on.”

Early Test

Before the booth, we tested the method on a building. We ran a classifier and its saliency maps on photographs of the Institute of Contemporary Art in Boston to see which parts of a building the model actually leans on. The answer set up the rest of the project: the evidence rarely sat where a designer would put it.

Ask a classifier where it looked

A ResNet-50 pretrained on ImageNet classifies each photo. Grad-CAM takes the gradient of the top class with respect to the network’s last convolutional block and uses it to weight that block’s feature maps. The result is a coarse 7 × 7 map of evidence, upsampled to the 224-pixel input. We saved it as a transparent PNG, with everything under 10% cut, so it could work as a mask.

weights = ResNet50_Weights.DEFAULT
model = resnet50(weights=weights)
model.eval()
# …
target_layers = [model.layer4[-1]]

with torch.no_grad():
    logits = model(input_tensor)
pred_class = int(torch.argmax(logits, dim=1).item())

cam = GradCAM(model=model, target_layers=target_layers)
grayscale_cam = cam(input_tensor=input_tensor,
                    targets=[ClassifierOutputTarget(pred_class)])[0]  # (224, 224)
# …
alpha_channel = (grayscale_cam * 255).astype(np.uint8)
alpha_channel[grayscale_cam < 0.1] = 0
Three panels: a photo of the ICA from the harbor, the cropped model input, and a heatmap overlay hottest under the cantilever
Three panels of the ICA from the street side, with the heatmap concentrated on the lower glazed facade
Three panels of the ICA at dusk, with the heatmap on the underside of the cantilever
Three panels of the ICA's corner, with the heatmap on the glass below the overhang

Grad-CAM on four views of the ICA: original, model input, overlay. The evidence pools under the cantilever and in the glazing, not along the silhouette.

Thresholded, the maps double as masks: keep what the model leaned on, wash out the rest. What survives is a building as the classifier sees it.

Photo of the ICA washed to white except for the region the heatmap marked, under the cantilever
A second ICA view washed to white except for its salient region

The maps as masks: salient regions kept, the rest washed out.

The Booth

The booth had to make a computer-vision pipeline readable to someone walking in off a gallery floor. I designed the interface as a short, fixed sequence. An overview introduces the three filters first. Then the visitor holds one pose for four captures, one per filter, and leaves with a strip, like any photo booth.

Live demo
  1. 1Start the booth
  2. 2Capture all four filters
  3. 3Print your strip
Open full screen ↗
Rebuilt for this page. The interface follows the booth’s; the image processing is a JavaScript port of our Python, so maps and hotspots behave like the installation’s but won’t match it pixel for pixel.

Decisions

  1. One pose, four readings

    Every capture is the same moment, so the only thing that changes along the strip is the interpretation.

  2. Numbers before heat

    Pixel Vision sits between the photo and the heatmap. Seeing yourself as luminance values first makes the heatmap read as arithmetic, not judgment.

  3. Keep the evidence visible

    In Perturbation, every warped region keeps its circle and center point, so each distortion traces back to the map that caused it.

Each filter has a color, a short code name and one plain sentence. The colors carry through the progress bar, the shot list and the controls, so a visitor always knows which reading they are in. Each filter has one or two parameters: block size, heatmap intensity, distortion strength and mode.

Dark interface titled How the machine interprets you, with four cards: Original (raw feed), Pixel Vision (pixel grid), Saliency Heatmap (attention map) and Perturbation (subvert), each with a short description
Step 01: the filter overview.
Booth interface showing the raw camera view of a gallery with tables, chairs and screens; a sidebar lists the four filters and a green Capture button
The same view as a grid of gray blocks, each labeled with its luminance value
The same view tinted blue by a saliency heatmap, with red and yellow patches on a table edge and ceiling lights
The same view warped around a hotspot on the table edge, which stretches into a bright starburst

The booth running in the gallery: raw feed, Pixel Vision, Saliency Heatmap and Perturbation, with the shot list and controls on the right.

The Code

Selina and I wrote the booth’s software together: one short Python script built on OpenCV. For every webcam frame it does three things: maps saliency, picks the hotspots, and warps the image around them. Then it shows its working.

Map what stands out

Each frame is resized to 640 × 480 and passed to OpenCV’s spectral residual detector. It shrinks the image, takes its Fourier transform and keeps only what the spectrum has that a smoothed copy of it doesn’t: statistical surprise. It runs in real time and knows nothing about faces or objects. The map comes back as values from 0 to 1, scaled here to 0–255.

saliency = cv2.saliency.StaticSaliencySpectralResidual_create()
# …
frame_small = cv2.resize(frame, (640, 480))

ok, saliency_map = saliency.computeSaliency(frame_small)
if not ok:
    print("Saliency computation failed")
    break

saliency_u8 = (saliency_map * 255).astype("uint8")
hotspots = find_salient_hotspots(saliency_u8, max_regions=4)
First test, March 2026, with Selina demoing: webcam, saliency map, binary regions and heatmap overlay. The phone outranks the face.

Keep only the strongest regions

The map is blurred and cut at its own 88th percentile, so the top eighth of the frame always counts as salient, whatever is in it. A 5 × 5 opening and closing removes specks and fills holes. The four largest regions become hotspots: a center from image moments, and a radius from the area of an equal circle, clamped between 18 and 90 pixels to keep the warp stable.

def find_salient_hotspots(saliency_map_u8, max_regions=4):
    blur = cv2.GaussianBlur(saliency_map_u8, (11, 11), 0)

    # Keep only the strongest saliency values.
    thresh_val = int(np.percentile(blur, 88))
    thresh_val = max(40, min(240, thresh_val))
    _, mask = cv2.threshold(blur, thresh_val, 255, cv2.THRESH_BINARY)

    kernel = np.ones((5, 5), np.uint8)
    mask = cv2.morphologyEx(mask, cv2.MORPH_OPEN, kernel, iterations=1)
    mask = cv2.morphologyEx(mask, cv2.MORPH_CLOSE, kernel, iterations=1)

    contours, _ = cv2.findContours(mask, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
    # …
    for cnt in contours[:max_regions]:
        m = cv2.moments(cnt)
        cx = int(m["m10"] / m["m00"])
        cy = int(m["m01"] / m["m00"])
        radius = int(np.clip(int(np.sqrt(area / np.pi)), 18, 90))
        hotspots.append((cx, cy, radius))

Warp the frame around each hotspot

The distortion is a displacement map. Each hotspot spreads a Gaussian influence with σ = 1.25 × its radius. In bulge mode, every sample point is pushed outward along the line from the center, by up to strength × radius pixels. cv2.remap then resamples the whole frame through the finished map in one pass.

grid_x, grid_y = np.meshgrid(
    np.arange(w, dtype=np.float32), np.arange(h, dtype=np.float32)
)
map_x, map_y = grid_x.copy(), grid_y.copy()

for cx, cy, radius in hotspots:
    dx = map_x - float(cx)
    dy = map_y - float(cy)
    dist = np.sqrt(dx * dx + dy * dy) + 1e-6

    sigma = max(8.0, radius * 1.25)
    influence = np.exp(-0.5 * (dist / sigma) ** 2)

    if mode in ("bulge", "pinch"):
        sign = 1.0 if mode == "bulge" else -1.0
        displacement = sign * distortion_strength * radius * influence
        map_x += (dx / dist) * displacement
        map_y += (dy / dist) * displacement
    # …

warped = cv2.remap(frame_bgr, map_x, map_y,
                   interpolation=cv2.INTER_LINEAR, borderMode=cv2.BORDER_REFLECT)

Six ways to misread

The same hotspots drive five more modes, switched from the keyboard during a session. Pinch reverses the bulge. Shear slides pixels sideways in proportion to their height above the center. Smear drags them horizontally, like motion blur. Pixelate snaps them to a block grid. Shockwave sends a ring outward on a sine wave, so the image keeps pulsing even when the sitter holds still.

elif mode == "shear":
    shear_amt = distortion_strength * 0.55
    map_x += shear_amt * dy * influence
    map_y += 0.15 * shear_amt * dx * influence

elif mode == "smear":
    local = np.clip(1.0 - dist / (radius * 2.2 + 1e-6), 0.0, 1.0)
    drag = distortion_strength * radius * 2.0 * (local**2)
    map_x += drag
    map_y += 0.25 * drag * (dy / dist)

elif mode == "pixelate":
    block = max(3, int(4 + distortion_strength * 18))
    local_mask = influence > 0.25
    qx = np.floor((map_x - float(cx)) / block) * block + float(cx) + block * 0.5
    qy = np.floor((map_y - float(cy)) / block) * block + float(cy) + block * 0.5
    map_x = np.where(local_mask, qx, map_x)
    map_y = np.where(local_mask, qy, map_y)

elif mode == "shockwave":
    phase = frame_index * 0.32
    wave_r = radius * (0.35 + 1.9 * ((np.sin(phase) + 1.0) * 0.5))
    band = max(2.0, radius * 0.2)
    ring = np.exp(-0.5 * ((dist - wave_r) / band) ** 2)
    # …

Show the working

The preview never hides how it decided. The warped frame is blended 75/25 with the heatmap, and each hotspot is drawn as a white circle with a center point. The sitter sees exactly which part of the frame the machine chose, and how far off that choice can be.

heatmap = cv2.applyColorMap(saliency_u8, cv2.COLORMAP_JET)
preview = cv2.addWeighted(distorted, 0.75, heatmap, 0.25, 0)

for cx, cy, radius in hotspots:
    cv2.circle(preview, (cx, cy), radius, (255, 255, 255), 1)
    cv2.circle(preview, (cx, cy), 3, (255, 255, 255), -1)
Webcam window titled Saliency-Driven Effects (with Collage): two faces with square patches of other parts of the frame pasted over them, and four circled hotspots

Left: bulge at strength 1.25 on two sitters. The hotspots favor edges: a cap brim, a hairline, a collar. Right: a later test with a collage mode that scatters salient patches across the frame.

The Installation

The booth is an open frame of white posts holding a monitor, a webcam, a light, a controller and a photo printer, wrapped in clear plastic and surrounded by plants. The plants are there on purpose. In “How Not to Be Seen”, Hito Steyerl hides bodies in plain sight with a green screen. Our version is living: a dense, high-frequency backdrop that competes with the sitter for the machine’s attention, and often wins.

Rendering of the booth: an open white frame with a green screen, a sitter on a bench facing a monitor and webcam, a lamp on a tripod, a cart with a laptop, and cacti, ferns and rocks around it
The booth, rendered in Enscape.
Close-up rendering of the booth labeled webcam, monitor, lighting, controller and photo printer
Axonometric drawing of a platform with curtains on a curved rail, lamps on stands and a figure standing in the middle

Left: equipment. Right: an early proposal with projection curtains and a ring of cameras.

The built booth: plastic sheeting, plants and the live screens.

Outcome

In our tests and at the show, the code rarely chose a face first. It chose cap brims, phone screens, leaves, table edges and glare on a monitor. Spectral residual saliency measures surprise in an image’s statistics, not importance to the person in it. Our early Grad-CAM test on the ICA showed the same gap: the evidence sat under the cantilever and in the glass, not in the silhouette the architects drew.

Used as a control signal instead of an explanation, saliency makes that gap visible. The strip is the record: one honest photo, then three frames that show where the machine’s attention actually went.