CLAD: Contrastive Learning for Background Debiasing

CNNs learn to cheat by leaning on backgrounds rather than the objects themselves. CLAD fixes this with a targeted contrastive objective, achieving state-of-the-art results on the Background Challenge benchmark.

BMVC 2022 Paper

The Problem: CNNs That Cheat on Backgrounds

Despite achieving superhuman performance on many benchmarks, CNNs don't see images the way humans do. They routinely exploit backgrounds and textures as shortcuts: a wolf classifier that fires because it sees snow, not the animal. This means excellent accuracy on standard test sets can mask a model that will fail catastrophically when the background distribution shifts.

The Background Challenge (ImageNet-9) was designed to expose exactly this: models trained normally show dramatic accuracy drops when objects are placed on completely random backgrounds (MIXED-RAND), even though the foreground hasn't changed at all.

CLAD feature space: robust to background, sensitive to foreground

CLAD learns a feature space that stays consistent across background changes while remaining sensitive to foreground object differences.

Method: Background-Debiased Contrastive Pairs

Standard contrastive learning doesn't help here: conventional positive pairs share the same background, so minimising their distance actually reinforces background bias. CLAD flips this logic with a purpose-built sampling strategy:

  1. Foreground extraction: Use GrabCut (or U²-Net for scalability) to segment the object from its background.
  2. Positive pairs: Take the same foreground and place it on a different-class background. Same object, different context → model must ignore the background to recognise them as equivalent.
  3. Negative pairs: Different foreground objects placed on similar-class backgrounds, pulled from a memory-efficient dictionary queue. Same background, different object → model must use foreground to distinguish them.
  4. Training objective: Combine standard cross-entropy (Lclass) with InfoNCE contrastive loss (Lcon), weighted by λ. CLAD+ optionally adds classification loss on the positive samples too.
Contrastive pair sampling: conventional vs CLAD's background-debiased strategy

Left: conventional contrastive learning preserves background in positive pairs. Right: CLAD's strategy: same foreground, different background for positives; different foreground, same background for negatives.

Full CLAD training pipeline

The full training pipeline: for each batch, positive samples are generated via background swapping, used to update the negative dictionary, and the combined loss is computed over anchor, positive, and negative features.

Results

Evaluated on the Background Challenge (ImageNet-9), CLAD and CLAD+ set a new state of the art, with almost no accuracy trade-off on original, unmodified images.

+4.1%
CLAD+ on MIXED-RAND vs prior SOTA
1.2
BG-GAP (CLAD+), lowest of all methods
<0.5%
Accuracy drop on original images
96.9%
Decision consistency (CLAD+) after bg swap
Model ORIGINAL ↑ ONLY-FG ↑ MIXED-RAND ↑ MIXED-SAME ↑ BG-GAP ↓
Base (IN9) 96.0 86.0 73.4 87.5 14.1
Base (MR) 88.4 89.5 86.7 87.1 0.4
MoCo-v2 (BG Swaps) 95.2 87.5 85.2 89.6 4.4
BYOL (BG Random) 96.1 88.3 85.2 90.2 5.0
CLAD (ours) 95.9 93.8 87.5 90.1 2.6
CLAD+ (ours) 95.6 94.6 89.3 90.5 1.2

Accuracy (%) on Background Challenge variants. BG-GAP = MIXED-SAME − MIXED-RAND; lower means less background bias.

65 65 70 70 75 75 80 80 85 85 90 90 no background bias Base (IN) Base (IN9) Base (MR) CIM SCL_E2E CIM+VIB SupCon+ShapeAug MoCo-v2 BYOL SwAV AttMask-High MoCov2+GT BYOL+GT DILEMMA CLAD+ CLAD Mixed-Same accuracy (%) Mixed-Rand accuracy (%)

Models closer to the identity line have lower background bias. CLAD and CLAD+ sit furthest right and closest to the line: high accuracy on both splits.

Analysis

Saliency Maps

SmoothGrad saliency maps make the improvement visually clear. Baseline models (Base-IN9 and Base-MR) highlight background regions, notably the snow behind a wolf. CLAD and CLAD+ focus tightly on the animal itself, even in cluttered scenes.

Saliency maps: CLAD focuses on foreground vs baselines attending to background

SmoothGrad saliency maps across four models. CLAD+ and CLAD produce cleaner, foreground-focused maps. The wolf/snow example (row 2) is a classic CNN background bias failure: only CLAD correctly attends to the animal.

Feature & Decision Consistency

CLAD+ achieves 92.0% feature similarity and 96.9% decision consistency between original and background-swapped image pairs, meaning the model extracts nearly the same features regardless of what's behind the object. Baselines sit 10–17 points lower on both metrics.

Contrastive Loss Weight (λ) Ablation

Ablation of lambda: MIXED-RAND improves while ORIGINAL stays stable up to λ=1

As λ increases from 0 to 1, MIXED-RAND accuracy improves while ORIGINAL accuracy stays flat. Beyond λ=1, the contrastive term dominates and performance on clean images degrades. The sweet spot is λ=1.

Generalising to Texture Bias

CLAD's framework is not specific to background. By swapping the contrastive construction to use texture (via AdaIN style transfer) instead of background, the same approach reduces texture bias, improving accuracy on Stylized ImageNet-9 and ImageNet-9-Sketch by ~20% over the standard baseline, with no drop on original images. Background debiasing alone does not fully transfer to texture, and vice versa: each bias requires its own targeted contrastive pairs.

Takeaways