Towards Unified Multi-granularity Text Detection with Interactive Attention

Xingyu Wan, Chengquan Zhang, Pengyuan Lyu, Sen Fan, Zihan Ni, Kun Yao, Errui Ding, Jingdong Wang

Abstract

Text detection tasks are often fragmented into word, line, paragraph, or page-level detection, typically requiring specialized models for each granularity. This paper presents Detect Any Text (DAT), a unified framework that integrates these tasks into a single end-to-end model. By employing an across-granularity interactive attention module, DAT facilitates bidirectional information flow between different scales, leveraging high-level context to improve low-level detection. Experimental results demonstrate that DAT achieves state-of-the-art performance across multiple benchmarks, including scene text detection, layout analysis, and page detection, while maintaining competitive inference speeds.

Introduction

In Optical Character Recognition (OCR) and document analysis, text detection encompasses a variety of sub-tasks. Depending on the application, requirements may range from identifying individual words in scene text to delineating lines, paragraphs, or entire page boundaries in complex documents. Traditionally, these tasks have been addressed by separate, specialized models. This fragmented approach is not only computationally expensive but also overlooks the inherent structural relationships between different granularities: words compose lines, which form paragraphs, which are situated within pages.

Multi-granularity text detection outputs across word, line, paragraph, and page levels.

Existing unified models often rely on "bottom-up" approaches, such as clustering words into lines. However, these methods frequently fail to utilize high-level context (e.g., paragraph structure) to refine low-level detection. Moreover, training such models typically requires datasets labeled at every level of the hierarchy, which are scarce in real-world scenarios.

Methodology: The Detect Any Text (DAT) Framework

DAT is built upon the DINO Transformer-based detector and introduces a unified architecture capable of handling multiple granularities simultaneously. The framework consists of two primary branches:

Detection Branch (DET)

The DET branch utilizes four distinct groups of object queries corresponding to word, line, paragraph, and page levels. The core innovation is the Interactive Attention Module. Unlike standard detectors that treat queries independently, DAT uses an attention mask to allow queries of different granularities to interact. An interaction factor ($\mathcal{I}$) controls the information flow across the hierarchy, enabling the model to learn the "concept" of a line by simultaneously considering its constituent words and the paragraph it belongs to.

The architecture of the Detect Any Text (DAT) framework, featuring DET and SEG branches.

To address the lack of multi-level labeled data, the authors implement Mixed-Granularity Training. This dynamic loss-weighting strategy allows the model to train effectively on diverse datasets, even those providing labels for only a single granularity (e.g., a dataset with only word-level boxes).

Segmentation Branch (SEG)

Inspired by the Segment Anything Model (SAM), the SEG branch refines the polygons generated by the DET branch. It uses these polygons as "prompts" for a mask decoder, producing precise segmentation masks. This is particularly effective for handling curved text or complex, overlapping layouts where standard bounding boxes may be insufficient.

Experimental Evaluation

The versatility of DAT was evaluated across a comprehensive suite of benchmarks to prove its multi-task capability:

  • Word Level: ICDAR2015 (multi-oriented) and Total-Text (arbitrarily shaped).
  • Line Level: CTW1500 and MSRA-TD500.
  • Paragraph/Layout: M6Doc (a large-scale dataset with 74 categories).
  • Page Level: Documents in the Wild (DIW).

Key Results and Insights

DAT achieves state-of-the-art (SOTA) performance across all evaluated tasks:

  • Scene Text: On Total-Text, DAT-SEG reached an F-score of 92.01, surpassing specialized models like ESTextSpotter.
  • Layout Analysis: On the M6Doc dataset, DAT improved the mean Average Precision (mAP) from 63.8 to 65.7, a significant jump in a complex task with 74 categories.
  • Page Detection: The model achieved 98.65 mIoU on the DIW dataset.

A key insight from this work is that multi-granularity training provides mutual benefits. High-level structural information acts as a top-down guide, helping the model disambiguate messy or stylized text at the word level. Furthermore, the unified nature of DAT allows it to generate high-quality pseudo-labels for missing granularities in existing datasets, facilitating future research in document understanding.

Conclusion

While DAT demonstrates significant advancements, challenges remain in fully utilizing multilingual datasets with varying annotation schemes and detecting extremely small or blurred text. Future work will focus on expanding the framework's capabilities across more diverse languages and complex annotation environments. Despite these challenges, DAT represents a significant step toward a truly unified and efficient text detection system that replaces the need for multiple specialized models in a pipeline.

Summary updated

BibTeX
@inproceedings{wan2024towards,
  author = {Xingyu Wan and Chengquan Zhang and Pengyuan Lyu and Sen Fan and Zihan Ni and Kun Yao and Errui Ding and Jingdong Wang},
  title = {{Towards Unified Multi-granularity Text Detection with Interactive Attention}},
  booktitle = {International Conference on Machine Learning},
  year = {2024},
  url = {https://openreview.net/forum?id=HaBVzgSdM7},
}
Figure