← All articles

text detectionsegmentationencoder-decoder

Finding text in street photos by letting the network weigh its own shortcuts

Before a computer can read a shop sign in a photo, it has to find the sign. This paper is about that first step, called text localization. We built a neural network that labels every pixel of an image as text or not text, and we changed the way its layers pass information to each other. On four public datasets it beat three well-known segmentation networks.

The problem

Text in the wild is awkward. Lighting is uncontrolled, backgrounds are cluttered, and many ordinary objects happen to look like letters. Text also comes in every size, from a word that fills the frame to a few pixels in a corner, and it can be tilted or curved.

Popular object detectors draw boxes. They start from a set of preset box shapes, called anchor boxes, which are chosen by clustering the boxes in the training data. Text boxes vary so much in size and aspect ratio that a fixed set of shapes fits them badly. Since text finding only needs a yes or no answer, we dropped boxes altogether. The network outputs a mask, a black and white picture the size of the input, where white pixels are text. This is binary segmentation, and it can mark curved text as well.

The idea

We used an encoder-decoder network. The encoder squeezes the image through a series of layers, each giving a coarser summary. The decoder then expands that summary back into a full-size mask. Squeezing throws away fine detail, so a network called U-Net adds skip connections: shortcuts that copy features from an encoder layer straight across to the matching decoder layer.

A plain shortcut has a weakness. Every bridge feeds the decoder with the same weight and nobody controls the total flow, so one layer can drown out the others. We replaced the bridges with three kinds of mirror connection:

  • Linear. Add the encoder features to the decoder as they are, as U-Net does.
  • Parametric. Multiply the encoder features by one trainable number first, so the network learns how loudly each bridge should speak.
  • Convolutional. Pass the features through an extra small encoder and decoder pair before adding them. This gives finer control but needs more memory.

Inside each layer we also added internal skips, in the style of residual networks, so that the learning signal reaches the early layers more easily.

Diagram of an encoder-decoder network with coloured blocks shrinking and then growing again. Boxes labelled Mirror Skip link each encoder layer to its mirror layer in the decoder, and small loops mark internal skips. A street-sign photo goes in and a black and white mask comes out.
The base network. The long arcs labelled Mirror Skip are the connections we studied, and the short loops are the internal skips.Source: Fig. 1 of the paper.

Three window sizes and a vote

A convolution looks at the image through a small sliding window, called a kernel. A small window sees fine strokes and a larger one sees more context. For each type of mirror connection we trained three networks with 3×3, 5×5 and 7×7 windows, so nine in total. To get the final mask we kept a pixel as text only where the three networks agreed, which removes many false alarms.

Three encoder-decoder networks labelled 3x3, 5x5 and 7x7 kernel each produce an output; a large arrow merges the three outputs by a logical and into the final output.
The three networks with different kernel sizes are merged with a logical and.Source: Fig. 5 of the paper.

What we found

We tested on ICDAR 2003, SVT, ICDAR 2015 and Total-Text. The first three label text with rectangles. Total-Text contains curved text (Table 2). We held back roughly 20% of the training data for tuning. We report the F-score, one number between 0 and 1 that mixes precision (how much of the marked text is real) with recall (how much of the real text was found).

Single networks were uneven. On SVT, for example, individual F-scores ranged from 0.57 to 0.74 (Table 4), and no kernel size or connection type won everywhere. The pattern only showed once we merged the three window sizes. The parametric version then gave the best F-score on SVT (0.84), ICDAR 2003 (0.87) and ICDAR 2015 (0.79) (Table 3), and we conclude that it works best overall. The plain linear connection did not do as well.

On curved text (Total-Text) the merged models scored F-scores of 0.89 (parametric) and 0.90 (convolutional). SegNet, U-Net and PSPNet scored 0.71, 0.75 and 0.75 (Table 3).

The convolutional connection came out slightly ahead only on Total-Text, which suggests that curved masks profit from its finer control. In the sample masks, the parametric networks drew cleaner shapes and showed less uncertainty in their soft masks, which are the raw probabilities before we threshold them at 0.5.

A grid of four street-scene photos at the top with curved text on signs, and below them the ground truth mask followed by soft and hard masks from the linear, parametric and convolutional models and from PSPNet, SegNet and U-Net.
Total-Text samples, one column per photo. The bottom three rows are the comparison networks. Our hard masks follow the curved text, while the SegNet and U-Net masks often miss it or break it up.Source: Fig. 9 of the paper.

Results in more detail

Table 3 holds the full comparison of the merged models. For each dataset it lists precision, recall and F-score for our three kinds of mirror connection and for three well-known segmentation networks, SegNet, U-Net and PSPNet. Within each dataset the first three rows are ours and the last three are the comparison networks. The first table below covers SVT and ICDAR 2003, and the second covers ICDAR 2015 and Total-Text.

Merged models against SegNet, UNet and PSPNet on SVT and ICDAR 2003
DatasetMirror skipPrecisionRecallF-score
SVTproposed (linear)0.760.690.72
SVTproposed (parametric)0.850.830.84
SVTproposed (convolution)0.820.830.81
SVTSegNet0.580.550.51
SVTUNet0.600.490.49
SVTPSPNet0.600.570.53
ICDAR2003proposed (linear)0.690.710.72
ICDAR2003proposed (parametric)0.780.880.87
ICDAR2003proposed (convolution)0.750.810.80
ICDAR2003SegNet0.700.620.59
ICDAR2003UNet0.620.530.51
ICDAR2003PSPNet0.720.720.68
The SVT and ICDAR2003 rows of Table 3, as printed. Higher values are better. Source: Table 3 of the paper.

