Query Attack via Opposite-Direction Feature:Towards Robust Image Retrieval

Zhedong Zheng, Liang Zheng, Yi Yang, Fei Wu · DOI

Abstract

Most existing works of adversarial samples focus on attacking image recognition models, while little attention is paid to the image retrieval task. In this paper, we identify two inherent challenges in applying prevailing image recognition attack methods to image retrieval. First, image retrieval demands discriminative visual features, which is significantly different from the one-hot class prediction in image recognition. Second, due to the disjoint and potentially unrelated classes between the training and test set in image retrieval, predicting the query category from predefined training classes is not accurate and leads to a sub-optimal adversarial gradient. To address these limitations, we propose a new white-box attack approach, Opposite-Direction Feature Attack (ODFA), to generate adversarial queries. Opposite-Direction Feature Attack (ODFA) effectively exploits feature-level adversarial gradients and takes advantage of feature distance in the representation space. To our knowledge, we are among the early attempts to design an attack method specifically for image retrieval. When we deploy an attacked image as the query, the true matches are prone to receive low ranks. We demonstrate through extensive experiments that (1) only crafting adversarial queries is sufficient to fool the state-of-the-art retrieval systems; (2) the proposed attack method, ODFA, leads to a higher attack success rate than classification attack methods, validating the necessity of leveraging characteristics of image retrieval; (3) the adversarial queries generated by our method have good transferability to other retrieval models without accessing their parameters, i.e., the black-box setting.

The Challenge of Image Retrieval Attacks

Image retrieval is fundamentally different from image recognition. In recognition, a model maps an image to a fixed set of "one-hot" labels (e.g., "cat" or "dog"). In retrieval, the model extracts a high-dimensional feature vector (an embedding) and compares it to a database of other vectors to find the most similar matches.

Comparison of Image Recognition and Image Retrieval tasks. Retrieval systems often face "unseen" classes, complicating traditional label-based adversarial attacks.

The authors identify two major gaps in applying standard adversarial attacks (like FGSM) to retrieval:

  1. Feature vs. Label: Retrieval relies on discriminative visual features, not just final class predictions. Attacking the classifier layer doesn't necessarily disrupt the underlying feature representation used for matching.
  2. The "Unseen Class" Problem: Retrieval systems often operate in an "open-set" environment. For example, a model trained to recognize cars might be used to retrieve specific models of trucks. Traditional attacks rely on the model's ability to predict a class; if the query class is unknown to the model, the resulting adversarial gradient is noisy and sub-optimal.

Methodology: Opposite-Direction Feature Attack (ODFA)

The authors propose Opposite-Direction Feature Attack (ODFA), a white-box attack that bypasses the classification layer entirely to target the intermediate feature space.

Instead of trying to make an image look like a specific "wrong" class, ODFA aims to make the adversarial query's feature vector ($f_{X'}$) the polar opposite of the original query's vector ($f_X$). By forcing the feature to the opposite side of the hypersphere, the attack ensures that the "true matches" (which are clustered near the original feature) end up with the lowest possible similarity scores, effectively burying them at the bottom of the ranking list.

Geometric visualization of feature-level attacks on a hypersphere. ODFA (c) targets the polar opposite direction (-f) of the original feature vector to maximize retrieval failure.

Core Components

  • The Loss Function: They minimize a loss that forces the cosine similarity between the original and adversarial features toward -1. Mathematically, they minimize the squared sum of the normalized features: $J(X') = \|\frac{f_{X'}}{\|f_{X'}\|_2} + \frac{f_X}{\|f_X\|_2}\|^2$.
  • Iterative Optimization: They use an iterative approach to gradually update the image pixels while keeping the total perturbation human-imperceptible (constrained by an $\epsilon$ value).
  • ODFA-MS (Multi-Scale): To defeat robust retrieval systems that fuse features from multiple image scales, the authors extend their method to calculate and average gradients across different input sizes, ensuring the attack remains effective regardless of how the victim model resizes the query.

Experimental Evaluation

The authors evaluated ODFA across five diverse image retrieval datasets: Food-256, CUB-200-2011 (birds), Market-1501 (pedestrians), and Oxford5k/Paris6k (landmarks).

ODFA consistently outperformed traditional classification-based attacks across all benchmarks:

  • Performance Drop: On the Food-256 dataset, a clean model achieved 66.41% Recall@1. Under ODFA attack ($\epsilon=16$), this plummeted to just 3.71%.
  • Superiority over Class-Attacks: On Market-1501, the best classification-based attack only dropped Recall@1 to 4.87%, whereas ODFA crushed it down to 0.68%.
  • Black-Box Success: Adversarial queries crafted for a ResNet-50 model successfully fooled a DenseNet-121 model, reducing its performance on Market-1501 from ~90% to ~10%. This suggests that different retrieval models often learn similar feature manifolds.

Conclusion

By targeting the representation space directly, ODFA becomes agnostic to whether the model "knows" what the object is. This research highlights a significant vulnerability in current image retrieval systems. While the primary method is white-box, its high transferability poses a real-world threat to black-box systems. Future work may explore attacks on shallower layers or investigate how these feature-level attacks impact other computer vision tasks like semantic segmentation.

Summary updated

BibTeX
@misc{zheng2018query,
  author = {Zhedong Zheng and Liang Zheng and Yi Yang and Fei Wu},
  title = {{Query Attack via Opposite-Direction Feature:Towards Robust Image Retrieval}},
  year = {2018},
  eprint = {1809.02681},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1809.02681},
}
Figure