---
title: cncv_ocr_recognition
canonical_url: "https://www.modelscope.cn/models/lacoboi/cncv_ocr_recognition"
md_url: "https://www.modelscope.cn/models/lacoboi/cncv_ocr_recognition.md"
repository: lacoboi/cncv_ocr_recognition
chinese_name: "菜鸟视觉算法-文字识别-文本行识别模型-中英"
last_updated: 2023-08-17
license: "Apache License 2.0"
pipeline_tag: ocr-recognition
tasks:
  - ocr-recognition
library_name:
  - onnx
frameworks:
  - onnx
language:
  - en
  - ch
domain:
  - cv
downloads: 415
stars: 8
tags:
  - OCR
  - cainiao
  - "文字识别"
---

# cncv_ocr_recognition

> cncv_ocr_recognition - lacoboi 在 ModelScope 开源的模型。文字识别，即给定一张文本图片，识别出图中所含文字并输出对应字符串

lacoboi/cncv_ocr_recognition 是 ModelScope 魔搭社区上的ocr-recognition模型，采用 Apache License 2.0 许可。

- **Repository**: lacoboi/cncv_ocr_recognition
- **License**: Apache License 2.0
- **Tasks**: ocr-recognition
- **Tags**: OCR, cainiao, 文字识别
- **Downloads**: 415
- **Stars**: 8
- **Last updated**: 2023-08-17

Source: https://www.modelscope.cn/models/lacoboi/cncv_ocr_recognition

---

# 文字识别模型介绍

文字识别，即给定一张文本图片，识别出图中所含文字并输出对应字符串。

本模型用于通用场景(不包含手写场景)的文字识别任务。

欢迎使用！

## 模型描述


本模型主要包括两个主要部分，统一卷积与自注意力机制的主干网络和Enhanced CTC loss（增加Center loss优化相似字符误识别问题），模型训练过程中，使用自蒸馏策略，识别模型结构如下图：     

<p align="center">
    <img src="./resources/pipeline.jpg"/> 
</p>

## 模型测试接结果

在公开中文数据集[Benchmarking-Chinese-Text-Recognition](https://github.com/FudanVI/benchmarking-chinese-text-recognition)上训练并测试，结果如下表所示：

<p align="left">
<table border="1" width="100%">
    <tr align="center">
        <td>Model</td><td>Scene</td><td>Web</td><td>Document</td>
    </tr>
    <tr align="center">
        <td>SAR</td><td>62.5</td><td>54.3</td><td>93.8</td>
    </tr>
    <tr align="center">
        <td>TransOCR</td><td>63.3</td><td>62.3</td><td>96.9</td>
    </tr>
    <tr align="center">
        <td>MaskOCR-base</td><td>73.9</td><td>74.8</td><td>99.3</td>
    </tr>
    <tr align="center">
        <td>OFA-OCR</td><td>82.9</td><td>81.7</td><td>99.1</td>
    </tr>
    <tr align="center">
        <td>CNCV-OCR</td><td>77.28</td><td>78.44</td><td>99.42</td>
    </tr>
</table>
<br>
</p>

与 OFA-OCR 模型对比优势：
1. 在保持精度较高的同时，推理速度快，显存占用少，模型实用性高，在A10机器上耗时(s)对比如下：

<p align="left">
<table border="1" width="100%">
    <tr align="center">
        <td>模型</td><td>batch 1</td><td>batch 16</td><td>batch 32</td><td>batch 64</td>
    </tr>
    <tr align="center">
        <td>OFA-OCR</td><td>0.2534</td><td>2.1695</td><td>4.052</td><td>out-memory</td>
    </tr>
    <tr align="center">
        <td>CNCV-OCR</td><td>0.021</td><td>0.0510</td><td>0.0982</td><td>0.2185</td>
    </tr>
</table>
<br>
</p>

2. 使用CTC解码，对长文本识别效果好；

## 期望模型使用方式以及适用范围


本模型主要用于给输入图片输出图中文字内容，具体地，模型输出内容以字符串形式输出。用户可以自行尝试各种输入图片。具体调用方式请参考代码示例。
- 注：输入图片应为包含文字的单行文本图片。其它如多行文本图片、非文本图片等可能没有返回结果，此时表示模型的识别结果为空。

###
模型可视化效果
以下为模型的可视化文字识别效果。

`TODO`

### 模型局限性以及可能的偏差
- 模型是在中文数据集上训练的，在其他语言或其他场景的数据上有可能产生一定偏差，请用户自行评测后决定如何使用。
- 当前版本在python3.7的CPU环境和单GPU环境测试通过，其他环境下可用性待测试。

## 相关论文以及引用
```
@misc{li2022uniformer,
      title={UniFormer: Unifying Convolution and Self-attention for Visual Recognition}, 
      author={Kunchang Li and Yali Wang and Junhao Zhang and Peng Gao and Guanglu Song and Yu Liu and Hongsheng Li and Yu Qiao},
      year={2022},
      eprint={2201.09450},
      archivePrefix={arXiv},
      primaryClass={cs.CV}
}
@article{ShiBY17,
  author    = {Baoguang Shi and
               Xiang Bai and
               Cong Yao},
  title     = {An End-to-End Trainable Neural Network for Image-Based Sequence Recognition
               and Its Application to Scene Text Recognition},
  journal   = {{IEEE} Trans. Pattern Anal. Mach. Intell.},
  volume    = {39},
  number    = {11},
  pages     = {2298--2304},
  year      = {2017}
}
@article{chen2021benchmarking,
  title={Benchmarking Chinese Text Recognition: Datasets, Baselines, and an Empirical Study},
  author={Chen, Jingye and Yu, Haiyang and Ma, Jianqi and Guan, Mengnan and Xu, Xixi and Wang, Xiaocong and Qu, Shaobo and Li, Bin and Xue, Xiangyang},
  journal={arXiv preprint arXiv:2112.15093},
  year={2021}
}
```
