Shape Robust Text Detection with Progressive Scale Expansion Network
- Publication
- CVPR 2019Conference
- First submitted to arXiv
- arXiv:1903.12473
Cite this paper · BibTeX
The citation identifies the linked source version. It cites the original paper and its authors.
@misc{textdetectionpsenet2019,
title = {{Shape Robust Text Detection with Progressive Scale Expansion Network}},
author = {Wenhai Wang and Enze Xie and Xiang Li and Wenbo Hou and Tong Lu and Gang Yu and Shuai Shao},
year = {2019},
eprint = {1903.12473},
archivePrefix = {arXiv},
url = {https://arxiv.org/abs/1903.12473}
}
With the increasing maturity of convolutional neural networks (CNNs), various applications have been developed. One of the most crucial applications is text detection, as it serves as a foundation for many others, such as OCR, autonomous driving, and image retrieval. However, designing a universal text detection model is highly challenging due to the wide variation in text shapes and sizes.
Problem Definition
In the early stages of development, object detection was the primary focus of researchers, leading to many text detection methods based on object detection techniques. However, these approaches faced several challenges when applied to text detection:
-
Dramatic Variations in Text Shape
Multi-scale features help with size variation, but text also poses large changes in shape and aspect ratio. For instance, as text length increases, the bounding box becomes elongated, and the aspect ratio grows significantly. This poses a challenge for anchor-based methods, as predefined aspect ratios may not cover the wide range of text shapes encountered. Adding unlimited anchor boxes is impractical.
-
Rectangular Boxes Do Not Fit Well
As shown in (b) of the figure above, text is often not neatly rectangular. For example, text on banners or street signs may be curved or irregular, and using rectangular boxes can fail to adequately capture the shape. Poorly fitting detection boxes make subsequent classification difficult and can render the detection itself meaningless.
-
Segmentation Struggles to Separate Close Text
As shown in (c), segmentation-based methods also have significant limitations. Text is often close together or overlapping, and pixel-based segmentation methods struggle to define the boundaries between adjacent text instances.
To address these challenges, the authors propose a new idea: rather than directly detecting text, find the core of the text and progressively expand it until reaching the text boundaries.
Solution
Model Architecture
The model architecture is straightforward, consisting of a Backbone + Neck (FPN) structure, as shown on the left side of the figure. The four feature maps are upsampled to the same size, concatenated, and fused by convolution. Then branches predict text segmentation maps at different scales.
As shown in the figure, represents the smallest text core, expands upon , expands upon , and so on, until . The supervision for these scales is generated from the dataset annotations:
The blue-bordered polygon represents the original text instance and corresponds to the largest ground-truth mask. The Vatti clipping algorithm progressively shrinks that polygon to obtain at different scales; each resulting polygon becomes a binary segmentation label.
For a given shrink ratio , the margin for scaling can be calculated by:
The scale ratio is defined as:
Here is the smallest scale ratio, and is the number of scales. The ratios rise linearly from to 1. The ground-truth masks generated in this way correspond to PSENet’s multi-scale predictions.
Progressive Expansion
To separate adjacent text instances and recover their complete shapes, the authors introduce a progressive expansion strategy based on breadth-first search (BFS).
- Initial Stage: As shown above, the smallest cores () are identified as connected components (, , , ).
- Expansion Stage: These cores are progressively expanded to , then to , until reaching the final connected components representing complete text instances.
Starting with pixels in the smallest cores, BFS incorporates neighboring text pixels at each scale. During expansion, conflicts between pixels from different cores are resolved using a "first-come, first-served" approach, ensuring that each pixel is assigned to only one core. The authors state that these boundary conflicts do not affect the final detection results or performance.
The algorithm’s steps are as follows:
- Input: Core block set , segmentation result
- Output: Expanded core blocks
- Initialize empty sets , , and queue .
- Add all elements of core blocks to and , and enqueue .
- Process each element in the queue, checking its neighboring pixels for expansion.
- Group the expanded results to form the final expanded core blocks .
Loss Function
The loss function for PSENet is defined as:
Where represents the loss for the complete text instance, and represents the loss for the shrunken text instance, with balancing their importance.
The Dice coefficient is used to calculate the loss instead of binary cross-entropy, which could bias predictions towards non-text regions because text occupies only a small part of natural images. The Dice coefficient is given by:
Here, and represent the predicted and ground-truth values for pixel . Online hard example mining (OHEM) supplies the training mask for so that patterns resembling text strokes, such as fences or grids, are addressed:
Because the smaller kernels lie within the complete text region, ignores pixels outside that region. Its formula is:
Where is a mask that ignores non-text areas, defined as:
Training Datasets
-
CTW1500
CTW1500 is a challenging dataset designed for detecting long, curved text. Created by Yuliang et al., it contains 1,000 training images and 500 test images. Unlike traditional text datasets like ICDAR 2015 and ICDAR 2017 MLT, CTW1500 annotates text instances using 14-point polygons, allowing it to describe arbitrarily shaped curved text.
-
Total-Text
Total-Text is a newly released curved text detection dataset that includes horizontal, multi-oriented, and curved text instances. The dataset contains 1,255 training images and 300 test images.
-
ICDAR 2015
ICDAR 2015 is a widely-used dataset in text detection, consisting of 1,500 images, with 1,000 for training and 500 for testing. Text regions are annotated as quadrilaterals with four vertices.
-
ICDAR 2017 MLT
IC17-MLT is a large-scale multi-lingual text dataset that includes 7,200 training images, 1,800 validation images, and 9,000 test images. It contains full scene images across nine languages, making it a comprehensive dataset for multi-lingual text detection.
Training Strategy
A pre-trained ResNet on ImageNet is used as the backbone, and the optimization is performed using Stochastic Gradient Descent (SGD).
The training strategy for the IC17-MLT dataset differs from others:
For IC17-MLT training, no additional data (e.g., SynthText) was used. The model is trained with a batch size of 16 using 4 GPUs, running for 180K iterations. The initial learning rate is set to , which is decreased by a factor of 10 at 60K and 120K iterations.
For datasets other than IC17-MLT, the training strategy is as follows:
There are two training settings for the other benchmarks. Without external text data, train directly on the target dataset for 36K iterations, with batch size 16 across 4 GPUs, starting at and decaying tenfold at 12K and 24K iterations.
With external data, first pretrain on IC17-MLT and then fine-tune on the target dataset for 24K iterations, starting at and decaying tenfold at 12K. These are alternative settings; the order is not target-dataset training followed by fine-tuning on IC17-MLT.
-
Optimization and Parameter Settings
- Weight decay is set to , Nesterov momentum is 0.99, and no damping is applied.
- During training, blurry text regions labeled as "DO NOT CARE" across all datasets are ignored.
- The balancing parameter for the loss function is set to 0.7, and the negative-positive sample ratio for OHEM is 3.
-
Data Augmentation Strategy
- Images are scaled randomly with ratios of [0.5, 1.0, 2.0, 3.0].
- Random horizontal flips and rotations are applied, with a range of ±10 degrees.
- A patch is randomly cropped from the transformed image.
-
Result Generation
- For quadrilateral text datasets, the minimum area rectangle is computed to extract the bounding box.
- For curved text datasets, the PSE output is applied to generate the final results.
Discussion
Impact of Component Design
-
Can the Kernel Block Serve as the Final Output?
The answer is no.
The kernel block's purpose is to roughly locate text instances and distinguish adjacent text. However, the smallest-scale kernel block cannot cover the full text region, negatively impacting text detection and recognition. As shown in figure (a), using only the smallest kernel block as the final result leads to poor F-measure performance on both the ICDAR 2015 and CTW1500 datasets.
-
Effect of Minimum Kernel Size
The authors study the impact of the minimum kernel size by setting the number of kernels and varying from 1 to 0.1.
As shown in figure (a), when is too large or too small, the F-measure on the test set decreases. At , only the text segmentation map is used as the final result, without using the Progressive Scale Expansion (PSE) algorithm. Results show that without PSE, the baseline performance is unsatisfactory, as the network fails to distinguish between adjacent text instances.
When is too large, PSENet struggles to separate closely located text instances. Conversely, when is too small, PSENet tends to incorrectly split entire lines of text into different segments, making training harder to converge.
-
Effect of Kernel Count
The authors examine the effect of varying the number of kernels while keeping the minimum size constant. For ICDAR 2015, , and for CTW1500, . The value of is increased from 2 to 10.
As shown in figure (b), as increases, the F-measure on the test set rises steadily and stabilizes when . The advantage of multiple kernels is their ability to accurately reconstruct two adjacent text instances with significant size differences.
Results for Curved Text
The authors evaluate curved-text detection on both CTW1500 and Total-Text.
During testing, the longer side of each image is scaled to 1280, and ResNet50 is used as the backbone network.
-
CTW1500
PSENet-1s reaches 78.0% F-measure on CTW1500 without external text data, and 82.2% after pretraining on IC17-MLT and fine-tuning on CTW1500. The latter exceeds CTD+TLOC by 8.8 percentage points and TextSnake by 6.6 percentage points. Those two comparison methods have different external-data conditions, so the gains need to be read separately.
-
Total-Text
On Total-Text, PSENet-1s with external text data reports 84.02% precision, 77.96% recall, and 80.87% F-measure. This is 2.47 percentage points above TextSnake's 78.4%; PSENet-1s without external text data reaches 78.3%. Compared with the DeconvNet baseline's 36.0% F-measure, the 80.87% result is 44.87 percentage points higher. EAST and SegLink were not fine-tuned on Total-Text, so their rows are for reference only.
The authors also show several challenging results, visually comparing them with existing CTD+TLOC methods, as seen below:
Results on ICDAR2015
The authors evaluate PSENet on the ICDAR 2015 (IC15) dataset to test its ability to detect oriented text. ResNet50 is used as the backbone for PSENet, and during inference, the longer side of the input image is scaled to 2240.
In the single-scale PSENet-1s setting with external text data, F-measure reaches 85.69%, about 3.1 percentage points above the table's previous best, TextSnake at 82.6%. Without external text data, PSENet-1s reaches 80.6%.
Speed Analysis
The authors conducted speed experiments on the CTW1500 test set, evaluating all test images and calculating the average speed. Images were scaled to [1280, 960, 640] along the long side for speed testing. All results were tested using PyTorch on a single 1080Ti GPU.
To balance speed and accuracy, both ResNet50 and ResNet18 were used as backbone networks.
- When the output feature map size is the same as the input image (1/1), PSENet achieves the best performance. However, due to the large feature map size, the PSE stage consumes more than half of the total inference time.
- When the output feature map's width and height are each reduced to 1/4 of the input image, FPS increases from 3.9 to 8.4, with F-measure decreasing from 82.2% to 79.9%. The PSE stage then takes less than one tenth of total inference time.
- When scaling the long side of the image to 640, the FPS further increases to 22, while the detector’s performance remains fairly good (75.6%).
With ResNet18 as the backbone, a 960-pixel long side, and no external text-data pretraining, PSENet reaches 26.75 FPS and 74.3% F-measure.
Conclusion
PSENet’s core idea is to tackle irregular-shaped scene text by progressively expanding detected areas. However, post-processing is still necessary to finalize text regions, which adds computational complexity in real-world applications.
Moreover, the progressive expansion strategy heavily relies on the initial text core region detection. If the core region is inaccurately detected, the subsequent expansion steps will be affected, thereby influencing the final detection result.
In summary, PSENet strikes a good balance between accuracy and speed, making it suitable for many practical applications. Compared to other methods based on semantic segmentation or object detection, PSENet offers a novel approach to detecting challenging text, pushing the field forward significantly.