On both datasets the parametric version has the highest F-score of its block, and all three of our versions are above the three comparison networks.

Merged models against SegNet, UNet and PSPNet on ICDAR 2015 and Total-Text
DatasetMirror skipPrecisionRecallF-score
ICDAR2015proposed (linear)0.720.680.73
ICDAR2015proposed (parametric)0.810.790.79
ICDAR2015proposed (convolution)0.710.690.71
ICDAR2015SegNet0.590.580.60
ICDAR2015UNet0.620.690.62
ICDAR2015PSPNet0.710.720.72
Total-Textproposed (linear)0.840.840.84
Total-Textproposed (parametric)0.880.880.89
Total-Textproposed (convolution)0.890.870.90
Total-TextSegNet0.700.700.71
Total-TextUNet0.750.740.75
Total-TextPSPNet0.750.720.75
The ICDAR2015 and Total-Text rows of Table 3, as printed. Higher values are better. Source: Table 3 of the paper.

On ICDAR 2015 the parametric version again has the highest F-score, and PSPNet is the closest of the comparison networks. On Total-Text even the plain linear version scores 0.84. The paper points out that these three comparison networks already use encoder-decoder layouts, feature fusion across layers and multi-scale analysis, the same ideas our model builds on.

Table 4 lists the nine individual networks on SVT before merging. L, P and C stand for the linear, parametric and convolutional connection, and the digit is the window size. The numbers are noisy: P7 reaches 0.7254 while P3 and P5 stay below 0.60.

Each single network on SVT, before merging
ModelKernel sizeMirror skipPrecisionRecallF score
L33×3Linear0.73920.73840.7388
L55×5Linear0.57530.55920.5660
L77×7Linear0.72340.71760.7260
L mean-Linear0.67930.67170.6769
P33×3Parametric0.57710.65050.5988
P55×5Parametric0.56200.63560.5808
P77×7Parametric0.72020.71280.7254
P mean-Parametric0.61970.66830.6350
C33×3Convolutional0.69340.70960.7011
C55×5Convolutional0.75630.68730.7159
C77×7Convolutional0.59370.57900.5856
C mean-Convolutional0.68110.65860.6675
Overall Mean--0.66010.66550.6598
All rows of Table 4, as printed. Source: Table 4 of the paper.

The other datasets look similar (Table 5, Table 6 and Table 7). The best single network on ICDAR 2003 was C3 with an F-score of 0.8133, on ICDAR 2015 it was P5 with 0.8428, and on Total-Text it was C7 with 0.9341. The mean over all nine networks was 0.7563 on ICDAR 2003, 0.7663 on ICDAR 2015 and 0.8896 on Total-Text. Total-Text produced the highest single-network scores, from 0.8178 up to 0.9341 (Table 7). All nine networks shared the same layout: encoder widths of 16, 64, 128, 256 and 512 channels, two convolutional blocks per layer, internal skips and a batch size of 16 (Table 1). We trained on one Nvidia GTX 1660 with 6 GB of memory.

The sample masks (Figs. 6 to 9 of the paper) tell the same story. The linear and convolutional models fail to detect text in several places where the parametric one succeeds, and the paper reports that our model behaves much more consistently across samples than the other networks.

Discussion

We conclude that the ensemble of three networks with 3×3, 5×5 and 7×7 windows and the parametric mirror connection works best. It beat the linear connection and the more memory-hungry convolutional one on three of the four datasets.

Our explanation starts with the plain bridge. In a U-Net style bridge every layer feeds the decoder with equal preference, and nothing controls the total flow, so one layer can overpower the others. A single trainable number per bridge keeps that in check. The linear connection helps gradients travel through a network, but for multi-scale features it did not do as well as the weighted versions. The convolutional version is more expressive and suits curved masks, yet it needs more memory and can over-fit the training data, which de-regularizes the network.

No window size or connection type won everywhere, and the pattern only became visible after merging. The training sets hold between 100 and 1,255 images (Table 2). The network only marks where text is and does not read it. As future work we name other domains, such as character-level text segmentation.

Finding text is the first step toward reading it. The paper's introduction names reading shop names and street signs for navigation systems as one use.

Sources

The figures and tables listed here are taken from the paper cited at the top of this page; the numbers quoted in the text come from it too.

  • Figures: Fig. 1, Fig. 5, Fig. 9
  • Tables: Table 1: layout shared by the nine networks; Table 2: size and type of the four datasets; Table 3: precision, recall and F-score of the merged models and of SegNet, U-Net and PSPNet; Table 4: each single network on SVT; Table 5: each single network on ICDAR 2003; Table 6: each single network on ICDAR 2015; Table 7: each single network on Total-Text

Acknowledgements

This work is sponsored by SERB (Government of India, order no. SB/S3/EECE/054/2016, dated 25/11/2016), and was carried out at the Centre for Microprocessor Application for Training Education and Research, CSE Department, Jadavpur University.

Cite the paper

K Dutta, M Bal, A Basak, Swarnendu Ghosh, N Das, M Kundu, M Nasipuri (2020). Multi scale mirror connection based encoder decoder network for text localization. Pattern Recognition Letters, Vol. 135, pp. 64–71 · Elsevier.

BibTeX
@article{dutta2020multi,
  author    = {Dutta, K and Bal, M and Basak, A and Ghosh, Swarnendu and Das, N and Kundu, M and Nasipuri, M},
  title     = {Multi scale mirror connection based encoder decoder network for text localization},
  journal   = {Pattern Recognition Letters},
  volume    = {135},
  pages     = {64--71},
  publisher = {Elsevier},
  year      = {2020},
  doi       = {10.1016/j.patrec.2020.04.002}
}