Paper · 2017-09-07 · cs.CV
Focusing Attention: Towards Accurate Text Recognition in Natural Images
Attention-based scene text recognizer plus a focusing network that pulls each character's attention back onto the character. Part of the training data has character pixel labels. Uses a 32-layer ResNet-style encoder. Author-reported lexicon-free accuracy: 87.4% IIIT5k, 85.9% SVT, 94.2% IC03, 93.3% IC13, 70.6% IC15, above the same model without the focusing network.
Optical character recognitionAttention mechanismConvolutional recurrent network (CRNN)Residual learningscene-text-recognitionattention-driftencoder-decoder
AI-compiled by claude-haiku-5-5 on 2026-10-24, not yet reviewed by a human. Every claim cites its source; check it when a detail matters.
In plain words
Reading words in photos is harder than reading scanned pages. Lighting, blur, odd fonts and busy backgrounds can make a model look at the wrong spot while it reads each letter. The authors call this "attention drift": the model is looking at a neighbouring patch, so it reads the wrong letter or skips one.
Their fix is to add a second small network that checks where the reader is looking for each letter and nudges that focus back onto the letter. Some training images also mark where each letter sits, which tells the checker where it should have looked. The encoder that turns the image into features is a deeper residual network than earlier work used.
TL;DR
Scene text recognition with an attention-based encoder-decoder fails on hard images because the attention for each character drifts off the character §1. FAN adds a focusing network (FN) that scores where the attention falls and trains the attention to land on each character, using pixel-level character labels for about 30% of the training words §3.2 §4.2. The paper reports gains over the same model without FN on every benchmark it tests tab. 2.
Problem
Attention-based recognizers learn the alignment between output characters and image regions without supervision on where each character is. On complicated or low-quality photos these alignments are often wrong, and the wrong regions produce wrong characters §1 §3.1. The authors name this failure "attention drift" and say it is the main reason for poor results on such images §1. Training such models on large synthetic sets is also hard §3.1.
Method
The model has three parts: a feature encoder, an attention network (AN) that reads the features one character at a time, and a focusing network (FN) that is trained only to check AN's attention §3 fig. 4.
Encoder. A ResNet-style CNN turns the image, resized to 256 wide by 32 high, into a sequence of 65 column features. A bidirectional LSTM runs over that sequence §4.2 tab. 1. Each feature corresponds to an image region called an attention region §1.
Attention network (AN). A standard attention decoder. At each output step it scores every feature against the decoder state, normalises the scores with a softmax to get alignment factors, and forms a glimpse vector as the weighted sum of the features. The decoder LSTM then emits a character from the glimpse and its state. An end-of-sequence symbol ends the output §3.1 eq. 1 eq. 2 eq. 3 eq. 4 eq. 5. The AN loss is the negative log-likelihood of the true characters eq. 6.
Focusing network (FN). For output step t the FN does two things §3.2:
- It computes an attention centre. Each feature has a centre, which is the centre of its receptive field in the input image, found by applying the convolution geometry layer by layer eq. 7 eq. 8. The attention centre for step t is the alignment-weighted average of these centres eq. 9.
- It crops a fixed-size patch of feature maps around that centre eq. 10. A small head scores every position of the patch against the glimpse vector and the cropped feature, and a softmax over the K label classes gives a distribution for each position eq. 11 eq. 12. Each position therefore predicts a label, as if the patch were a pixel-level segmentation.
The FN loss is the negative log-likelihood of the labelled positions, summed over steps, over the patch width and over the patch height, and it is applied only to images that carry character annotations eq. 13 §3.2.
Joint objective. The total loss mixes the two losses with a weight λ,
L = (1 - λ) L_Att + λ L_focus, where 0 ≤ λ < 1 eq. 14 §3.3. The network
is trained by back-propagation §3.3.
Decoding. For unconstrained recognition the most probable character is taken at each step. For constrained recognition, the conditional probability of each lexicon word is computed and the best word is returned §3.4.
# Focusing attention, one training pass over a word image [§3.1] [§3.2]
# Input: image (H, W, C); labels y_1..y_M; pixel labels (optional)
# Output: scalar loss [eq. 14]
def fan_loss(image, labels, pixel_labels, lam):
# Encode the image into T column features [§4.2] [tab. 1]
features = encode_cnn_blstm(image) # (T, feat)
# Centre of the receptive field of each feature [eq. 7] [eq. 8]
centres = receptive_field_centres(features) # (T, 2)
state = initial_decoder_state()
loss_att = 0
loss_focus = 0
for t in range(M):
# Alignment factors over the T features [eq. 4] [eq. 5]
alpha = attention_weights(state, features) # (T,)
# Glimpse vector: weighted sum of features [eq. 3]
glimpse = weighted_sum(alpha, features)
# Attention centre: weighted average of the centres [eq. 9]
centre = weighted_sum(alpha, centres) # (2,)
# Crop a P_H x P_W patch of feature maps at the centre [eq. 10]
patch = crop(feature_map, centre, P_H, P_W)
# Decode the character for step t [eq. 1] [eq. 2]
label_probs, state = decode_step(state, glimpse, labels[t-1])
# AN loss: negative log-likelihood of the true character [eq. 6]
loss_att -= log(label_probs[labels[t]])
# FN: per-position label distribution over the patch [eq. 11] [eq. 12]
pixel_probs = focus_head(glimpse, patch) # (P_W, P_H, K)
# FN loss only where pixel labels exist [eq. 13] [§3.2]
if pixel_labels is not None:
loss_focus -= sum_log_prob(pixel_probs, pixel_labels[t])
# Trade off the two losses with lambda [eq. 14] [§3.3]
return (1 - lam) * loss_att + lam * loss_focusKey equations, as written in the paper:
\mathcal{L} = (1 - \lambda)\,\mathcal{L}_{Att} + \lambda\,\mathcal{L}_{focus} eq. 14
c_t = \sum_{j=1}^{T} \alpha_{t,j}\, c_{t,j} eq. 9
\mathcal{L}_{focus} = - \sum_t^M \sum_i^{\mathcal{P}_W} \sum_j^{\mathcal{P}_H} \log P(\hat{y}_{t}^{(i,j)} \mid \mathcal{I}, \omega) eq. 13
Hyperparameters
Values the paper states are cited. Anything not stated is marked.
| Name | Value | Where | Notes |
|---|---|---|---|
| Encoder | 32-layer ResNet-style CNN, followed by BLSTM | §4.2 tab. 1 | Layer table gives block shapes; see Pitfalls for the W×H order |
| Encoder output sequence | 65 features (width) × 1 (height) | tab. 1 | Used as T in the attention |
| BLSTM hidden units | 256 | §4.2 | per direction is not stated |
| Decoder LSTM | 256 memory blocks | §4.2 | |
| Output classes | 37 (26 letters, 10 digits, 1 EOS) | §4.2 | K in eq. 12 is described as "the number of label classes"; 37 is an inference |
| λ (focus weight) | 0.01 | §4.2 tab. 6 tab. 7 | Swept 0.001 to 0.1; 0 disables FN |
| Optimizer | ADADELTA | §4.2 [adadelta] | learning rate, decay, epsilon: not stated |
| Batch size | 32 | §4.2 | |
| Input size | 256 × 32 (W × H) | §4.2 | same in training and testing |
| Training data (no pixel labels) | 8 million synthetic word images | §4.2 | from Jaderberg et al. |
| Training data (pixel labels) | 4 million synthetic word images | §4.2 | cropped from 80 thousand images; about 30% of instances have pixel labels |
| Training length | about 3 epochs, about 5 days | §4.2 | |
| Throughput | about 90 samples per second | §4.2 | |
| Patch size P_H, P_W | not stated | §3.2 | "max-size of ground-truth regions in the input image"; no number |
| Dimensions of R, S, b in eq. 11 | not stated | §3.2 | |
| Dropout, weight decay, augmentation | not stated | ||
| Framework | Caffe, with CUDA | §4.2 | |
| Hardware | 1 × NVIDIA Tesla M40, Intel Xeon E5-2650 2.30 GHz, 128 GB RAM | §4.2 | |
| Lexicons | 50, 1k, full (constrained); none (unconstrained) | §4.1 §3.4 |
Results
Author-reported. Setup: the model is trained on the 8M plus 4M synthetic words above, with no fine-tuning on the ICDAR 2015 training set §4.3. The baseline is the same ResNet-based AN without FN, so the difference isolates FN §4.3. Accuracy is word accuracy. Tables are copied from the paper with the authors' notation; bold marks the best entry in each column in the paper.
Word accuracy on general benchmarks tab. 2
| Method | IIIT5k 50 | IIIT5k 1k | IIIT5k None | SVT 50 | SVT None | IC03 50 | IC03 Full | IC03 None | IC13 None | IC15 None |
|---|---|---|---|---|---|---|---|---|---|---|
| ABBYY | 24.3 | – | – | 35.0 | – | 56.0 | 55.0 | – | – | – |
| Wang et al. 2011 | – | – | – | 57.0 | – | 76.0 | 62.0 | – | – | – |
| Mishra et al. | 64.1 | 57.5 | – | 73.2 | – | 81.8 | 67.8 | – | – | – |
| Wang et al. 2012 | – | – | – | 70.0 | – | 90.0 | 84.0 | – | – | – |
| Goel et al. | – | – | – | 77.3 | – | 89.7 | – | – | – | – |
| Bissacco et al. | – | – | – | 90.4 | 78.0 | – | – | – | 87.6 | – |
| Alsharif and Pineau | – | – | – | 74.3 | – | 93.1 | 88.6 | – | – | – |
| Almazán et al. | 91.2 | 82.1 | – | 89.2 | – | – | – | – | – | – |
| Yao et al. | 80.2 | 69.3 | – | 75.9 | – | 88.5 | 80.3 | – | – | – |
| Rodríguez-Serrano et al. | 76.1 | 57.4 | – | 70.0 | – | – | – | – | – | – |
| Jaderberg et al. (first 2014 row) | – | – | – | 86.1 | – | 96.2 | 91.5 | – | – | – |
| Su and Lu | – | – | – | 83.0 | – | 92.0 | 82.0 | – | – | – |
| Gordo | 93.3 | 86.6 | – | 91.8 | – | – | – | – | – | – |
| Jaderberg et al. 2016 | 97.1 | 92.7 | – | 95.4 | 80.7 | 98.7 | 98.6 | 93.1 | 90.8 | – |
| Jaderberg et al. (second 2014 row) | 95.5 | 89.6 | – | 93.2 | 71.7 | 97.8 | 97.0 | 89.6 | 81.8 | – |
| Shi et al. 2016 (end-to-end) | 97.6 | 94.4 | 78.2 | 96.4 | 80.8 | 98.7 | 97.6 | 89.4 | 86.7 | – |
| Shi et al. 2016 (robust) | 96.2 | 93.8 | 81.9 | 95.5 | 81.9 | 98.3 | 96.2 | 90.1 | 88.6 | – |
| Baidu IDL | – | – | – | – | – | – | – | – | 89.9 | 77.0 |
| Baseline (ResNet + AN) | 98.9 | 96.8 | 83.7 | 95.7 | 82.2 | 98.5 | 96.7 | 91.5 | 89.4 | 63.3 |
| FAN | 99.3 | 97.5 | 87.4 | 97.1 | 85.9 | 99.2 | 97.3 | 94.2 | 93.3 | 70.6 |
The paper's table labels some rows only by author name; two rows cite the same 2014 work and are kept in the order printed. The paper does not say which of the two is which.
Total normalized edit distance (NED), lower is better tab. 3. NED per image is edit distance divided by ground-truth length; the totals are summed over images §4.3.
| Method | IIIT5k 50 | IIIT5k 1k | IIIT5k None | SVT 50 | SVT None | IC03 50 | IC03 Full | IC03 None | IC13 None | IC15 None |
|---|---|---|---|---|---|---|---|---|---|---|
| Baseline | 31.7 | 78.0 | 188.9 | 22.9 | 47.3 | 11.2 | 18.4 | 28.5 | 58.1 | 306.8 |
| FAN | 22.0 | 64.5 | 145.2 | 16.3 | 36.7 | 6.0 | 16.2 | 21.3 | 39.8 | 251.9 |
FAN vs AN, both with the Shi et al. 2016 image encoder (unconstrained; no ResNet) tab. 4 tab. 5
| Method | Metric | IIIT5k | SVT | IC03 | IC13 | IC15 |
|---|---|---|---|---|---|---|
| AN | NED total | 248.0 | 65.9 | 43.1 | 85.2 | 348.2 |
| FAN | NED total | 213.4 | 56.0 | 31.5 | 72.1 | 323.6 |
| AN | Accuracy | 79.5 | 75.6 | 88.2 | 85.8 | 58.2 |
| FAN | Accuracy | 81.7 | 78.7 | 90.3 | 87.8 | 61.0 |
Effect of λ (unconstrained) tab. 6 tab. 7
| λ | NED IIIT5k | NED SVT | NED IC03 | NED IC13 | NED IC15 | Acc IIIT5k | Acc SVT | Acc IC03 | Acc IC13 | Acc IC15 |
|---|---|---|---|---|---|---|---|---|---|---|
| 0.001 | 153.2 | 40.5 | 23.3 | 44.6 | 262.9 | 86.6 | 85.8 | 93.2 | 92.7 | 69.5 |
| 0.005 | 147.5 | 37.6 | 22.8 | 42.2 | 255.3 | 87.2 | 85.6 | 93.5 | 92.8 | 70.2 |
| 0.01 | 145.2 | 36.7 | 21.3 | 39.8 | 251.9 | 87.4 | 85.9 | 94.2 | 93.3 | 70.6 |
| 0.05 | 148.4 | 38.1 | 23.1 | 45.2 | 252.5 | 87.0 | 86.2 | 94.1 | 92.5 | 70.6 |
| 0.1 | 150.0 | 38.4 | 23.3 | 49.8 | 253.8 | 86.9 | 86.2 | 93.9 | 92.1 | 70.7 |
Effect of the share of pixel-labelled training samples (unconstrained) tab. 8 tab. 9
| Labelled share | NED IIIT5k | NED SVT | NED IC03 | NED IC13 | NED IC15 | Acc IIIT5k | Acc SVT | Acc IC03 | Acc IC13 | Acc IC15 |
|---|---|---|---|---|---|---|---|---|---|---|
| 0% | 188.9 | 47.3 | 28.5 | 58.1 | 306.8 | 83.7 | 82.2 | 91.5 | 89.4 | 63.3 |
| 1% | 155.3 | 41.7 | 22.6 | 46.3 | 258.3 | 86.2 | 84.4 | 93.8 | 92.7 | 70.0 |
| 5% | 152.5 | 41.8 | 22.3 | 52.7 | 258.3 | 86.3 | 84.7 | 93.8 | 92.6 | 69.4 |
| 10% | 152.9 | 39.7 | 22.1 | 43.5 | 264.9 | 86.3 | 84.5 | 94.0 | 93.1 | 70.0 |
| 30% | 145.2 | 36.7 | 21.3 | 39.8 | 251.9 | 87.4 | 85.9 | 94.2 | 93.3 | 70.6 |
The 0% row equals the baseline row in tab. 2 and tab. 3.
Paper vs code
No official code. The paper gives no code link, and the source has no URL to a repository. The arXiv metadata held in the wiki has no comment field to check. GitHub searches for "focusing attention text recognition" and "attention drift text recognition" found no repository from the authors. "FAN scene text recognition" found only Lornatang/FAN-PyTorch, a third-party PyTorch reimplementation under Apache-2.0. It is not used as code for this card.
Pitfalls
- Focus loss normalisation is not stated. eq. 13 is a plain sum over steps and patch positions, with no division by batch size or count. An earlier version in the source had a 1/N factor and a count of pixel-labelled samples; that text is commented out §3.2. With λ = 0.01 the relative scale of the two losses depends on this choice, which the paper does not state.
- Patch size is not a number. P_H and P_W are "the max-size of ground-truth regions in the input image" §3.2. The paper gives no fixed value, and it does not say how variable-size patches are batched into one tensor.
- Centre location is undefined. eq. 8 uses
location(j)for "the centre of the receptive field". The paper does not give a formula. The natural reading is the midpoint of eq. 7's bounds, but that is an inference. - Crop source is ambiguous. Section 3.2 says the patch comes from "the input image or a convolution output". The implementation section says "we crop feature maps from the input image" §4.2. The paper does not say how image coordinates map to feature-map coordinates after the ResNet strides.
- FN parameter shapes are missing. R, S and b in eq. 11 have no dimensions. The softmax in eq. 12 over K needs e to have K entries, and no output projection is mentioned. Implementers must pick shapes that make this consistent.
- K is inconsistent. eq. 12 says K is "the number of label classes", and §4.2 gives 37 output units. Using 37 is the only reading that matches §4.2.
- Feature count and layer table. In the encoder table each layer spec lists width before height for kernel, stride and padding §4.2. The paper calls the network 32 layers §4.2; the layer count is not checked against the table here. The width of 65 follows from the pool and conv entries in the table under that reading.
- Pixel labels are a cost. About 30% of 4 million synthetic instances carry character positions §4.2. The sweep tab. 8 tab. 9 shows that 1% already gives most of the gain, but the 30% setting is what the headline numbers use. The 0% row matches the baseline, so the paper treats "no pixel labels" as "no focusing loss".
- λ was picked on the evaluation benchmarks. The λ sweep tab. 6 tab. 7 reports test-benchmark results and no separate validation split is named §4.4. The selected λ = 0.01 is therefore tuned on the reported test sets.
- Not every comparison is a win. Baidu IDL is higher on IC15 (77.0 vs 70.6) tab. 2, and Jaderberg et al. 2016 is higher on IC03 Full (98.6 vs 97.3). The paper states both exceptions §4.3.
- Lexicon scoring is underspecified. For constrained decoding the paper says it computes "conditional probability distributions for all lexicon words" and takes the highest §3.4. It does not say whether this is a sum of log-probabilities, nor how the cost grows with lexicon size.
- Dataset filtering. IC03 keeps 867 images after dropping non-alphanumeric labels and words under three characters §4.1. IC15 keeps 1811 of 2077 after dropping non-alphanumeric and irregular text §4.1. Compare numbers only on the same subsets.
- Throughput. About 90 samples per second and about 5 days for about 3 epochs on one M40 GPU §4.2. The paper gives no cost for other hardware.
Lineage
- Builds on: attention alignment of Bahdanau et al. (2014) §3.1; end-of-sequence handling following Sutskever et al. (2014) §3.1; the image encoder released by Shi et al. (2016, robust) §4.2 tab. 4; the end-to-end CNN-RNN work of Shi et al. (2016) §2; the ResNet design of He et al. (2016) §1.
- Related: Kim et al. (2016), joint CTC and attention for speech, where attention drift was also noted; the authors tried CTC with attention for scene text and dropped it §2.
- Compared against: 18 published methods plus a baseline without FN tab. 2.
- Superseded by: not stated in the card's sources.
Source and license
Adapted from “Focusing Attention: Towards Accurate Text Recognition in Natural Images” by Zhanzhan Cheng, Fan Bai, Yunlu Xu, Gang Zheng, Shiliang Pu, Shuigeng Zhou (arXiv:1709.02054), used under CC BY-SA 4.0. Changes: condensed and restructured for implementation, with tables, equations and algorithms taken from the paper and its code, each cited to its source. Not affiliated with or endorsed by the authors. This page is licensed under CC BY-SA 4.0.