Testing Deep Learning Models for Image Analysis Using Object-Relevant Metamorphic Relations

Yongqiang Tian, Shiqing Ma, Ming Wen, Yepang Liu, Shing-Chi Cheung, Xiangyu ZhangarXiv 2019

Abstract

Deep learning (DL) models for image analysis often achieve high accuracy by exploiting background context rather than identifying the target object. This paper presents a metamorphic testing framework that quantifies this "background bias" using two novel relations: Object-Preserving and Object-Removing. By calculating an Object-Relevancy Score, the authors demonstrate that a significant portion of "correct" predictions are based on irrelevant features, exposing vulnerabilities in state-of-the-art models.

Introduction: The Reliability Gap in Image Analysis

Deep Learning models have revolutionized image classification and object detection, yet they often operate as "black boxes." A critical concern is the model's reliance on object-irrelevant features—the background—rather than the object-relevant features of the target. For instance, a model might correctly classify a "wolf" primarily due to the presence of snow. While the prediction is technically correct, the underlying logic is fragile and unreliable. This "reliability gap" makes models susceptible to adversarial attacks and unexpected failures in novel environments.

Methodology: Metamorphic Testing Framework

To address this, the authors employ Metamorphic Testing, a technique designed for scenarios where a perfect test oracle is unavailable. Instead of verifying individual outputs, the framework examines the relationship between outputs of related inputs.

Overview of the metamorphic testing framework for image analysis.

The testing process involves three main stages:

  1. Feature Identification: Identifying the target object and background within an image using ground truth masks or bounding boxes.
  2. Test Construction: Generating mutated images based on specific relations.
  3. Result Validation: Comparing model outputs across original and mutated images to calculate an Object-Relevancy Score.

Object-Relevant Metamorphic Relations

The framework introduces two core Metamorphic Relations (MRs) to quantify model logic:

  • MR-1 (Object Preserving): The target object is maintained while the background is altered (e.g., blurred, grayscaled, or replaced). A robust model's prediction should remain stable.
  • MR-2 (Object Removing): The target object is removed, and the resulting "hole" is filled via inpainting. A model relying on the object should see a significant change in its prediction.
Examples of metamorphic relations: (a) original image, (b) object-preserving (MR-1), and (c) object-removing (MR-2).

By applying 38 different mutation operations, the authors calculate an Object-Relevancy Score. A low score indicates that the model is "cheating" by over-relying on background context.

Experimental Evaluation

The approach was evaluated on 20 state-of-the-art DL models (10 for classification, 10 for detection) using benchmarks including ImageNet, COCO, and Pascal VOC.

Key Findings

  • The Top-5 Illusion: Even when models are "correct" within their top-5 predictions, approximately 5.3% of classification and 8.5% of detection results were found to be problematic (background-reliant).
  • High Error Rates in Detection: In specific object detection models, the rate of problematic inferences reached as high as 29.1%.
  • Vulnerability to Attacks: The Object-Relevancy Score serves as a map for potential exploits. By targeting images with low relevancy scores, the authors achieved a 66.2% success rate in "image transplanting" attacks, nearly double the success of random selection (36.0%).
  • Category Bias: Certain categories, such as sports equipment (pucks, volleyballs), showed higher background reliance, likely due to the strong association between the object and its typical environment (e.g., a court or rink).

Conclusion and Future Work

This research moves beyond qualitative visualization tools by providing a quantitative metric for model reliability. While the method currently depends on ground truth data and may be affected by inpainting artifacts, it offers a powerful diagnostic for identifying "weak points" in DL logic. Future work aims to extend this framework to video analysis and medical imaging, and to utilize Object-Relevancy Scores to retrain models for improved robustness.

Summary updated

BibTeX
@misc{tian2019testing,
  author = {Yongqiang Tian and Shiqing Ma and Ming Wen and Yepang Liu and Shing-Chi Cheung and Xiangyu Zhang},
  title = {{Testing Deep Learning Models for Image Analysis Using Object-Relevant Metamorphic Relations}},
  year = {2019},
  eprint = {1909.03824},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1909.03824},
}
Figure