Skip to main content
QUICK REVIEW

[Paper Review] ZeroCap: Zero-Shot Image-to-Text Generation for Visual-Semantic Arithmetic

Yoad Tewel, Yoav Shalev|arXiv (Cornell University)|Nov 29, 2021
Multimodal Machine Learning ApplicationsComputer Science6 citations
TL;DR

ZeroCap proposes a zero-shot image-to-text generation method that combines CLIP's visual-semantic embedding with a pre-trained language model (GPT-2) to generate diverse, semantically grounded captions without any fine-tuning. By leveraging the semantic alignment of CLIP and the generative capacity of GPT-2, it enables novel visual-semantic arithmetic, such as image-based analogies and comparisons, achieving state-of-the-art performance on visual relation benchmarks while maintaining high semantic fidelity.

ABSTRACT

Recent text-to-image matching models apply contrastive learning to large corpora of uncurated pairs of images and sentences. While such models can provide a powerful score for matching and subsequent zero-shot tasks, they are not capable of generating caption given an image. In this work, we repurpose such models to generate a descriptive text given an image at inference time, without any further training or tuning steps. This is done by combining the visual-semantic model with a large language model, benefiting from the knowledge in both web-scale models. The resulting captions are much less restrictive than those obtained by supervised captioning methods. Moreover, as a zero-shot learning method, it is extremely flexible and we demonstrate its ability to perform image arithmetic in which the inputs can be either images or text, and the output is a sentence. This enables novel high-level vision capabilities such as comparing two images or solving visual analogy tests. Our code is available at: https://github.com/YoadTew/zero-shot-image-to-text.

Motivation & Objective

  • To enable zero-shot image captioning without any fine-tuning or model retraining.
  • To overcome the limitations of supervised captioning models that produce scripted, constrained captions by leveraging web-scale pre-trained models.
  • To enable visual-semantic arithmetic, allowing operations like image-based analogies and comparisons.
  • To generate captions that reflect real-world knowledge and semantic diversity beyond human-annotated datasets.
  • To demonstrate that combining CLIP and a language model enables high-level vision capabilities such as image analogy solving.

Proposed method

  • The method combines CLIP's vision and text encoders with GPT-2's autoregressive language generation to produce image captions at inference time.
  • It modifies the key-value pairs of GPT-2's attention mechanism across all layers and heads during decoding to align generated tokens with CLIP's visual-semantic embedding space.
  • The caption generation process is entirely zero-shot, relying only on the pre-trained weights of CLIP and GPT-2 without any parameter updates.
  • The approach enables multi-modal arithmetic by treating images and text as vectors in a shared CLIP embedding space, allowing operations like 'A is to B as C is to X'.
  • It uses CLIP-score as a key evaluation metric to assess semantic alignment between generated captions and input images.
  • The method supports both image-to-text and text-to-image arithmetic, such as transforming a daytime image into a nighttime version using textual prompts.
Figure 1 : Our novel captioning method ZeroCap exhibits real-world knowledge, generates text that is more diverse and less scripted than existing methods, can address the written content of an image, and can perform visual-semantic arithmetic.
Figure 1 : Our novel captioning method ZeroCap exhibits real-world knowledge, generates text that is more diverse and less scripted than existing methods, can address the written content of an image, and can perform visual-semantic arithmetic.

Experimental results

Research questions

  • RQ1Can a zero-shot method generate diverse, semantically rich captions without any fine-tuning on image-caption datasets?
  • RQ2Can visual-semantic arithmetic be performed using only pre-trained models, enabling tasks like image analogy solving?
  • RQ3How does the caption quality of this method compare to supervised baselines in terms of semantic alignment and diversity?
  • RQ4To what extent can the model generate captions that reflect real-world knowledge beyond curated datasets?
  • RQ5Can the method perform multi-modal reasoning by combining images and text in a shared embedding space?

Key findings

  • ZeroCap achieves a CLIP-score of 0.70 on the visual relations benchmark, significantly outperforming the baseline ClipCap (0.24), indicating superior semantic alignment with input images.
  • The method achieves a BLEU-1 score of 0.10 and Recall@5 of 0.32 on the same benchmark, demonstrating improved caption quality over ClipCap’s 0.003 and 0.035, respectively.
  • Generated captions are more diverse and less scripted than those from supervised models, reflecting broader real-world knowledge and semantic richness.
  • The model successfully performs visual-semantic arithmetic, such as generating 'Nighttime dinner' from a 'breakfast' image using textual direction prompts like 'day' and 'night'.
  • The method enables novel high-level vision tasks, including comparing two images semantically and solving visual analogy problems using the formula X ∼ C + B - A.
  • Despite using GPT-2 (not GPT-3), the method demonstrates strong zero-shot capabilities, highlighting the power of combining large-scale pre-trained models.
Figure 2 : An overview of our approach. We guide the model towards the phrase ‘eagle’ instead of ‘man’. We do this by adjusting the context ( $C_{4}$ ), using the gradients of CLIP loss ( $\mathcal{L}_{\text{CLIP}}$ ) illustrated with a red arrow. To maintain language attributes, we optimize the min
Figure 2 : An overview of our approach. We guide the model towards the phrase ‘eagle’ instead of ‘man’. We do this by adjusting the context ( $C_{4}$ ), using the gradients of CLIP loss ( $\mathcal{L}_{\text{CLIP}}$ ) illustrated with a red arrow. To maintain language attributes, we optimize the min

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.