arXiv:2611.01962cs.CVNov 2026

Manuscript Offprint

arXiv:2611.01962

Object-Only Is Not Context-Free: A Counterfactual Diagnostic for Context Removal in Object Retrieval

Boaz Meivar, Shai Avidan

Abstract

Object-centric retrieval pipelines often mask the background before pooling backbone features, aiming for a descriptor that reflects the object rather than its scene. Whether this truly yields an object-only descriptor, however, is rarely tested. We introduce the Keyhole Aperture Probe (KAP), a counterfactual diagnostic that repurposes the ground-truth masks of existing panoptic segmentation datasets (COCO, ADE20K) for retrieval: it holds the pooled object region fixed and varies only the pixels outside it, summarizing a backbone's context dependence in a single number. We find that the pooled object region has already integrated its surround. Replacing the context, with a neutral fill or even a different real scene, changes the descriptor, and when retrieval fails under a blank fill, the descriptor matches plain-background images rather than its own object. Object-only is not context-free. Across ten modern backbones, object-only descriptors retain only about a quarter to two-thirds of their full-image accuracy, and the effect is not unique to Transformer self-attention: a convolutional backbone shows it too. The dependence is also reducible: a lightweight adapter that encourages the descriptor to stay stable as context is removed lowers it and improves full-image instance retrieval on INSTRE, transferring to ILIAS with accuracy improved or preserved. A matched contrastive-fine-tuning control does not reproduce those gains. We release KAP as a simple, backbone-agnostic evaluation protocol to measure and reduce this dependence before deployment.

1. Introduction

Object-level retrieval is routinely framed as an instance-isolation problem: obtain a mask, pool features inside it, and treat everything outside as nuisance. Yet modern foundation encoders are trained on full images and their co-occurrence structure [24, 36], so an “object descriptor” pooled from a masked region likely summarizes object plus context. Some leakage is expected, since attention and large receptive fields mix every token with its surround; what is missing is a measurement of how much, for which backbones, and through what mechanism. An object stripped to its mask can even retrieve the wrong category outright (Fig. 1). Context is informative for identity, location, and scale [30], but reliance on it induces shortcut behavior and background bias that fail under shift [10, 33]; for retrieval there is little controlled, at-scale evidence on which effect dominates or on what makes a backbone susceptible. Masking, moreover, does not so much remove context as replace it with a neutral fill, and we show (Sec. 4.2) that the encoder folds this fill back into the “object-only” descriptor.

We address this with a counterfactual measurement built on panoptic segmentation datasets [14, 19, 37], whose pixel-precise masks let us delineate an object exactly and intervene only on its surroundings: per query we hold fixed the object pixels, pooling region, database, and labels, and change only the pixels outside the mask, sweeping an expanding aperture (d=0, 5, ..., 50 px and full image), gray-filling outside it, while always pooling over the original undilated mask. This decouples what the encoder sees from what we pool. We summarize each backbone with one scalar, d0d_0/full: the fraction of full-image retrieval accuracy retained when only object pixels are visible. We call this protocol the Keyhole Aperture Probe (KAP); it reads out through nearest-neighbor retrieval, and the same ranking appears under a trained classifier (Sec. 4.3).

We apply KAP across ten diverse backbones and find that all show substantial context reliance. When a descriptor breaks, it drifts toward plain-background images rather than its own object; the effect is not specific to Transformer attention, and sharpest for small objects.

Why does this matter, if the full image is usually available? The sweep is a measurement instrument, and the cost it exposes bites in two deployment regimes. (i) Masking the query to obtain “object-specific” features (a masked-crop-then-encode step used ahead of frozen backbones in open-vocabulary pipelines [7, 18, 34]) implicitly assumes a matching masked gallery. Against a natural gallery the

Figure

Figure 1. How much context does an object descriptor need? A COCO donut query under an expanding visible aperture (gray fill), with DINOv2-G/14 top-1 retrievals. At d=0 (mask only) the top-1 is wrong (orange); as the aperture opens the match flips through cake to the correct donut. KAP reduces this dependence to one scalar; across ten backbones it varies widely and is not exclusive to ViT self-attention.

masked query is distribution-shifted and loses. (ii) Even with full images on both sides, a context-reliant descriptor matches on background, so the same object in a new scene retrieves poorly. The reliance is also reducible: an aperture-conditioned training signal yields features that improve full-image instance retrieval on INSTRE [32] (+3.6 to +11.9 mAP) and transfer to ILIAS [15], with a matched control ruling out generic contrastive fine-tuning as the cause. The rest of the paper measures this dependence, validates it as a diagnostic, traces its mechanism, and reduces it.

References (35)