Abstract
Standard evaluation of computer vision models relies on independent and identically distributed (IID) datasets, which often fail to capture the "long-tail" of real-world scenarios. We present LANCE (Language-guided Counterfactual Images), an automated framework that stress-tests visual models by generating realistic counterfactual images—variations where a single semantic attribute is modified. By leveraging large language models (LLMs) to guide text-to-image diffusion, LANCE uncovers hidden vulnerabilities and class-level biases that traditional metrics overlook.
Introduction
The current paradigm for evaluating computer vision models typically involves testing on static benchmarks like ImageNet. While a high accuracy score on these datasets suggests robustness, it often masks a model's reliance on spurious correlations. For instance, a model might correctly identify a "dog sled" primarily because of the presence of snow, failing when the same sled is placed on grass or pulled by an atypical breed of dog.
To move beyond static evaluation, we need dynamic test suites capable of "poking" models with targeted interventions. LANCE addresses this need by providing a scalable, automated pipeline for generating counterfactual test cases that isolate specific semantic factors, such as background, object color, or domain.
The LANCE Framework
LANCE bridges the gap between high-level semantic concepts and low-level pixel manipulation through a three-step pipeline:
- Captioning: A pre-trained BLIP-2 model generates a descriptive caption for an existing test image, providing a textual baseline of the image's content.
- Language-guided Perturbation: An LLM (LLaMA-7B, fine-tuned via LoRA) suggests a single, realistic modification to the caption. These perturbations target five specific factors: Subject, Object, Background, Adjective, and Data Domain (e.g., transforming a photograph into a charcoal drawing).
- Counterfactual Image Generation: To translate the edited text back into a realistic image, LANCE employs a text-to-image diffusion model (Stable Diffusion). By utilizing prompt-to-prompt editing and null-text inversion, the framework ensures the new image remains structurally similar to the original, altering only the requested attribute.
By comparing a model's prediction on the original image versus the generated counterfactual, researchers can precisely measure the model's sensitivity to specific semantic changes.
Experimental Evaluation
The authors evaluated LANCE using several prominent architectures, including ResNet-50, ViT, ConvNext, and CLIP. The primary "base" for these tests was HardImageNet, a subset of 15 ImageNet classes known for their reliance on spurious features. From this, the authors produced the LANCE Test Set, a benchmark consisting of approximately 1,500 generated counterfactual images.
Key Results
- Universal Performance Drops: Every model tested exhibited a significant drop in accuracy when faced with LANCE-generated counterfactuals. For example, ResNet-50's top-1 accuracy fell by 5.8%, while CLIP—despite its massive pre-training—saw a drop of 8.0%.
- Quantifiable Uncertainty: Beyond simple accuracy, the authors measured the drop in confidence ($\Delta p$). The results showed that models become significantly more uncertain when semantic interventions are introduced, even if they technically maintain the correct classification.
- Human Validation: To ensure the performance drops were due to model failure rather than poor image quality, a human study was conducted. Participants rated the generated images highly for realism (4.2/5) and "edit success" (3.7/5), confirming that the counterfactuals were semantically valid.
Insights into Model Bias
LANCE's automated nature allows for the discovery of systematic class-level biases. One of the most significant findings was that background changes caused the most drastic performance declines across all models. This suggests that state-of-the-art vision models remain heavily dependent on environmental context rather than the primary object of interest.
Furthermore, LANCE revealed specific breed-based biases. In the "dog sled" category, models were significantly less confident when the dogs were changed from standard breeds like Huskies or Malamutes to other breeds, even when the sled and harness remained clearly visible. This highlights how models internalize the narrow distributions found in training data.
Limitations and Future Directions
While LANCE provides a powerful tool for stress-testing, it is subject to the limitations of its underlying components. As a generative framework, it can inherit the biases of Stable Diffusion; for instance, changing a "woman" to an "athlete" might inadvertently alter perceived race or body type based on the generator's training data. Additionally, the LLM may occasionally suggest physically impossible or nonsensical edits (e.g., a "purple howler monkey") that do not provide meaningful insights into real-world robustness.
Future work involves using LANCE-generated counterfactuals for bias mitigation. By incorporating these targeted variations into the training process as data augmentation, researchers may be able to develop models that are more robust to the vulnerabilities LANCE uncovers.
Summary updated