深度学习
  • 前言
  • 第一章:经典网络
    • ImageNet Classification with Deep Convolutional Neural Network
    • Very Deep Convolutional Networks for Large-Scale Image Recognition
    • Going Deeper with Convolutions
    • Deep Residual Learning for Image Recognition
    • PolyNet: A Pursuit of Structural Diversity in Very Deep Networks
    • Squeeze-and-Excitation Networks
    • Densely Connected Convolutional Networks
    • SQUEEZENET: ALEXNET-LEVEL ACCURACY WITH 50X FEWER PARAMETERS AND <0.5MB MODEL SIZE
    • MobileNet v1 and MobileNet v2
    • Xception: Deep Learning with Depthwise Separable Convolutions
    • Aggregated Residual Transformations for Deep Neural Networks
    • ShuffleNet v1 and ShuffleNet v2
    • CondenseNet: An Efficient DenseNet using Learned Group Convolution
    • Neural Architecture Search with Reinforecement Learning
    • Learning Transferable Architectures for Scalable Image Recognition
    • Progressive Neural Architecture Search
    • Regularized Evolution for Image Classifier Architecture Search
    • 实例解析:12306验证码破解
  • 第二章:自然语言处理
    • Recurrent Neural Network based Language Model
    • Learning Phrase Representations using RNN Encoder-Decoder for Statistical Machine Translation
    • Neural Machine Translation by Jointly Learning to Align and Translate
    • Hierarchical Attention Networks for Document Classification
    • Connectionist Temporal Classification : Labelling Unsegmented Sequence Data with Recurrent Neural Ne
    • About Long Short Term Memory
    • Attention Is All you Need
    • BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding
  • 第三章:语音识别
    • Speech Recognition with Deep Recurrent Neural Network
  • 第四章:物体检测
    • Rich feature hierarchies for accurate object detection and semantic segmentation
    • Spatial Pyramid Pooling in Deep Convolutional Networks for Visual Recognition
    • Fast R-CNN
    • Faster R-CNN: Towards Real-Time Object Detection with Region Proposal Networks
    • R-FCN: Object Detection via Region-based Fully Convolutuional Networks
    • Mask R-CNN
    • You Only Look Once: Unified, Real-Time Object Detection
    • SSD: Single Shot MultiBox Detector
    • YOLO9000: Better, Faster, Stronger
    • Focal Loss for Dense Object Detection
    • YOLOv3: An Incremental Improvement
    • Learning to Segment Every Thing
    • SNIPER: Efficient Multi-Scale Training
  • 第五章:光学字符识别
    • 场景文字检测
      • DeepText: A Unified Framework for Text Proposal Generation and Text Detection in Natural Images
      • Detecting Text in Natural Image with Connectionist Text Proposal Network
      • Scene Text Detection via Holistic, Multi-Channel Prediction
      • Arbitrary-Oriented Scene Text Detection via Rotation Proposals
      • PixelLink: Detecting Scene Text via Instance Segmentation
    • 文字识别
      • Spatial Transform Networks
      • Robust Scene Text Recognition with Automatic Rectification
      • Bidirectional Scene Text Recognition with a Single Decoder
      • multi-task learning for text recognition with joint CTC-attention
    • 端到端文字检测与识别
      • Reading Text in the Wild with Convolutional Neural Networks
      • Deep TextSpotter: An End-to-End Trainable Scene Text Localization and Recognition Framework
    • 实例解析:字符验证码破解
    • 二维信息识别
      • 基于Seq2Seq的公式识别引擎
      • Show and Tell: A Neural Image Caption Generator
      • Show, Attend and Tell: Neural Image Caption Generation with Visual Attention
  • 第六章:语义分割
    • U-Net: Convolutional Networks for Biomedical Image Segmentation
  • 第七章:人脸识别
    • 人脸检测
      • DenseBox: Unifying Landmark Localization with End to End Object Detection
      • UnitBox: An Advanced Object Detection Network
  • 第八章:网络优化
    • Batch Normalization
    • Layer Normalization
    • Weight Normalization
    • Instance Normalization
    • Group Normalization
    • Switchable Normalization
  • 第九章:生成对抗网络
    • Generative Adversarial Nets
  • 其它应用
    • Holistically-Nested Edge Detection
    • Image Style Transfer Using Convolutional Nerual Networks
    • Background Matting: The World is Your Green Screen
  • Tags
  • References
由 GitBook 提供支持
在本页
  • 前言
  • 1. Bi-STR算法详解
  • 1.1 ResNet
  • 1.2 编码层
  • 1.3 解码层
  • 2. 结论

这有帮助吗?

  1. 第五章:光学字符识别
  2. 文字识别

Bidirectional Scene Text Recognition with a Single Decoder

上一页Robust Scene Text Recognition with Automatic Rectification下一页multi-task learning for text recognition with joint CTC-attention

最后更新于4年前

这有帮助吗?

前言

被提出以来,几乎刷榜了NLP的所有任务,自然而然的大伙会想到使用Transformer来做场景文字的识别。而Transformer的特点使其具有了识别弧形文字,二维文字的天然优势。这篇文章提出的Bi-STR算法便是在卷积特征之后加入了Transformer同时作为编码器和解码器,同时加入了位置编码和方向编码来作为额外的特征。Bi-STR大幅刷新了ASTER的识别准确率,尤其是长文本的识别准确率。

