Focus, Distinguish, and Prompt: Unleashing CLIP for Efficient and Flexible Scene Text Retrieval

Gangyan Zeng, Yuan Zhang, Jin Wei, Dongbao Yang, peng zhang, Yiwen Gao, Xugong Qin, Yu Zhou · DOI

Abstract

Scene text retrieval aims to find all images containing the query text from an image gallery. Current efforts tend to adopt an Optical Character Recognition (OCR) pipeline, which requires complicated text detection and/or recognition processes, resulting in inefficient and inflexible retrieval. Different from them, in this work we propose to explore the intrinsic potential of Contrastive Language-Image Pre-training (CLIP) for OCR-free scene text retrieval. Through empirical analysis, we observe that the main challenges of CLIP as a text retriever are: 1) limited text perceptual scale, and 2) entangled visual-semantic concepts. To this end, a novel model termed FDP (Focus, Distinguish, and Prompt) is developed. FDP first focuses on scene text via shifting the attention to the text area and probing the hidden text knowledge, and then divides the query text into content word and function word for processing, in which a semantic-aware prompting scheme and a distracted queries assistance module are utilized. Extensive experiments show that FDP significantly enhances the inference speed while achieving better or competitive retrieval accuracy compared to existing methods. Notably, on the IIIT-STR benchmark, FDP surpasses the state-of-the-art model by 4.37% with a 4 times faster speed. Furthermore, additional experiments under phrase-level and attribute-aware scene text retrieval settings validate FDP's particular advantages in handling diverse forms of query text.

Introduction

Scene Text Retrieval (STR) is the task of finding all images in a gallery that contain a specific piece of text, such as searching for "Starbucks" in a city photo database. Historically, this has required a heavy OCR pipeline: first, an algorithm detects text boxes, then another recognizes the characters, and finally, the results are matched against a query. This approach is computationally expensive, slow, and prone to "cascading errors"—if the detector misses a word, the retriever never sees it.

While Vision-Language Models like CLIP are powerful, they struggle with STR for two main reasons. First is scale: CLIP typically looks at low-resolution images (224x224), where small scene text becomes blurry. Second is visual-semantic entanglement: CLIP often confuses the visual representation of a word with its semantic meaning. For example, searching for "dog" might return a picture of an actual animal rather than a sign that says "DOG."

The FDP Framework

The researchers introduced the FDP (Focus, Distinguish, and Prompt) framework to "unleash" CLIP’s latent OCR capabilities through three distinct stages:

  1. Focus: To solve the scale problem without retraining CLIP’s massive encoder, a lightweight "Dynamic Attention Shift" module is used. This creates a rough heat map of text locations and uses it as an attention mask to force the model to "look" at text regions. A "Text Knowledge Probe"—querying the model with the phrase "scene text"—further primes visual features for text-related information.
  2. Distinguish: The team discovered that CLIP processes "content words" (like hotel or coffee) differently than "function words" (like and or with). FDP uses unsupervised clustering to categorize query words and applies tailored retrieval strategies for each.
  3. Prompt: Instead of static text, FDP uses Prompt Tuning, converting queries into learnable vectors optimized during training. A "Distracted Queries Assistance" module makes the model more robust by forcing it to distinguish target words from "hard negatives" (words with small edit distances, like "advice" vs. "advise").

Performance and Efficiency

FDP was evaluated on standard benchmarks including IIIT-STR, SVT (Street View Text), and TotalText. The results demonstrate a superior trade-off between accuracy and speed compared to traditional OCR-based methods.

Figure 2: Comparison of mAP scores and inference speed (FPS) on the IIIT-STR benchmark. FDP models (red) achieve higher accuracy at significantly higher speeds than previous methods (blue).

On the IIIT-STR benchmark, the "Large" version of FDP (FDP-L) achieved a 91.49% mAP, surpassing previous state-of-the-art models by over 4%. More impressively, FDP is significantly faster than OCR-based competitors, running at roughly 45 FPS for its small version, compared to approximately 11 FPS for previous top-tier models.

Flexibility and Qualitative Analysis

Because it does not rely on a rigid character-recognition engine, FDP is uniquely flexible. It can handle phrase-level queries and attribute-aware retrieval, tasks that often baffle traditional OCR systems.

Figure 1: Qualitative examples of (a) phrase-level and (b) attribute-aware scene text retrieval. FDP successfully retrieves complex queries like "pink lady apple juice" and "welcome in red" where conventional models fail.

As shown in Figure 1, FDP successfully retrieved images for complex queries like "galaxy in red background" or "coffee in italic font." This flexibility stems from the model's ability to maintain global image context while highlighting text regions through its learnable attention mask, rather than simply cropping and zooming into text boxes.

Conclusion

FDP demonstrates that a frozen, "off-the-shelf" CLIP model can be transformed into a high-performance OCR engine with the right architectural "nudges." By bypassing traditional detection and recognition stages, FDP achieves a 4x speedup and sets new accuracy records. While challenges remain with extremely tiny text or very similar spellings, FDP represents a significant step toward more efficient and flexible scene text retrieval in real-world environments.

Summary updated

BibTeX
@inproceedings{zeng2024focus,
  author = {Gangyan Zeng and Yuan Zhang and Jin Wei and Dongbao Yang and peng zhang and Yiwen Gao and Xugong Qin and Yu Zhou},
  title = {{Focus, Distinguish, and Prompt: Unleashing CLIP for Efficient and Flexible Scene Text Retrieval}},
  booktitle = {ACM Multimedia},
  year = {2024},
  doi = {10.1145/3664647.3680877},
}
Figure