摘要:精读PP-OCR以及里面的一些技术。
论文:《PP-OCR: A Practical Ultra Lightweight OCR System》
PP-OCR 由 text detection, detected boxes rectification and text recognition组成,下图为整体框架图。

Text Detection
总体上使用 Differentiable Binarization 作为 text detector,将其中的Backbone换成了MobileNetV3 large x0.5。为什么用MobileNetV3?
理由是,在figure6中,MobileNetV3 can achieve higher accuracy when the predict time are same.
综合了性能(HMean指标后文会说)和速度选择了large x0.5
Backbone是很重要的,这几乎决定了整个Text Detection的速度,所以要找到很好的模型架构。
The size of backbone has dominant effect on the model size of a text detector. Therefore, light backbones should be selected for building the ultra lightweight models
Head 选择了FPN-like 的架构,同时 fuse the feature maps of the different scales 为了提升 small text regions detection 的表现。在fuse different scales 的 feature maps 时,通常使用一个1*1 convolution(简写为inner_channels)。经过实验发现,inner_channels对 model size 有很大的影响,但是减少他会降低正确率。
When inner channels is reduced from 256 to 96, the model size is reduced from 7M to 4.1M, but the accuracy declines slightly.
从下表可以看到,减少inner_channels的维度,直接time减半了
删除了MobileNetV3中大量的SE结构,因为发现输入分辨率较大的时候(640*640),很难estimate the channel-wise feature responses with the SE block。同时开销很大。所以去掉了。
However, when the input resolution is large, such as 640 × 640, it is hard to estimate the channel-wise feature responses with the SE block. The accuracy improvement is limited, but the time cost is very high.
Cosine Learning Rate Decay,关于学习率的调整方法,在figure8中有介绍;Learning Rate Warm-up 在文本分类有效,本文发现在文本检测也是有效的。这两个策略从表中看出可以是相当有效了。
FPGM Pruner,采取原生方法,加上每层不同的剪枝敏感度

Detected boxes rectification
为了把检测框转化为水平矩形(并且里面的文本是正的)。利用图像分类的技术,训练了一个 classifier
\boxed{
y=clip(x,-\alpha,\alpha)
}
Text recognition
使用 CRNN 的架构
Backbone使用MobileNetV3 small x0.5(或者x1.0)
Data Augmentation:除了之前提到的BDA,还加入了TIA,
Cosine Learning Rate Decay:关于学习率的调整方法,同Text Detection
Feature Map Resolution:如图12所示,把一部分的下采样幅度减少。为了让特征图分辨率更大,准确率更高。
Regularization Parameters:添加了 L2 decay
Learning Rate Warm-up:也是关于学习率的,同Text Detection
Light Head:sequence features指的是时间步 * 特征的形式,这里的每个特征维度(即Feature Map Resolution后的输出的维度)的大小对模型大小有很大影响。因为这后面有一个全连接层(d→N,d为特征维度,N为字符个数,这里有d∗N的参数量,一般N在6000左右),如果d过大,参数量会暴增,所以设置为48.
A full connection layer is used to encode the sequence features to the predicted characters in the ordinary. The dimension of the sequence features have an impact on the model size of a text recognizer, especially for Chinese recognition whose characters are more than 6 thousands. Meanwhile, it is not that the higher of the dimension, the stronger of the ability of the sequence features representation. In PP-OCR, the dimension of the sequence features is set to 48 empirically.

Pre-trained Model:如果数据量少,可以利用一个在 ImageNet 预训练的模型来fine-tune。
If the training data is fewer, fine tune the existing networks, which are trained on a large data set such as ImageNet, to achieve fast convergence and better accuracy.
- 同时要用很多的合成数据,因为真实数据很少,用很多的合成数据训练也能达到很好的效果。
PACT Quantization:同Detected boxes rectification,除了LSTM layers被跳过了
Those layers will not be quantified at present since the complexity of LSTM quantization.
数据集
构建了一个数据集,详细可以查看原论文3.1节。重点需要关注以下三点:
不同任务使用完全不同的数据策略
synthetic data 不是简单造数据,而是针对 failure case 设计(例如对于方向分类的,就专门设计反向的。)
真实数据主要承担 domain adaptation,而 synthetic 承担 diversity(即针对真实数据中少见的一些分布,比如Text Detection中少见long text, multi direction text and table text.)
基于 TextRender 来构建的数据集
训练细节
OCR system