Controlled Caption Generation for Images Through Adversarial Attacks

Nayyer Aafaq, Naveed Akhtar, Wei Liu, Mubarak Shah, Ajmal MianarXiv 2021

TL;DR

This paper introduces a novel GAN-based method to generate adversarial examples for image captioning systems by attacking the internal layers of the visual encoder. This approach successfully fools captioning models into generating incorrect captions, even without knowledge of the language model, and demonstrates high transferability across different models.

What Problem Does This Paper Address?

Image captioning systems, which combine visual understanding (CNNs) with language generation (RNNs), are increasingly important but also vulnerable to adversarial attacks. While adversarial attacks on image classification are well-studied, their application to image captioning is less explored. Existing methods often require full knowledge of the captioning model's objective function or attack only the classification layer of the visual encoder, which is less effective. This paper addresses the challenge of creating effective adversarial attacks on image captioning systems, specifically by targeting the internal representations of the visual encoder, which is a crucial component feeding into the language generation part. The goal is to generate adversarial images that cause the system to produce incorrect captions, even when the attack has limited information about the captioning model itself.

Methods

The core of the proposed method is a Generative Adversarial Network (GAN) designed to craft adversarial perturbations for input images. Instead of directly manipulating pixels to fool a classifier, this GAN aims to alter the internal representation of the visual encoder (specifically, a chosen hidden layer) to match that of a target image.

Here's a breakdown:

  • Generator: Takes a random noise vector and learns to produce a perturbation. This perturbation is then added to a source image.
  • Discriminator: A pre-trained CNN (acting as the visual encoder) is used. It receives both the perturbed source image and a target image and extracts features from a specific hidden layer. The goal is for the perturbed source image to produce feature representations similar to the target image's features at that layer.
  • Loss Functions:
    • Discriminator Loss: Encourages the discriminator to output similar feature representations for the perturbed source image and the target image at the chosen layer. This is formulated as a squared Euclidean distance between these feature vectors.
  • Generator Loss: Aims to minimize the difference between the generated perturbation and the target perturbation, encouraging the generator to produce effective adversarial examples.
  • Attack Strategy: The attack manipulates the internal features of the visual encoder. This is significant because the RNN (language model) relies on these internal features, not just the final classification output. By controlling these intermediate representations, the authors can influence the generated caption without needing to know the RNN's specific objective function. This is termed a "gray-box" attack, as it only requires knowledge of the visual encoder's architecture and internal layers.

Datasets

The experiments were conducted using the Microsoft COCO 2014 (MS COCO) dataset, a standard benchmark for image captioning. The dataset was split into training, validation, and test sets. For generator training, a subset of images was further split based on classes to ensure sufficient examples for generator learning.

Key Insights and Ideas

  • Attacking Internal Representations is Key: The most significant insight is that attacking the internal hidden layers of the visual encoder is far more effective for fooling image captioning systems than attacking the final classification layer. This is because the language model directly uses these internal features.
  • Gray-Box Attack Feasibility: The proposed method demonstrates that effective adversarial attacks on image captioning can be achieved without full knowledge of the language model, making it a practical "gray-box" attack. This is a crucial step towards understanding and improving the robustness of these systems.
  • Transferability of Attacks: The adversarial examples generated are highly transferable, meaning they can fool different image captioning models (e.g., Show-and-Tell and Show-Attend-and-Tell) even if those models have different architectures.
  • Keyword Preservation in Failed Attacks: Even when an attack doesn't result in an exact match for the target caption, the predicted captions often retain keywords from the target, suggesting that the attack subtly influences the semantic content rather than completely disrupting it.
  • Internal Layer Size Insignificance: The size of the LSTM's hidden state in the captioning framework does not significantly impact the success rate of the adversarial attacks, suggesting that the vulnerability lies more in the visual encoder's representations.

Key Results

  • High Attack Success Rates: The proposed method achieved high success rates in fooling image captioning models. For instance, using the METEOR metric with a threshold of τ=0.25, attack success rates reached up to 95.3% on the Show-and-Tell model and 81.5% on the Show-Attend-and-Tell model.
  • Superior to Previous Methods: Compared to the "Show and Fool" method, which also attacks the visual encoder but uses different techniques, the proposed GAN-based approach achieved significantly higher accuracy (e.g., 66.7% vs. 34.5% for I-FGSM based attack).
  • Keyword Retention: In cases where exact caption matches failed, the attack still managed to include target keywords in the predicted captions with high accuracy (e.g., 90.7% for 3 keywords).
  • Model Performance Degradation: The adversarial attacks consistently degraded the performance of both tested captioning models across various evaluation metrics (BLEU, METEOR, CIDEr, ROUGE, SPICE) as the perturbation strength (ε) increased.

Limitations and Future Work

  • Computational Cost: While the method is effective, training GANs can be computationally intensive.
  • "Exact Match" as a Metric: The authors acknowledge that "exact match" is a strict criterion for captioning, as multiple captions can be semantically correct for an image. They propose METEOR as a more robust metric.
  • Future Work: The paper suggests exploring more sophisticated attack strategies, investigating defenses against such attacks, and extending the research to other vision-language tasks. The authors also highlight the need for further research into the internal mechanisms of these complex models to build more robust systems.

Summary updated

BibTeX
@misc{aafaq2021controlled,
  author = {Nayyer Aafaq and Naveed Akhtar and Wei Liu and Mubarak Shah and Ajmal Mian},
  title = {{Controlled Caption Generation for Images Through Adversarial Attacks}},
  year = {2021},
  eprint = {2107.03050},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2107.03050},
}
Figure