1. Bi-STR算法详解

图1:Bi-STR网络结构图

Bi-STR的网络结构如图1所示,从图1左侧的高层架构我们可以看出它是由3个主要部分组成:

  1. 残差网络:用作图像的像素编码,用于计算其Feature Map;

  2. 由NNN个编码层组成的编码器;

  3. NNN个解码层组成的解码器,解码器有两个输出,分别是从左向右(ltr)以及从右想左(rtl)。

1.1 ResNet

ResNet被广泛的用于文字识别的骨干网络,这里采用了一个45层的残差网络。通过这个网络,我们可以得到输入图像的特征表示,这里表示为Q∈RW×C×H\mathcal{Q} \in \mathbb{R} ^ {W\times C \times H}Q∈RW×C×H,或者表示为长度为www的特征序列,即v1,...,vW\mathbf{v}_1, ..., \mathbf{v}_Wv1​,...,vW​, 其中 vi∈RC×H\mathbf{v}_i \in \mathbb{R} ^ {C\times H}vi​∈RC×H。

1.2 编码层

从图1的中间部分我们可以看出,ResNet得到的特征层Q\mathcal{Q}Q加上位置编码信息直接给到由自注意力机制组成的Transformer编码层,这里使用的是多头的Self-Attention。关于Transformer的详细讲解,可以看我的另外一篇文章,这里只对网络流程做一下梳理。

1: 使用不同的3个特征矩阵乘以图像特征Q\mathcal{Q}Q,我们得到3个不同的向量,他们分别是Query向量(Q\mathbf{Q}Q),Key向量(K\mathbf{K}K)和Value向量(V\mathbf{V}V)。 2: 根据Q,K,V\mathbf{Q}, \mathbf{K}, \mathbf{V}Q,K,V我们可以得到Self-Attention的矩阵表示:

Attention(Q,K,V)=softmax(QKTd)V.Attention(\mathbf{Q}, \mathbf{K}, \mathbf{V}) = \text{softmax}\left(\frac{\mathbf{Q}\mathbf{K}^T}{\sqrt{d}}\right)\mathbf{V}.Attention(Q,K,V)=softmax(d​QKT​)V.

3: 多头自注意力机制

Multi-Head Self Attention是由多个Single-Head Self拼接而成的,表示为

headi=Attention(QWiQ,KWiK,VWiV)head_{i} = \text{Attention}(\mathbf{QW}^Q_i, \mathbf{KW}^K_i, \mathbf{VW}^V_i)headi​=Attention(QWiQ​,KWiK​,VWiV​)

多头Self-Attention表示为

MultiHeadSelfAttention=Concat(head1,...,headh)WOMultiHeadSelfAttention = Concat(head_1, ..., head_h)\mathbf{W}^OMultiHeadSelfAttention=Concat(head1​,...,headh​)WO

其中WiQ∈Rdmodel×dk,WiK∈Rdmodel×dk,WiV∈Rdmodel×dv\mathbf{W}^Q_i \in \mathbb{R} ^ {d_\text{model} \times d_k}, \mathbf{W}^K_i \in \mathbb{R} ^ {d_\text{model} \times d_k}, \mathbf{W}^V_i \in \mathbb{R} ^ {d_\text{model} \times d_v}WiQ​∈Rdmodel​×dk​,WiK​∈Rdmodel​×dk​,WiV​∈Rdmodel​×dv​ 以及WO∈Rhdv×dmodel\mathbf{W} ^ O \in \mathbb{R} ^ {hd_v \times d_\text{model}}WO∈Rhdv​×dmodel​是参数矩阵。

4:与Feature Map一起提供给编码器的位置向量,它的编码方式和Transformer论文提供的方式相同。

1.3 解码层

图1右侧的是Bi-STR的解码层,它的输入一个是编码器的输出,还有三个分别是方向嵌入,词位置嵌入以及词嵌入。

1.3.1 Embeddings

首先方向嵌入是为了模拟双向RNN结构引入的编码器,作用是告诉模型是从左向右编码还是从右向左编码,关于方向编码具体的实现细节,论文中没有给出。另外两个向量分别是词向量和词位置向量,比较简单不再赘述。

1.3.2 解码层模型

解码器可以拆分成两个主要模块,第一个是Masked Multi-Head Self-Attention也叫做decoder self-attention, 他的输入是1.3.1中的所有Embeddings。它之所以叫Masked是因为输入给他的只有已经解码得到的序列的内容。解码器的第二个模块是一个Multi-Head Self Attention,也叫做decoder cross-attention,他的输入是上个解码器的输出以及图像的Feature Map。

Bi-STR的两个解码结构分别侧重于对文本和图像编码,而不是像其它的解码器笼统的把文本和图像一起输入。这种解耦的结构使得不同的模块侧重于不同的内容,更有利于网络学习不同的特征。

2. 结论

这篇文章介绍了使用Transformer来做文字识别,通过添加不同的embedding层来保证模型和任务的适配性,但遗憾的是几个编码器的细节作者并没有给与特别详细的解释。笔者之前也尝试过使用Transformer来进行二维文字的识别,但是考虑到Transformer的自回归的特性,导致网络的运行时间非常漫长,所以如何提升Transformer的测试速度是下一步急需解决的问题。

Transformer
图1:Bi-STR网络结构图