first commit
Some checks are pending
Build/Publish Develop Docs / deploy (push) Waiting to run

This commit is contained in:
2025-07-02 08:57:16 +03:00
commit 56532cc9a9
1901 changed files with 457695 additions and 0 deletions

63
docs/FAQ.en.md Normal file
View File

@@ -0,0 +1,63 @@
---
comments: true
hide:
- navigation
- toc
---
1. **Prediction error: got an unexpected keyword argument 'gradient_clip'**
The installed version of paddle is incorrect. Currently, this project only supports Paddle 1.7, which will be adapted to 1.8 in the near future.
2. **Error when converting attention recognition model: KeyError: 'predict'**
Solved. Please update to the latest version of the code.
3. **About inference speed**
When there are many words in the picture, the prediction time will increase. You can use `--rec_batch_num` to set a smaller prediction batch num. The default value is 30, which can be changed to 10 or other values.
4. **Service deployment and mobile deployment**
It is expected that the service deployment based on Serving and the mobile deployment based on Paddle Lite will be released successively in mid-to-late June. Stay tuned for more updates.
5. **Release time of self-developed algorithm**
Baidu Self-developed algorithms such as SAST, SRN and end2end PSL will be released in June or July. Please be patient.
6. **How to run on Windows or Mac?**
PaddleOCR has completed the adaptation to Windows and MAC systems. Two points should be noted during operation:
1. In [Quick installation](./installation_en.md), if you do not want to install docker, you can skip the first step and start with the second step.
2. When downloading the inference model, if wget is not installed, you can directly click the model link or copy the link address to the browser to download, then extract and place it in the corresponding directory.
7. **The difference between ultra-lightweight model and General OCR model**
At present, PaddleOCR has opensourced two Chinese models, namely 8.6M ultra-lightweight Chinese model and general Chinese OCR model. The comparison information between the two is as follows:
- Similarities: Both use the same **algorithm** and **training data**
- Differences: The difference lies in **backbone network** and **channel parameters**, the ultra-lightweight model uses MobileNetV3 as the backbone network, the general model uses Resnet50_vd as the detection model backbone, and Resnet34_vd as the recognition model backbone. You can compare the two model training configuration files to see the differences in parameters.
|Model|Backbone|Detection configuration file|Recognition configuration file|
|-|-|-|-|
|8.6M ultra-lightweight Chinese OCR model|MobileNetV3+MobileNetV3|det_mv3_db.yml|rec_chinese_lite_train.yml|
|General Chinese OCR model|Resnet50_vd+Resnet34_vd|det_r50_vd_db.yml|rec_chinese_common_train.yml|
8. **Is there a plan to opensource a model that only recognizes numbers or only English + numbers?**
It is not planned to opensource numbers only, numbers + English only, or other vertical text models. PaddleOCR has opensourced a variety of detection and recognition algorithms for customized training. The two Chinese models are also based on the training output of the open-source algorithm library. You can prepare the data according to the tutorial, choose the appropriate configuration file, train yourselves, and we believe that you can get good result. If you have any questions during the training, you are welcome to open issues or ask in the communication group. We will answer them in time.
9. **What is the training data used by the open-source model? Can it be opensourced?**
At present, the open source model, dataset and magnitude are as follows:
- Detection:
English dataset: ICDAR2015
Chinese dataset: LSVT street view dataset with 3w pictures
- Recognition:
English dataset: MJSynth and SynthText synthetic dataset, the amount of data is tens of millions.
Chinese dataset: LSVT street view dataset with cropped text area, a total of 30w images. In addition, the synthesized data based on LSVT corpus is 500w.
Among them, the public datasets are opensourced, users can search and download by themselves, or refer to [Chinese data set](dataset/datasets_en.md), synthetic data is not opensourced, users can use open-source synthesis tools to synthesize data themselves. Current available synthesis tools include [text_renderer](https://github.com/Sanster/text_renderer), [SynthText](https://github.com/ankush-me/SynthText), [TextRecognitionDataGenerator](https://github.com/Belval/TextRecognitionDataGenerator), etc.
10. **Error in using the model with TPS module for prediction**
Error message: Input(X) dims[3] and Input(Grid) dims[2] should be equal, but received X dimension[3]\(108) != Grid dimension[2]\(100)
Solution: TPS does not support variable shape. Please set --rec_image_shape='3,32,100' and --rec_char_type='en'
11. **Custom dictionary used during training, the recognition results show that words do not appear in the dictionary**
The used custom dictionary path is not set when making prediction. The solution is setting parameter `rec_char_dict_path` to the corresponding dictionary file.
12. **Results of cpp_infer and python_inference are very different**
Versions of exported inference model and inference library should be same. For example, on Windows platform, version of the inference library that PaddlePaddle provides is 1.8, but version of the inference model that PaddleOCR provides is 1.7, you should export model yourself(`tools/export_model.py`) on PaddlePaddle 1.8 and then use the exported model for inference.
13. **How to identify artistic fonts in signs or advertising images**
Recognizing artistic fonts in signs or advertising images is a very challenging task because the variation in individual characters is much greater compared to standard fonts. If the artistic font to be identified is within a dictionary list, each word in the dictionary can be treated as a template for recognition using a general image retrieval system. You can try using PaddleClas image recognition system.

778
docs/FAQ.md Normal file
View File

@@ -0,0 +1,778 @@
---
comments: true
hide:
- navigation
- toc
---
> 恭喜你发现宝藏!
PaddleOCR收集整理了自从开源以来在issues和用户群中的常见问题并且给出了简要解答旨在为OCR的开发者提供一些参考也希望帮助大家少走一些弯路。
其中[通用问题](#1)一般是初次接触OCR相关算法时用户会提出的问题在[1.5 垂类场景实现思路](#15)中总结了如何在一些具体的场景中确定技术路线进行优化。[PaddleOCR常见问题](#2-paddleocr)是开发者在使用PaddleOCR之后可能会遇到的问题也是PaddleOCR实践过程中的避坑指南。
同时PaddleOCR也会在review issue的过程中添加 `good issue``good first issue` 标签但这些问题可能不会被立刻补充在FAQ文档里开发者也可对应查看。我们也非常希望开发者能够帮助我们将这些内容补充在FAQ中。
OCR领域大佬众多本文档回答主要依赖有限的项目实践难免挂一漏万如有遗漏和不足也**希望有识之士帮忙补充和修正**,万分感谢。
## 1. 通用问题
### 1.1 检测
#### Q: 基于深度学习的文字检测方法有哪几种?各有什么优缺点?
**A**:常用的基于深度学习的文字检测方法一般可以分为基于回归的、基于分割的两大类,当然还有一些将两者进行结合的方法。
1基于回归的方法分为box回归和像素值回归。a. 采用box回归的方法主要有CTPN、Textbox系列和EAST这类算法对规则形状文本检测效果较好但无法准确检测不规则形状文本。 b. 像素值回归的方法主要有CRAFT和SA-Text这类算法能够检测弯曲文本且对小文本效果优秀但是实时性能不够。
2基于分割的算法如PSENet这类算法不受文本形状的限制对各种形状的文本都能取得较好的效果但是往往后处理比较复杂导致耗时严重。目前也有一些算法专门针对这个问题进行改进如DB将二值化进行近似使其可导融入训练从而获取更准确的边界大大降低了后处理的耗时。
### 1.2 识别
#### Q: PaddleOCR提供的文本识别算法包括哪些
**A**PaddleOCR主要提供五种文本识别算法包括CRNN\StarNet\RARE\Rosetta和SRN, 其中CRNN\StarNet和Rosetta是基于ctc的文字识别算法RARE是基于attention的文字识别算法SRN为百度自研的文本识别算法引入了语义信息显著提升了准确率。 详情可参照如下页面: 文本识别算法
#### Q: 文本识别方法CRNN关键技术有哪些
**A**CRNN 关键技术包括三部分。1CNN提取图像卷积特征。2深层双向LSTM网络在卷积特征的基础上继续提取文字序列特征。3Connectionist Temporal Classification(CTC),解决训练时字符无法对齐的问题。
#### Q: 对于中文行文本识别CTC和Attention哪种更优
**A**1从效果上来看通用OCR场景CTC的识别效果优于Attention因为带识别的字典中的字符比较多常用中文汉字三千字以上如果训练样本不足的情况下对于这些字符的序列关系挖掘比较困难。中文场景下Attention模型的优势无法体现。而且Attention适合短语句识别对长句子识别比较差。
2从训练和预测速度上Attention的串行解码结构限制了预测速度而CTC网络结构更高效预测速度上更有优势。
#### Q: 弯曲形变的文字识别需要怎么处理TPS应用场景是什么是否好用
**A**1在大多数情况下如果遇到的场景弯曲形变不是太严重检测4个顶点然后直接通过仿射变换转正识别就足够了。
2如果不能满足需求可以尝试使用TPSThin Plate Spline即薄板样条插值。TPS是一种插值算法经常用于图像变形等通过少量的控制点就可以驱动图像进行变化。一般用在有弯曲形变的文本识别中当检测到不规则的/弯曲的使用基于分割的方法检测算法文本区域往往先使用TPS算法对文本区域矫正成矩形再进行识别STAR-Net、RARE等识别算法中引入了TPS模块。
> **Warning**TPS看起来美好在实际应用时经常发现并不够鲁棒并且会增加耗时需要谨慎使用。
### 1.3 端到端
#### Q: 请问端到端的pgnet相比于DB+CRNN在准确率上有优势吗或者是pgnet最擅长的场景是什么场景呢
**A**pgnet是端到端算法检测识别一步到位不用分开训练2个模型也支持弯曲文本的识别但是在中文上的效果还没有充分验证db+crnn的验证更充分应用相对成熟常规非弯曲的文本都能解的不错。
#### Q: 目前OCR普遍是二阶段端到端的方案在业界落地情况如何
**A**端到端在文字分布密集的业务场景效率会比较有保证精度的话看自己业务数据积累情况如果行级别的识别数据积累比较多的话two-stage会比较好。百度的落地场景比如工业仪表识别、车牌识别都用到端到端解决方案。
#### Q: 二阶段的端到端的场景文本识别方法的不足有哪些?
**A**这类方法一般需要设计针对ROI提取特征的方法而ROI操作一般比较耗时。
#### Q: AAAI 2021最新的端到端场景文本识别PGNet算法有什么特点
**A**PGNet不需要字符级别的标注NMS操作以及ROI操作。同时提出预测文本行内的阅读顺序模块和基于图的修正模块来提升文本识别效果。该算法是百度自研近期会在PaddleOCR开源。
### 1.4 评估方法
#### Q: OCR领域常用的评估指标是什么
**A**:对于两阶段的可以分开来看,分别是检测和识别阶段
1检测阶段先按照检测框和标注框的IOU评估IOU大于某个阈值判断为检测准确。这里检测框和标注框不同于一般的通用目标检测框是采用多边形进行表示。检测准确率正确的检测框个数在全部检测框的占比主要是判断检测指标。检测召回率正确的检测框个数在全部标注框的占比主要是判断漏检的指标。
2识别阶段
字符识别准确率,即正确识别的文本行占标注的文本行数量的比例,只有整行文本识别对才算正确识别。
3端到端统计
端对端召回率:准确检测并正确识别文本行在全部标注文本行的占比;
端到端准确率:准确检测并正确识别文本行在 检测到的文本行数量 的占比;
准确检测的标准是检测框与标注框的IOU大于某个阈值正确识别的检测框中的文本与标注的文本相同。
### 1.5 垂类场景实现思路
#### Q背景干扰的文字如印章盖到落款上需要识别落款或者印章中的文字如何识别
**A**1在人眼确认可识别的条件下对于背景有干扰的文字首先要保证检测框足够准确如果检测框不准确需要考虑是否可以通过过滤颜色等方式对图像预处理并且增加更多相关的训练数据在识别的部分注意在训练数据中加入背景干扰类的扩增图像。
2如果MobileNet模型不能满足需求可以尝试ResNet系列大模型来获得更好的效果。
#### Q请问对于图片中的密集文字有什么好的处理办法吗
**A**可以先试用预训练模型测试一下例如DB+CRNN判断下密集文字图片中是检测还是识别的问题然后针对性的改善。还有一种是如果图象中密集文字较小可以尝试增大图像分辨率对图像进行一定范围内的拉伸将文字稀疏化提高识别效果。
#### Q 文本行较紧密的情况下如何准确检测?
**A**使用基于分割的方法如DB检测密集文本行时最好收集一批数据进行训练并且在训练时并将生成二值图像的shrink_ratio参数调小一些。
#### Q对于一些在识别时稍微模糊的文本有没有一些图像增强的方式
**A**在人类肉眼可以识别的前提下可以考虑图像处理中的均值滤波、中值滤波或者高斯滤波等模糊算子尝试。也可以尝试从数据扩增扰动来强化模型鲁棒性另外新的思路有对抗性训练和超分SR思路可以尝试借鉴。但目前业界尚无普遍认可的最优方案建议优先在数据采集阶段增加一些限制提升图片质量。
#### Q低像素文字或者字号比较小的文字有什么超分辨率方法吗
**A**超分辨率方法分为传统方法和基于深度学习的方法。基于深度学习的方法中比较经典的有SRCNN另外CVPR2020也有一篇超分辨率的工作可以参考文章Unpaired Image Super-Resolution using Pseudo-Supervision但是没有充分的实践验证过需要看实际场景下的效果。
#### Q对于一些尺寸较大的文档类图片在检测时会有较多的漏检怎么避免这种漏检的问题呢
**A**PaddleOCR中在图像最长边大于960时将图像等比例缩放为长边960的图像再进行预测对于这种图像可以通过修改det_limit_side_len增大检测的最长边tools/infer/utility.py#L42
#### Q文档场景中使用DB模型会出现整行漏检的情况应该怎么解决
**A**:可以在预测时调小 det_db_box_thresh 阈值默认为0.5, 可调小至0.3观察效果。
#### Q: 弯曲文本(如略微形变的文档图像)漏检问题
**A**: db后处理中计算文本框平均得分时是求rectangle区域的平均分数容易造成弯曲文本漏检已新增求polygon区域的平均分数会更准确但速度有所降低可按需选择在相关pr中可查看[可视化对比效果](https://github.com/PaddlePaddle/PaddleOCR/pull/2604)。该功能通过参数 [det_db_score_mode](https://github.com/PaddlePaddle/PaddleOCR/blob/release/2.1/tools/infer/utility.py#L51)进行选择,参数值可选[`fast`(默认)、`slow`]`fast`对应原始的rectangle方式`slow`对应polygon方式。感谢用户[buptlihang](https://github.com/buptlihang)提[pr](https://github.com/PaddlePaddle/PaddleOCR/pull/2574)帮助解决该问题🌹。
#### Q如何识别文字比较长的文本
**A**:在中文识别模型训练时,并不是采用直接将训练样本缩放到[3,32,320]进行训练而是先等比例缩放图像保证图像高度为32宽度不足320的部分补0宽高比大于10的样本直接丢弃。预测时如果是单张图像预测则按上述操作直接对图像缩放不做宽度320的限制。如果是多张图预测则采用batch方式预测每个batch的宽度动态变换采用这个batch中最长宽度。
#### Q如何识别带空格的英文行文本图像
**A**:空格识别可以考虑以下两种方案:
(1)优化文本检测算法。检测结果在空格处将文本断开。这种方案在检测数据标注时,需要将含有空格的文本行分成好多段。
(2)优化文本识别算法。在识别字典里面引入空格字符,然后在识别的训练数据中,如果用空行,进行标注。此外,合成数据时,通过拼接训练数据,生成含有空格的文本。
#### Q弯曲文本有试过opencv的TPS进行弯曲校正吗
**A**opencv的tps需要标出上下边界对应的点这个点很难通过传统方法或者深度学习方法获取。PaddleOCR里StarNet网络中的tps模块实现了自动学点自动校正可以直接尝试这个。
#### Q: 如何识别招牌或者广告图中的艺术字?
**A**: 招牌或者广告图中的艺术字是文本识别一个非常有挑战性的难题因为艺术字中的单字和印刷体相比变化非常大。如果需要识别的艺术字是在一个词典列表内可以将改每个词典认为是一个待识别图像模板通过通用图像检索识别系统解决识别问题。可以尝试使用PaddleClas的图像识别系统。
#### Q: 印章如何识别
**A**1. 使用带tps的识别网络或abcnet,2.使用极坐标变换将图片拉平之后使用crnn
#### Q: 使用预训练模型进行预测,对于特定字符识别识别效果较差,怎么解决?
**A**: 由于我们所提供的识别模型是基于通用大规模数据集进行训练的部分字符可能在训练集中包含较少因此您可以构建特定场景的数据集基于我们提供的预训练模型进行微调。建议用于微调的数据集中每个字符出现的样本数量不低于300但同时需要注意不同字符的数量均衡。具体可以参考微调。
#### Q: 在使用训练好的识别模型进行预测的时候,发现有很多重复的字,这个怎么解决呢?
**A**:可以看下训练的尺度和预测的尺度是否相同,如果训练的尺度为[3, 32, 320],预测的尺度为[3, 64, 640],则会有比较多的重复识别现象。
#### Q: 图像正常识别出来的文字是OK的旋转90度后识别出来的结果就比较差有什么方法可以优化
**A**: 整图旋转90之后效果变差是有可能的因为目前PPOCR默认输入的图片是正向的 可以自己训练一个整图的方向分类器,放在预测的最前端(可以参照现有方向分类器的方式),或者可以基于规则做一些预处理,比如判断长宽等等。
#### Q: 如何识别竹简上的古文?
**A**对于字符都是普通的汉字字符的情况只要标注足够的数据finetune模型就可以了。如果数据量不足您可以尝试[StyleText](https://github.com/PFCCLab/StyleText)工具。
而如果使用的字符是特殊的古文字、甲骨文、象形文字等,那么首先需要构建一个古文字的字典,之后再进行训练。
#### Q: 只想要识别票据中的部分片段,重新训练它的话,只需要训练文本检测模型就可以了吗?问文本识别,方向分类还是用原来的模型这样可以吗?
**A**可以的。PaddleOCR的检测、识别、方向分类器三个模型是独立的在实际使用中可以优化和替换其中任何一个模型。
#### Q: 如何用PaddleOCR识别视频中的文字
**A**: 目前PaddleOCR主要针对图像做处理如果需要视频识别可以先对视频抽帧然后用PPOCR识别。
#### Q: 相机采集的图像为四通道,应该如何处理?
**A**: 有两种方式处理:
- 如果没有其他需要可以在解码数据的时候指定模式为三通道例如如果使用opencv可以使用cv::imread(img_path, cv::IMREAD_COLOR)。
- 如果其他模块需要处理四通道的图像那也可以在输入PaddleOCR模块之前进行转换例如使用cvCvtColor(&img,img3chan,CV_RGBA2RGB)。
#### Q: 遇到中英文识别模型不支持的字符,该如何对模型做微调?
**A**:如果希望识别中英文识别模型中不支持的字符,需要更新识别的字典,并完成微调过程。比如说如果希望模型能够进一步识别罗马数字,可以按照以下步骤完成模型微调过程。
1. 准备中英文识别数据以及罗马数字的识别数据,用于训练,同时保证罗马数字和中英文识别数字的效果;
2. 修改默认的字典文件,在后面添加罗马数字的字符;
3. 下载PaddleOCR提供的预训练模型配置预训练模型和数据的路径开始训练。
#### Q特殊字符例如一些标点符号识别效果不好怎么办
**A**:首先请您确认要识别的特殊字符是否在字典中。
如果字符在已经字典中但效果依然不好可能是由于识别数据较少导致的您可以增加相应数据finetune模型。
---
#### Q单张图上多语种并存识别如单张图印刷体和手写文字并存应该如何处理
**A**单张图像中存在多种类型文本的情况很常见典型的以学生的试卷为代表一张图像同时存在手写体和印刷体两种文本这类情况下可以尝试”1个检测模型+1个N分类模型+N个识别模型”的解决方案。
其中不同类型文本共用同一个检测模型N分类模型指额外训练一个分类器将检测到的文本进行分类如手写+印刷的情况就是二分类N种语言就是N分类在识别的部分针对每个类型的文本单独训练一个识别模型如手写+印刷的场景,就需要训练一个手写体识别模型,一个印刷体识别模型,如果一个文本框的分类结果是手写体,那么就传给手写体识别模型进行识别,其他情况同理。
#### Q: 多语言的字典里是混合了不同的语种,这个是有什么讲究吗?统一到一个字典里会对精度造成多大的损失?
**A**统一到一个字典里会造成最后一层FC过大增加模型大小。如果有特殊需求的话可以把需要的几种语言合并字典训练模型合并字典之后如果引入过多的形近字可能会造成精度损失字符平衡的问题可能也需要考虑一下。在PaddleOCR里暂时将语言字典分开。
#### Q类似泰语这样的小语种部分字会占用两个字符甚至三个字符请问如何制作字典
**A**:处理字符的时候,把多字符的当作一个字就行,字典中每行是一个字。
---
#### Q: 想把简历上的文字识别出来后能够把关系一一对应起来比如姓名和它后面的名字组成一对籍贯、邮箱、学历等等都和各自的内容关联起来这个应该如何处理PPOCR目前支持吗
**A**: 这样的需求在企业应用中确实比较常见,但往往都是个性化的需求,没有非常规整统一的处理方式。常见的处理方式有如下两种:
1. 对于单一版式、或者版式差异不大的应用场景,可以基于识别场景的一些先验信息,将识别内容进行配对; 比如运用表单结构信息:常见表单"姓名"关键字的后面,往往紧跟的就是名字信息
2. 对于版式多样,或者无固定版式的场景, 需要借助于NLP中的NER技术给识别内容中的某些字段赋予key值
由于这部分需求和业务场景强相关难以用一个统一的模型去处理目前PPOCR暂不支持。 如果需要用到NER技术可以参照Paddle团队的另一个开源套件: [PaddlePaddle/ERNIE](https://github.com/PaddlePaddle/ERNIE) 其提供的预训练模型ERNIE, 可以帮助提升NER任务的准确率。
### 1.6 训练过程与模型调优
#### Q: 增大batch_size模型训练速度没有明显提升
**A**如果batch_size打得太大加速效果不明显的话可以试一下增大初始化内存的值运行代码前设置环境变量
export FLAGS_initial_cpu_memory_in_mb=2000 # 设置初始化内存约2G左右
#### Q: 预测时提示图像过大,显存、内存溢出了,应该如何处理?
**A**可以按照这个PR的修改来缓解显存、内存占用 #2230
#### Q: 识别训练时训练集精度已经到达90了但验证集精度一直在70涨不上去怎么办
**A**训练集精度90测试集70多的话应该是过拟合了有两个可尝试的方法1加入更多的增广方式或者调大增广prob的概率默认为0.4。2调大系统的l2 decay值
### 1.7 补充资料
#### Q: 对于小白如何快速入门中文OCR项目实践
**A**建议可以先了解OCR方向的基础知识大概了解基础的检测和识别模型算法。然后在Github上可以查看OCR方向相关的repo。目前来看从内容的完备性来看PaddleOCR的中英文双语教程文档是有明显优势的在数据集、模型训练、预测部署文档详实可以快速入手。而且还有微信用户群答疑非常适合学习实践。项目地址PaddleOCR AI 快车道课程:<https://aistudio.baidu.com/aistudio/course/introduce/1519>
## 2. PaddleOCR实战问题
### 2.1 PaddleOCR repo
#### Q: PaddleOCR develop分支和dygraph分支的区别
**A**目前PaddleOCR有四个分支分别是
- develop基于Paddle静态图开发的分支推荐使用paddle1.8 或者2.0版本该分支具备完善的模型训练、预测、推理部署、量化裁剪等功能领先于release/1.1分支。
- release/1.1PaddleOCR 发布的第一个稳定版本,基于静态图开发,具备完善的训练、预测、推理部署、量化裁剪等功能。
- dygraph基于Paddle动态图开发的分支目前仍在开发中未来将作为主要开发分支运行要求使用Paddle2.0.0版本。
- release/2.0-rc1-0PaddleOCR发布的第二个稳定版本基于动态图和paddle2.0版本开发,动态图开发的工程更易于调试,目前支,支持模型训练、预测,暂不支持移动端部署。
如果您已经上手过PaddleOCR并且希望在各种环境上部署PaddleOCR目前建议使用静态图分支develop或者release/1.1分支。如果您是初学者想快速训练调试PaddleOCR中的算法建议尝鲜PaddleOCR dygraph分支。
**注意**develop和dygraph分支要求的Paddle版本、本地环境有差别请注意不同分支环境安装部分的差异。
#### QPaddleOCR与百度的其他OCR产品有什么区别
**A**PaddleOCR主要聚焦通用ocr如果有垂类需求您可以用PaddleOCR+垂类数据自己训练;
如果缺少带标注的数据或者不想投入研发成本建议直接调用开放的API开放的API覆盖了目前比较常见的一些垂类。
### 2.2 安装环境
#### QOSError [WinError 126] 找不到指定的模块。mac pro python 3.4 shapely import 问题
**A**这个问题是因为shapely库安装有误可以参考 #212 这个issue重新安装一下
#### QPaddlePaddle怎么指定GPU运行 os.environ["CUDA_VISIBLE_DEVICES"]这种不生效
**A**:通过设置 export CUDA_VISIBLE_DEVICES='0'环境变量
#### QPaddleOCR是否支持在Windows或Mac系统上运行
**A**PaddleOCR已完成Windows和Mac系统适配运行时注意两点
1在快速安装时如果不想安装docker可跳过第一步直接从第二步安装paddle开始。
2inference模型下载时如果没有安装wget可直接点击模型链接或将链接地址复制到浏览器进行下载并解压放置到相应目录。
### 2.3 数据量说明
#### Q简单的对于精度要求不高的OCR任务数据集需要准备多少张呢
**A**1训练数据的数量和需要解决问题的复杂度有关系。难度越大精度要求越高则数据集需求越大而且一般情况实际中的训练数据越多效果越好。
2对于精度要求不高的场景检测任务和识别任务需要的数据量是不一样的。对于检测任务500张图像可以保证基本的检测效果。对于识别任务需要保证识别字典中每个字符出现在不同场景的行文本图像数目需要大于200张举例如果有字典中有5个字每个字都需要出现在200张图片以上那么最少要求的图像数量应该在200-1000张之间这样可以保证基本的识别效果。
#### Q请问PaddleOCR项目中的中文超轻量和通用模型用了哪些数据集训练多少样本gpu什么配置跑了多少个epoch大概跑了多久
**A**
1检测的话LSVT街景数据集共3W张图像超轻量模型150epoch左右2卡V100 跑了不到2天通用模型2卡V100 150epoch 不到4天。
2识别的话520W左右的数据集真实数据26W+合成数据500W训练超轻量模型4卡V100总共训练了5天左右。通用模型4卡V100共训练6天。
超轻量模型训练分为2个阶段
(1)全量数据训练50epoch耗时3天
(2)合成数据+真实数据按照1:1数据采样进行finetune训练200epoch耗时2天
通用模型训练:
真实数据+合成数据,动态采样(11)训练200epoch耗时 6天左右。
#### Q训练文字识别模型真实数据有30w合成数据有500w需要做样本均衡吗
**A**需要一般需要保证一个batch中真实数据样本和合成数据样本的比例是51~101左右效果比较理想。如果合成数据过大会过拟合到合成数据预测效果往往不佳。还有一种启发性的尝试是可以先用大量合成数据训练一个base模型然后再用真实数据微调在一些简单场景效果也是会有提升的。
#### Q: 当训练数据量少时,如何获取更多的数据?
**A**当训练数据量少时可以尝试以下三种方式获取更多的数据1人工采集更多的训练数据最直接也是最有效的方式。2基于PIL和opencv基本图像处理或者变换。例如PIL中ImageFont, Image, ImageDraw三个模块将文字写到背景中opencv的旋转仿射变换高斯滤波等。3利用数据生成算法合成数据例如pix2pix等算法。
### 2.4 数据标注与生成
> [!NOTE]
> StyleText 已经移动到 [PFCCLab/StyleText](https://github.com/PFCCLab/StyleText)
#### Q: Style-Text 如何不文字风格迁移,就像普通文本生成程序一样默认字体直接输出到分割的背景图?
**A**使用image_synth模式会输出fake_bg.jpg即为背景图。如果想要批量提取背景可以稍微修改一下代码将fake_bg保存下来即可。要修改的位置
<https://github.com/PaddlePaddle/PaddleOCR/blob/de3e2e7cd3b8b65ee02d7a41e570fa5b511a3c1d/StyleText/engine/synthesisers.py#L68>
#### Q: 能否修改StyleText配置文件中的分辨率
**A**StyleText目前的训练数据主要是高度32的图片建议不要改变高度。未来我们会支持更丰富的分辨率。
#### Q: StyleText是否可以更换字体文件
**A**StyleText项目中的字体文件为标准字体主要用作模型的输入部分不能够修改。
StyleText的用途主要是提取style_image中的字体、背景等style信息根据语料生成同样style的图片。
#### Q: StyleText批量生成图片为什么没有输出
**A**:需要检查以下您配置文件中的路径是否都存在。尤其要注意的是[label_file配置](https://github.com/PFCCLab/StyleText/blob/main/README_ch.md#%E4%B8%89%E5%BF%AB%E9%80%9F%E4%B8%8A%E6%89%8B)。
如果您使用的style_image输入没有label信息您依然需要提供一个图片文件列表。
#### Q使用StyleText进行数据合成时文本(TextInput)的长度远超StyleInput的长度该怎么处理与合成呢
**A**在使用StyleText进行数据合成的时候建议StyleInput的长度长于TextInput的长度。有2种方法可以处理上述问题
1. 将StyleInput按列的方向进行复制与扩充直到其超过TextInput的长度。
2. 将TextInput进行裁剪保证每段TextInput都稍短于StyleInput分别合成之后,再拼接在一起。
实际使用中发现使用第2种方法的效果在长文本合成的场景中的合成效果更好StyleText中提供的也是第2种数据合成的逻辑。
#### Q: StyleText 合成数据效果不好?
**A**StyleText模型生成的数据主要用于OCR识别模型的训练。PaddleOCR目前识别模型的输入为32 x N因此当前版本模型主要适用高度为32的数据。
建议要合成的数据尺寸设置为32 x N。尺寸相差不多的数据也可以生成尺寸很大或很小的数据效果确实不佳。
### 2.5 预训练模型与微调
#### Q如何更换文本检测/识别的backbone
**A**无论是文字检测还是文字识别骨干网络的选择是预测效果和预测效率的权衡。一般选择更大规模的骨干网络例如ResNet101_vd则检测或识别更准确但预测耗时相应也会增加。而选择更小规模的骨干网络例如MobileNetV3_small_x0_35则预测更快但检测或识别的准确率会大打折扣。幸运的是不同骨干网络的检测或识别效果与在ImageNet数据集图像1000分类任务效果正相关。飞桨图像分类套件PaddleClas汇总了ResNet_vd、Res2Net、HRNet、MobileNetV3、GhostNet等23种系列的分类网络结构在上述图像分类任务的top1识别准确率GPU(V100和T4)和CPU(骁龙855)的预测耗时以及相应的117个预训练模型下载地址。
1文字检测骨干网络的替换主要是确定类似于ResNet的4个stages以方便集成后续的类似FPN的检测头。此外对于文字检测问题使用ImageNet训练的分类预训练模型可以加速收敛和效果提升。
2文字识别的骨干网络的替换需要注意网络宽高stride的下降位置。由于文本识别一般宽高比例很大因此高度下降频率少一些宽度下降频率多一些。可以参考PaddleOCR中MobileNetV3骨干网络的改动。
#### Q: 参照文档做实际项目时,是重新训练还是在官方训练的基础上进行训练?具体如何操作?
**A** 基于官方提供的模型进行finetune的话收敛会更快一些。 具体操作上以识别模型训练为例如果修改了字符文件可以设置pretraind_model为官方提供的预训练模型
#### Q: 下载的识别模型解压后缺失文件没有期望的inference.pdiparams, inference.pdmodel等文件
**A**用解压软件解压可能会出现这个问题建议二次解压下或者用命令行解压tar xf
#### Q: 为什么在checkpoints中load下载的预训练模型会报错
**A**:这里有两个不同的概念:
pretrained_model指预训练模型是已经训练完成的模型。这时会load预训练模型的参数但并不会load学习率、优化器以及训练状态等。如果需要finetune应该使用pretrained。
checkpoints指之前训练的中间结果例如前一次训练到了100个epoch想接着训练。这时会load尝试所有信息包括模型的参数之前的状态等。
#### Q: 如何对检测模型finetune比如冻结前面的层或某些层使用小的学习率学习
**A**如果是冻结某些层可以将变量的stop_gradient属性设置为True这样计算这个变量之前的所有参数都不会更新了参考<https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/faq/train_cn.html#id4>
如果对某些层使用更小的学习率学习,静态图里还不是很方便,一个方法是在参数初始化的时候,给权重的属性设置固定的学习率,参考:<https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/fluid/param_attr/ParamAttr_cn.html#paramattr>
实际上我们实验发现直接加载模型去fine-tune不设置某些层不同学习率效果也都不错
### 2.6 模型超参调整
#### Q: DB检测训练输入尺寸640可以改大一些吗
**A**不建议改大。检测模型训练输入尺寸是预处理中random crop后的尺寸并非直接将原图进行resize多数场景下这个尺寸并不小了改大后可能反而并不合适而且训练会变慢。另外代码里可能有的地方参数按照预设输入尺寸适配的改大后可能有隐藏风险。
#### Q: 预处理部分图片的长和宽为什么要处理成32的倍数
**A**以检测中的resnet骨干网络为例图像输入网络之后需要经过5次2倍降采样共32倍因此建议输入的图像尺寸为32的倍数。
#### Q: 在识别模型中为什么降采样残差结构的stride为(2, 1)
**A**: stride为(2, 1)表示在图像y方向高度方向上stride为2x方向宽度方向上为1。由于待识别的文本图像通常为长方形这样只在高度方向做下采样尽量保留宽度方向的序列信息避免宽度方向下采样后丢失过多的文字信息。
#### Q训练识别时如何选择合适的网络输入shape
**A**一般高度采用32最长宽度的选择有两种方法
1统计训练样本图像的宽高比分布。最大宽高比的选取考虑满足80%的训练样本。
2统计训练样本文字数目。最长字符数目的选取考虑满足80%的训练样本。然后中文字符长宽比近似认为是1英文认为31预估一个最长宽度。
#### Q识别模型框出来的位置太紧凑会丢失边缘的文字信息导致识别错误
**A**:可以在命令中加入 --det_db_unclip_ratio 参数定义位置这个参数是检测后处理时控制文本框大小的默认1.6可以尝试改成2.5或者更大,反之,如果觉得文本框不够紧凑,也可以把该参数调小。
### 2.7 模型结构
#### Q文本识别训练不加LSTM是否可以收敛
**A**理论上是可以收敛的加上LSTM模块主要是为了挖掘文字之间的序列关系提升识别效果。对于有明显上下文语义的场景效果会比较明显。
#### Q文本识别中LSTM和GRU如何选择
**A**从项目实践经验来看序列模块采用LSTM的识别效果优于GRU但是LSTM的计算量比GRU大一些可以根据自己实际情况选择。
#### Q对于CRNN模型backbone采用DenseNet和ResNet_vd哪种网络结构更好
**A**Backbone的识别效果在CRNN模型上的效果与Imagenet 1000 图像分类任务上识别效果和效率一致。在图像分类任务上ResnNet_vd79%+的识别精度明显优于DenseNet77%+此外对于GPUNvidia针对ResNet系列模型做了优化预测效率更高所以相对而言resnet_vd是较好选择。如果是移动端可以优先考虑MobileNetV3系列。
#### Q: 如何根据不同的硬件平台选用不同的backbone
**A**在不同的硬件上不同的backbone的速度优势不同可以根据不同平台的速度-精度图来确定backbone这里可以参考[PaddleClas模型速度-精度图](https://github.com/PaddlePaddle/PaddleClas/tree/release/2.0/docs/zh_CN/models)。
### 2.8 PP-OCR系统
#### Q: 在PP-OCR系统中文本检测的骨干网络为什么没有使用SE模块
**A**SE模块是MobileNetV3网络一个重要模块目的是估计特征图每个特征通道重要性给特征图每个特征分配权重提高网络的表达能力。但是对于文本检测输入网络的分辨率比较大一般是640\*640利用SE模块估计特征图每个特征通道重要性比较困难网络提升能力有限但是该模块又比较耗时因此在PP-OCR系统中文本检测的骨干网络没有使用SE模块。实验也表明当去掉SE模块超轻量模型大小可以减小40%文本检测效果基本不受影响。详细可以参考PP-OCR技术文章<https://arxiv.org/abs/2009.09941>.
#### Q: PP-OCR系统中文本检测的结果有置信度吗
**A**:文本检测的结果有置信度,由于推理过程中没有使用,所以没有显示的返回到最终结果中。如果需要文本检测结果的置信度,可以在[文本检测DB的后处理代码](../ppocr/postprocess/db_postprocess.py)的155行添加scores信息。这样在[检测预测代码](../tools/infer/predict_det.py)的197行就可以拿到文本检测的scores信息。
#### Q: DB文本检测特征提取网络金字塔构建的部分代码在哪儿
**A**:特征提取网络金字塔构建的部分:[代码位置](../ppocr/modeling/necks/db_fpn.py)。ppocr/modeling文件夹里面是组网相关的代码其中architectures是文本检测或者文本识别整体流程代码backbones是骨干网络相关代码necks是类似与FPN的颈函数代码heads是提取文本检测或者文本识别预测结果相关的头函数transforms是类似于TPS特征预处理模块。更多的信息可以参考[代码组织结构](./tree.md)。
#### QPaddleOCR如何做到横排和竖排同时支持的
**A**合成了一批竖排文字逆时针旋转90度后加入训练集与横排一起训练。预测时根据图片长宽比判断是否为竖排若为竖排则将crop出的文本逆时针旋转90度后送入识别网络。
#### Q: 目前知识蒸馏有哪些主要的实践思路?
**A**知识蒸馏即利用教师模型指导学生模型的训练目前有3种主要的蒸馏思路
1. 基于输出结果的蒸馏即让学生模型学习教师模型的软标签分类或者OCR识别等任务中或者概率热度图分割等任务中
2. 基于特征图的蒸馏,即让学生模型学习教师模型中间层的特征图,拟合中间层的一些特征。
3. 基于关系的蒸馏针对不同的样本假设个数为N教师模型会有不同的输出那么可以基于不同样本的输出计算一个NxN的相关性矩阵可以让学生模型去学习教师模型关于不同样本的相关性矩阵。
当然,知识蒸馏方法日新月异,也欢迎大家提出更多的总结与建议。
#### Q: 文字识别模型模型的输出矩阵需要进行解码才能得到识别的文本。代码中实现为preds_idx = preds.argmax(axis=2)也就是最佳路径解码法。这是一种贪心算法是每一个时间步只将最大概率的字符作为当前时间步的预测输出但得到的结果不一定是最好的。为什么不使用beam search这种方式进行解码呢
**A**实验发现使用贪心的方法去做解码识别精度影响不大但是速度方面的优势比较明显因此PaddleOCR中使用贪心算法去做识别的解码。
### 2.9 端到端
#### Q: 端到端算法PGNet是否支持中文识别速度会很慢嘛
**A**目前开源的PGNet算法模型主要是用于检测英文数字对于中文的识别需要自己训练大家可以使用开源的端到端中文数据集而对于复杂文本弯曲文本的识别也可以自己构造一批数据集针对进行训练对于推理速度可以先将模型转换为inference再进行预测速度应该会相当可观。
#### Q: 端到端算法PGNet提供了两种后处理方式两者之间有什么区别呢
**A**: 两种后处理的区别主要在于速度的推理config中PostProcess有fast/slow两种模式slow模式的后处理速度慢精度相对较高fast模式的后处理速度快精度也在可接受的范围之内。建议使用速度快的后处理方式。
#### Q: 使用PGNet进行eval报错
**A**: 需要注意我们目前在release/2.1更新了评测代码目前支持AB两种评测模式
- A模式该模式主要为了方便用户使用与训练集一样的标注文件就可以正常进行eval操作, 代码中默认是A模式。
- B模式该模式主要为了保证我们的评测代码可以和Total Text官方的评测方式对齐该模式下直接加载官方提供的mat文件进行eval。
#### Q: PGNet有中文预训练模型吗
**A**: 目前我们尚未提供针对中文的预训练模型,如有需要,可以尝试自己训练。具体需要修改的地方有:
1. [config文件中](https://github.com/PaddlePaddle/PaddleOCR/blob/release/2.1/configs/e2e/e2e_r50_vd_pg.yml#L23-L24),字典文件路径及语种设置;
1. [网络结构中](https://github.com/PaddlePaddle/PaddleOCR/blob/release/2.1/ppocr/modeling/heads/e2e_pg_head.py#L181)`out_channels`修改为字典中的字符数目+1考虑到空格
1. [loss中](https://github.com/PaddlePaddle/PaddleOCR/blob/release/2.1/ppocr/losses/e2e_pg_loss.py#L93),修改`37`为字典中的字符数目+1考虑到空格
#### Q: 用于PGNet的训练集文本框的标注有要求吗
**A**: PGNet支持多点标注比如4点、8点、14点等。但需要注意的是标注点尽可能分布均匀相邻标注点间隔距离均匀一致且label文件中的标注点需要从标注框的左上角开始按标注点顺时针顺序依次编写以上问题都可能对训练精度造成影响。
我们提供的基于Total Text数据集的PGNet预训练模型使用了14点标注方式。
#### Q: 用PGNet做进行端到端训练时数据集标注的点的个数必须都是统一一样的吗? 能不能随意标点数,只要能够按顺时针从左上角开始标这样?
**A**: 目前代码要求标注为统一的点数。
### 2.10 模型效果与效果不一致
#### Q: PP-OCR检测效果不好该如何优化
**A** 具体问题具体分析:
如果在你的场景上检测效果不可用首选是在你的数据上做finetune训练
如果图像过大文字过于密集建议不要过度压缩图像可以尝试修改检测预处理的resize逻辑防止图像被过度压缩
检测框大小过于紧贴文字或检测框过大可以调整db_unclip_ratio这个参数加大参数可以扩大检测框减小参数可以减小检测框大小
检测框存在很多漏检问题可以减小DB检测后处理的阈值参数det_db_box_thresh防止一些检测框被过滤掉也可以尝试设置det_db_score_mode为'slow';
其他方法可以选择use_dilation为True对检测输出的feature map做膨胀处理一般情况下会有效果改善
#### Q同一张图通用检测出21个条目轻量级检测出26个 ,难道不是轻量级的好吗?
**A**:可以主要参考可视化效果,通用模型更倾向于检测一整行文字,轻量级可能会有一行文字被分成两段检测的情况,不是数量越多,效果就越好。
#### Q: DB有些框太贴文本了反而去掉了一些文本的边角影响识别这个问题有什么办法可以缓解吗
**A**可以把后处理的参数unclip_ratio适当调大一点。
#### Q: 使用合成数据精调小模型后效果可以但是还没开源的小infer模型效果好这是为什么呢
**A**1要保证使用的配置文件和pretrain weights是对应的
2在微调时一般都需要真实数据如果使用合成数据效果反而可能会有下降PaddleOCR中放出的识别inference模型也是基于预训练模型在真实数据上微调得到的效果提升比较明显
3在训练的时候文本长度超过25的训练图像都会被丢弃因此需要看下真正参与训练的图像有多少太少的话也容易过拟合。
#### Q: 表格识别中,如何提高单字的识别结果?
**A**: 首先需要确认一下检测模型有没有有效的检测出单个字符,如果没有的话,需要在训练集当中添加相应的单字数据集。
#### Q: 动态图分支(dygraph,release/2.0),训练模型和推理模型效果不一致
**A**当前问题表现为使用训练完的模型直接测试结果较好但是转换为inference model后预测结果不一致出现这个问题一般是两个原因
1. 预处理函数设置的不一致
2. 后处理参数不一致 repo中config.yml文件的前后处理参数和inference预测默认的超参数有不一致的地方建议排查下训练模型预测和inference预测的前后处理 参考issue。
#### Q: 自己训练的det模型在同一张图片上inference模型与eval模型结果差别很大为什么
**A**这是由于图片预处理不同造成的。如果训练的det模型图片输入并不是默认的shape[600, 600]eval的程序中图片预处理方式与train时一致 由xxx_reader.yml中的test_image_shape参数决定缩放大小但predict_eval.py中的图片预处理方式由程序里的preprocess_params决定 最好不要传入max_side_len而是传入和训练时一样大小的test_image_shape。
#### Q: 训练模型和测试模型的检测结果差距较大
**A**1. 检查两个模型使用的后处理参数是否是一样的训练的后处理参数在配置文件中的PostProcess部分测试模型的后处理参数在tools/infer/utility.py中最新代码中两个后处理参数已保持一致。
#### Q: PaddleOCR模型Python端预测和C++预测结果不一致?
**A**正常来说python端预测和C++预测文本是一致的,如果预测结果差异较大, 建议首先排查diff出现在检测模型还是识别模型或者尝试换其他模型是否有类似的问题。 其次检查python端和C++端数据处理部分是否存在差异建议保存环境更新PaddleOCR代码再试下。 如果更新代码或者更新代码都没能解决建议在PaddleOCR微信群里或者issue中抛出您的问题。
用户总结的排查步骤:<https://github.com/PaddlePaddle/PaddleOCR/issues/2470>
### 2.11 训练调试与配置文件
#### Q: 某个类别的样本比较少通过增加训练的迭代次数或者是epoch变相增加小样本的数目这样能缓解这个问题么
**A** 尽量保证类别均衡, 某些类别样本少,可以通过补充合成数据的方式处理;实验证明训练集中出现频次较少的字符,识别效果会比较差,增加迭代次数不能改变样本量少的问题。
#### Q文本检测换成自己的数据没法训练有一些”###”是什么意思?
**A**:数据格式有问题,”###” 表示要被忽略的文本区域,所以你的数据都被跳过了,可以换成其他任意字符或者就写个空的。
#### Q如何调试数据读取程序
**A**tools/train.py中有一个test_reader()函数用于调试数据读取。
#### Q中文文本检测、文本识别构建训练集的话大概需要多少数据量
**A**检测需要的数据相对较少在PaddleOCR模型的基础上进行Fine-tune一般需要500张可达到不错的效果。 识别分英文和中文,一般英文场景需要几十万数据可达到不错的效果,中文则需要几百万甚至更多。
#### Q: config yml文件中的ratio_list参数的作用是什么
**A**: 在动态图中ratio_list在有多个数据源的情况下使用ratio_list中的每个值是每个epoch从对应数据源采样数据的比例。如ratio_list=[0.3,0.2]label_file_list=['data1','data2'],代表每个epoch的训练数据包含data1 30%的数据和data2里 20%的数据ratio_list中数值的和不需要等于1。ratio_list和label_file_list的长度必须一致。
静态图检测数据采样的逻辑与动态图不同,但基本不影响训练精度。
在静态图中,使用 检测 dataloader读取数据时会先设置每个epoch的数据量比如这里设置为1000ratio_list中的值表示在1000中的占比比如ratio_list是[0.3, 0.7]则表示使用两个数据源每个epoch从第一个数据源采样1000*0.3=300张图从第二个数据源采样700张图。ratio_list的值的和也不需要等于1。
#### Q: iaa里面添加的数据增强方式是每张图像训练都会做增强还是随机的如何添加一个数据增强方法
**A**iaa增强的训练配置参考[这里](https://github.com/PaddlePaddle/PaddleOCR/blob/0ccc1720c252beb277b9e522a1b228eb6abffb8a/configs/det/ch_ppocr_v2.0/ch_det_mv3_db_v2.0.yml#L82)。其中{ 'type': Fliplr, 'args': { 'p': 0.5 } } p是概率。新增数据增强可以参考[这个方法](https://github.com/PaddlePaddle/PaddleOCR/blob/release%2F2.1/doc/doc_ch/add_new_algorithm.md#%E6%95%B0%E6%8D%AE%E5%8A%A0%E8%BD%BD%E5%92%8C%E5%A4%84%E7%90%86)
#### Q: 怎么加速训练过程呢?
**A**OCR模型训练过程中一般包含大量的数据增广这些数据增广是比较耗时的因此可以离线生成大量增广后的图像直接送入网络进行训练机器资源充足的情况下也可以使用分布式训练的方法可以参考[分布式训练教程文档](https://github.com/PaddlePaddle/PaddleOCR/blob/dygraph/doc/doc_ch/distributed_training.md)。
#### Q: 一些特殊场景的数据识别效果差但是数据量很少不够用来finetune怎么办
**A**:您可以合成一些接近使用场景的数据用于训练。
我们计划推出基于特定场景的文本数据合成工具请您持续关注PaddleOCR的近期更新。
#### Q: PaddleOCR可以识别灰度图吗
**A**PaddleOCR的模型均为三通道输入。如果您想使用灰度图作为输入建议直接用3通道的模式读入灰度图
或者将单通道图像转换为三通道图像再识别。例如opencv的cvtColor函数就可以将灰度图转换为RGB三通道模式。
#### Q: 如何合成手写中文数据集?
**A**: 手写数据集可以通过手写单字数据集合成得到。随机选取一定数量的单字图片和对应的label将图片高度resize为随机的统一高度后拼接在一起即可得到合成数据集。对于需要添加文字背景的情况建议使用阈值化将单字图片的白色背景处理为透明背景再与真实背景图进行合成。具体可以参考文档[手写数据集](https://github.com/PaddlePaddle/PaddleOCR/blob/a72d6f23be9979e0c103d911a9dca3e4613e8ccf/doc/doc_ch/handwritten_datasets.md)。
#### QPaddleOCR默认不是200个step保存一次模型吗为啥文件夹下面都没有生成
**A**因为默认保存的起始点不是0而是4000将eval_batch_step [4000, 5000]改为[0, 2000] 就是从第0次迭代开始每2000迭代保存一次模型
#### Q: PaddleOCR在训练的时候一直使用cosine_decay的学习率下降策略这是为什么呢
**A**cosine_decay表示在训练的过程中学习率按照cosine的变化趋势逐渐下降至0在迭代轮数更长的情况下比常量的学习率变化策略会有更好的收敛效果因此在实际训练的时候均采用了cosine_decay来获得精度更高的模型。
#### Q: Cosine学习率的更新策略是怎样的训练过程中为什么会在一个值上停很久
**A**: Cosine学习率的说明可以参考[这里](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/optimizer/lr/CosineAnnealingDecay_cn.html#cosineannealingdecay)
在PaddleOCR中为了让学习率更加平缓我们将其中的epoch调整成了iter。
学习率的更新会和总的iter数量有关。当iter比较大时会经过较多iter才能看出学习率的值有变化。
#### Q: 之前的CosineWarmup方法为什么不见了
**A**: 我们对代码结构进行了调整目前的Cosine可以覆盖原有的CosineWarmup的功能只需要在配置文件中增加相应配置即可。
例如下面的代码可以设置warmup为2个epoch
```
lr:
name: Cosine
learning_rate: 0.001
warmup_epoch: 2
```
#### Q: 训练识别和检测时学习率要加上warmup目的是什么
**A**: Warmup机制先使学习率从一个较小的值逐步升到一个较大的值而不是直接就使用较大的学习率这样有助于模型的稳定收敛。在OCR检测和OCR识别中一般会带来精度~0.5%的提升。
#### Q: 关于dygraph分支中文本识别模型训练要使用数据增强应该如何设置
**A**:可以参考[配置文件](../configs/rec/ch_ppocr_v2.0/rec_chinese_lite_train_v2.0.yml)在`Train['dataset']['transforms']`添加RecAug字段使数据增强生效。可以通过添加对aug_prob设置表示每种数据增强采用的概率。aug_prob默认是0.4。详细设置可以参考[ISSUE 1744](https://github.com/PaddlePaddle/PaddleOCR/issues/1744)。
#### Q: 训练过程中,训练程序意外退出/挂起,应该如何解决?
**A**: 考虑内存显存使用GPU训练的话是否不足可在配置文件中将训练和评估的batch size调小一些。需要注意训练batch size调小时学习率learning rate也要调小一般可按等比例调整。
#### Q: 训练程序启动后直到结束看不到训练过程log
**A**: 可以从以下三方面考虑:
1. 检查训练进程是否正常退出、显存占用是否释放、是否有残留进程如果确定是训练程序卡死可以检查环境配置遇到环境问题建议使用docker可以参考说明文档[安装](https://github.com/PaddlePaddle/PaddleOCR/blob/release/2.1/doc/doc_ch/installation.md)。
2. 检查数据集的数据量是否太小可调小batch size从而增加一个epoch中的训练step数量或在训练config文件中将参数print_batch_step改为1即每一个step打印一次log信息。
3. 如果使用私有数据集训练可先用PaddleOCR提供/推荐的数据集进行训练,排查私有数据集是否存在问题。
#### Q: 配置文件中的参数num workers是什么意思应该如何设置
**A**: 训练数据的读取需要硬盘IO而硬盘IO速度远小于GPU运算速度为了避免数据读取成为训练速度瓶颈可以使用多进程读取数据num workers表示数据读取的进程数量0表示不使用多进程读取。在Linux系统下多进程读取数据时进程间通信需要基于共享内存因此使用多进程读取数据时建议设置共享内存不低于2GB最好可以达到8GB此时num workers可以设置为CPU核心数。如果机器硬件配置较低或训练进程卡死、dataloader报错可以将num workers设置为0即不使用多进程读取数据。
### 2.12 预测
#### Q: 为什么PaddleOCR检测预测是只支持一张图片测试即test_batch_size_per_card=1
**A**测试的时候对图像等比例缩放最长边960不同图像等比例缩放后长宽不一致无法组成batch所以设置为test_batch_size为1。
#### Q: PaddleOCR支持tensorrt推理吗
**A**支持的需要在编译的时候将CMakeLists.txt文件当中将相关代码option(WITH_TENSORRT "Compile demo with TensorRT." OFF)的OFF改成ON。关于服务器端部署的更多设置可以参考飞桨官网
#### Q: 如何使用TensorRT加速PaddleOCR预测
**A** 目前paddle的dygraph分支已经支持了python和C++ TensorRT预测的代码python端inference预测时把参数[--use_tensorrt=True](https://github.com/PaddlePaddle/PaddleOCR/blob/3ec57e8df9263de6fa897e33d2d91bc5d0849ef3/tools/infer/utility.py#L37)即可,
C++TensorRT预测需要使用支持TRT的预测库并在编译时打开[-DWITH_TENSORRT=ON](https://github.com/PaddlePaddle/PaddleOCR/blob/3ec57e8df9263de6fa897e33d2d91bc5d0849ef3/deploy/cpp_infer/tools/build.sh#L15)。
如果想修改其他分支代码支持TensorRT预测可以参考[PR](https://github.com/PaddlePaddle/PaddleOCR/pull/2921)。
建议使用TensorRT大于等于6.1.0.5以上的版本。
#### Q: 为什么识别模型做预测的时候,预测图片的数量数量还会影响预测的精度
**A** 推理时识别模型默认的batch_size=6, 如预测图片长度变化大可能影响预测效果。如果出现上述问题可在推理的时候设置识别bs=1命令如下
```bash linenums="1"
python3 tools/infer/predict_rec.py --image_dir="./doc/imgs_words/ch/word_4.jpg" --rec_model_dir="./PP-OCRv3_mobile_rec_infer/" --rec_batch_num=1
```
### 2.13 推理部署
#### QPaddleOCR模型推理方式有几种各自的优缺点是什么
**A**:目前推理方式支持基于训练引擎推理和基于预测引擎推理。
1基于训练引擎推理不需要转换模型但是需要先组网再load参数语言只支持python不适合系统集成。
2基于预测引擎的推理需要先转换模型为inference格式然后可以进行不需要组网的推理语言支持c++和python适合系统集成。
#### QPaddleOCR中对于模型预测加速CPU加速的途径有哪些基于TenorRT加速GPU对输入有什么要求
**A**1CPU可以使用mkldnn进行加速对于python inference的话可以把enable_mkldnn改为true[参考代码](https://github.com/PaddlePaddle/PaddleOCR/blob/dygraph/tools/infer/utility.py#L99)对于cpp inference的话可参考[文档](https://github.com/PaddlePaddle/PaddleOCR/tree/dygraph/deploy/cpp_infer)
2GPU需要注意变长输入问题等TRT6 之后才支持变长输入
#### Qhubserving、pdserving这两种部署方式区别是什么
**A**hubserving原本是paddlehub的配套服务部署工具可以很方便的将paddlehub内置的模型部署为服务paddleocr使用了这个功能并将模型路径等参数暴露出来方便用户自定义修改。paddle serving是面向所有paddle模型的部署工具文档中可以看到我们提供了快速版和标准版其中快速版和hubserving的本质是一样的而标准版基于rpc更稳定更适合分布式部署。
#### Q: 目前paddle hub serving 只支持 imgpath如果我想用imgurl 去哪里改呢?
**A**:图片是在[这里](https://github.com/PaddlePaddle/PaddleOCR/blob/67ef25d593c4eabfaaceb22daade4577f53bed81/deploy/hubserving/ocr_system/module.py#L55)读取的, 可以参考下面的写法将url path转化为np array
```
response = request.urlopen('http://i1.whymtj.com/uploads/tu/201902/9999/52491ae4ba.jpg')
img_array = np.array(bytearray(response.read()), dtype=np.uint8)
img = cv.imdecode(img_array, -1)
```
#### Q: C++ 端侧部署可以只对OCR的检测部署吗
**A**可以的识别和检测模块是解耦的。如果想对检测部署需要自己修改一下main函数 只保留检测相关就可以: [参考](https://github.com/PaddlePaddle/PaddleOCR/blob/de3e2e7cd3b8b65ee02d7a41e570fa5b511a3c1d/deploy/cpp_infer/src/main.cpp#L72)
#### Q服务部署可以只发布文本识别而不带文本检测模型么
**A**可以的。默认的服务部署是检测和识别串联预测的。也支持单独发布文本检测或文本识别模型比如使用PaddleHUBPaddleOCR 模型时deploy下有三个文件夹分别是
ocr_det检测预测
ocr_rec: 识别预测
ocr_system: 检测识别串联预测
#### Q: lite预测库和nb模型版本不匹配该如何解决
**A** 如果可以正常预测就不用管如果这个问题导致无法正常预测可以尝试使用同一个commit的Paddle Lite代码编译预测库和opt文件可以参考[移动端部署教程](https://github.com/PaddlePaddle/PaddleOCR/blob/release%2F2.1/deploy/lite/readme.md)。
#### Q如何将PaddleOCR预测模型封装成SDK
**A**如果是Python的话可以使用tools/infer/predict_system.py中的TextSystem进行sdk封装如果是c++的话可以使用deploy/cpp_infer/src下面的DBDetector和CRNNRecognizer完成封装
#### Q为什么PaddleOCR检测预测是只支持一张图片测试即test_batch_size_per_card=1
**A**测试的时候对图像等比例缩放最长边960不同图像等比例缩放后长宽不一致无法组成batch所以设置为test_batch_size为1。
#### Q为什么第一张张图预测时间很长第二张之后预测时间会降低
**A**:第一张图需要显存资源初始化,耗时较多。完成模型加载后,之后的预测时间会明显缩短。
#### Q: 采用Paddle-Lite进行端侧部署出现问题环境没问题
**A**如果你的预测库是自己编译的那么你的nb文件也要自己编译用同一个lite版本。不能直接用下载的nb文件因为版本不同。
#### Q: 如何多进程运行paddleocr
**A**实例化多个paddleocr服务然后将服务注册到注册中心之后通过注册中心统一调度即可关于注册中心可以搜索eureka了解一下具体使用其他的注册中心也行。
#### Q: 如何多进程预测?
**A**: 近期PaddleOCR新增了[多进程预测控制参数](https://github.com/PaddlePaddle/PaddleOCR/blob/a312647be716776c1aac33ff939ae358a39e8188/tools/infer/utility.py#L103)`use_mp`表示是否使用多进程,`total_process_num`表示在使用多进程时的进程数。具体使用方式请参考[文档](https://github.com/PaddlePaddle/PaddleOCR/blob/release/2.1/doc/doc_ch/inference.md#1-%E8%B6%85%E8%BD%BB%E9%87%8F%E4%B8%AD%E6%96%87ocr%E6%A8%A1%E5%9E%8B%E6%8E%A8%E7%90%86)。
#### Q: 怎么解决paddleOCR在T4卡上有越预测越慢的情况
**A**
1. T4 GPU没有主动散热因此在测试的时候需要在每次infer之后需要sleep 30ms否则机器容易因为过热而降频(inference速度会变慢),温度过高也有可能会导致宕机。
2. T4在不使用的时候也有可能会降频因此在做benchmark的时候需要锁频下面这两条命令可以进行锁频。
```
nvidia-smi -i 0 -pm ENABLED
nvidia-smi --lock-gpu-clocks=1590 -i 0
```
#### Q: 在windows上进行cpp inference的部署时总是提示找不到`paddle_fluid.dll`和`opencv_world346.dll`
**A**有2种方法可以解决这个问题
1. 将paddle预测库和opencv库的地址添加到系统环境变量中。
2. 将提示缺失的dll文件拷贝到编译产出的`ocr_system.exe`文件夹中。
#### Q: win下C++部署中文识别乱码的解决方法
**A**: win下编码格式不是utf8,而ppocr_keys_v1.txt的编码格式的utf8将ppocr_keys_v1.txt 的编码从utf-8修改为 Ansi 编码格式就行了。
#### Q: windows 3060显卡GPU模式启动 加载模型慢
**A**: 30系列的显卡需要使用cuda11。
#### Q想在Mac上部署从哪里下载预测库呢
**A**Mac上的Paddle预测库可以从这里下载[https://paddle-inference-lib.bj.bcebos.com/mac/2.0.0/cpu_avx_openblas/paddle_inference.tgz](https://paddle-inference-lib.bj.bcebos.com/mac/2.0.0/cpu_avx_openblas/paddle_inference.tgz)
#### Q内网环境如何进行服务化部署呢
**A**仍然可以使用PaddleServing或者HubServing进行服务化部署保证内网地址可以访问即可。
#### Q: 使用hub_serving部署延时较高可能的原因是什么呀
**A**: 首先测试的时候第一张图延时较高可以多测试几张然后观察后几张图的速度其次如果是在cpu端部署serving端模型如backbone为ResNet34耗时较慢建议在cpu端部署mobile如backbone为MobileNetV3模型。
#### Q: 在使用PaddleLite进行预测部署时启动预测后卡死/手机死机?
**A**: 请检查模型转换时所用PaddleLite的版本和预测库的版本是否对齐。即PaddleLite版本为2.8则预测库版本也要为2.8。
#### Q: 预测时显存爆炸、内存泄漏问题?
**A**: 打开显存/内存优化开关`enable_memory_optim`可以解决该问题,相关代码已合入,[查看详情](https://github.com/PaddlePaddle/PaddleOCR/blob/release/2.1/tools/infer/utility.py#L153)。

View File

@@ -0,0 +1,336 @@
---
comments: true
typora-copy-images-to: images
---
# Appendix
This appendix contains python, document specifications and Pull Request process.
## Appendix 1Python Code Specification
The Python code of PaddleOCR follows [PEP8 Specification]( https://www.python.org/dev/peps/pep-0008/ ), some of the key concerns include the following
- Space
- Spaces should be added after commas, semicolons, colons, not before them
```python linenums="1"
# true:
print(x, y)
# false:
print(x , y)
```
- When specifying a keyword parameter or default parameter value in a function, do not use spaces on both sides of it
```python linenums="1"
# true:
def complex(real, imag=0.0)
# false:
def complex(real, imag = 0.0)
```
- comment
- Inline comments: inline comments are indicated by the` # `sign. Two spaces should be left between code and` # `, and one space should be left between` # `and comments, for example
```python linenums="1"
x = x + 1 # Compensate for border
```
- Functions and methods: The definition of each function should include the following:
- Function description: Utility, input and output of function
- Args: Name and description of each parameter
- Returns: The meaning and type of the return value
```python linenums="1"
def fetch_bigtable_rows(big_table, keys, other_silly_variable=None):
"""Fetches rows from a Bigtable.
Retrieves rows pertaining to the given keys from the Table instance
represented by big_table. Silly things may happen if
other_silly_variable is not None.
Args:
big_table: An open Bigtable Table instance.
keys: A sequence of strings representing the key of each table row
to fetch.
other_silly_variable: Another optional variable, that has a much
longer name than the other args, and which does nothing.
Returns:
A dict mapping keys to the corresponding table row data
fetched. Each row is represented as a tuple of strings. For
example:
{'Serak': ('Rigel VII', 'Preparer'),
'Zim': ('Irk', 'Invader'),
'Lrrr': ('Omicron Persei 8', 'Emperor')}
If a key from the keys argument is missing from the dictionary,
then that row was not found in the table.
"""
pass
```
## Appendix 2: Document Specification
### 2.1 Overall Description
- Document Location: If you add new features to your original Markdown file, please **Do not re-create** a new file. If you don't know where to add it, you can first PR the code and then ask the official in commit.
- New Markdown Document Name: Describe the content of the document in English, typically a combination of lowercase letters and underscores, such as `add_New_Algorithm.md`
- New Markdown Document Format: Catalog - Body - FAQ
> The directory generation method can use [this site](https://ecotrust-canada.github.io/markdown-toc/ ) Automatically extract directories after copying MD contents, and then add `
- English and Chinese: Any changes or additions to the document need to be made in both Chinese and English documents.
### 2.2 Format Specification
- Title format: The document title format follows the format of: Arabic decimal point combination-space-title (for example, `2.1 XXXX`, `2.XXXX`)
- Code block: Displays code in code block format that needs to be run, describing the meaning of command parameters before the code block. for example:
> Pipeline of detection + direction Classify + recognition: Vertical text can be recognized after set direction classifier parameters`--use_angle_cls true`.
>
> ```bash linenums="1"
> paddleocr --image_dir ./imgs/11.jpg --use_angle_cls true
> ```
- Variable References: If code variables or command parameters are referenced in line, they need to be represented in line code, for example, above `--use_angle_cls true` with one space in front and one space in back
- Uniform naming: e.g. PP-OCRv2, PP-OCR mobile, `paddleocr` whl package, PPOCRLabel, Paddle Lite, etc.
- Supplementary notes: Supplementary notes by reference format `>`.
- Picture: If a picture is added to the description document, specify the naming of the picture (describing its content) and add the picture under `doc/`.
- Title: Capitalize the first letter of each word in the title.
## Appendix 3: Pull Request Description
### 3.1 PaddleOCR Branch Description
PaddleOCR will maintain two branches in the future, one for each:
- release/x.x family branch: stable release version branch, also the default branch. PaddleOCR releases a new release branch based on feature updates and adapts to the release version of Paddle. As versions iterate, more and more release/x.x family branches are maintained by default with the latest version of the release branch.
- dygraph branch: For the development branch, adapts the dygraph version of the Paddle dynamic graph to primarily develop new functionality. If you need to redevelop, choose the dygraph branch. To ensure that the dygraph branch pulls out the release/x.x branch when needed, the code for the dygraph branch can only use the valid API in the latest release branch of Paddle. That is, if a new API has been developed in the Paddle dygraph branch but has not yet appeared in the release branch code, do not use it in Paddle OCR. In addition, performance optimization, parameter tuning, policy updates that do not involve API can be developed normally.
The historical branch of PaddleOCR will no longer be maintained in the future. These branches will continue to be maintained, considering that some of you may still be using them:
Develop branch: This branch was used for the development and testing of static diagrams and is currently compatible with version >=1.7. If you have special needs, you can also use this branch to accommodate older versions of Paddle, but you won't update your code until you fix the bug.
PaddleOCR welcomes you to actively contribute code to repo. Here are some basic processes for contributing code.
### 3.2 PaddleOCR Code Submission Process And Specification
If you are familiar with Git use, you can jump directly to [Some Conventions For Submitting Code in 3.2.10](#Some_conventions_for_submitting_code)
#### 3.2.1 Create Your `Remote Repo`
In PaddleOCR [GitHub Home]( https://github.com/PaddlePaddle/PaddleOCR ) Click the `Fork` button in the upper left corner to create a `remote repo`in your personal directory, such as `https://github.com/ {your_name}/PaddleOCR`.
![banner](./images/banner.png)
Clone `Remote repo`
```bash linenums="1"
# pull code of develop branch
git clone https://github.com/{your_name}/PaddleOCR.git -b dygraph
cd PaddleOCR
```
Clone failures are mostly due to network reasons, try again later or configure the proxy
#### 3.2.2 Login And Connect Using Token
Start by viewing the information for the current `remote repo`.
```bash linenums="1"
git remote -v
# origin https://github.com/{your_name}/PaddleOCR.git (fetch)
# origin https://github.com/{your_name}/PaddleOCR.git (push)
```
Only the information of the clone `remote repo`, i.e. the PaddleOCR under your username, is available. Due to the change in Github's login method, you need to reconfigure the `remote repo` address by means of a Token. The token is generated as follows:
1. Find Personal Access Tokens: Click on your avatar in the upper right corner of the Github page and choose Settings --> Developer settings --> Personal access tokens,
2. Click Generate new token: Fill in the token name in Note, such as 'paddle'. In Select scopes, select repo (required), admin:repo_hook, delete_repo, etc. You can check them according to your needs. Then click Generate token to generate the token, and finally copy the generated token.
Delete the original origin configuration
```bash linenums="1"
git remote rm origin
```
Change the remote branch to `https://oauth2:{token}@github.com/{your_name}/PaddleOCR.git`. For example, if the token value is 12345 and your user name is PPOCR, run the following command
```bash linenums="1"
git remote add origin https://oauth2:12345@github.com/PPOCR/PaddleOCR.git
```
This establishes a connection to our own `remote repo`. Next we create a remote host of the original PaddleOCR repo, named upstream.
```bash linenums="1"
git remote add upstream https://github.com/PaddlePaddle/PaddleOCR.git
```
Use `git remote -v` to view current `remote warehouse` information, output as follows, found to include two origin and two upstream of `remote repo` .
```bash linenums="1"
origin https://github.com/{your_name}/PaddleOCR.git (fetch)
origin https://github.com/{your_name}/PaddleOCR.git (push)
upstream https://github.com/PaddlePaddle/PaddleOCR.git (fetch)
upstream https://github.com/PaddlePaddle/PaddleOCR.git (push)
```
This is mainly to keep the local repository up to date when subsequent pull request (PR) submissions are made.
#### 3.2.3 Create Local Branch
First get the latest code of upstream, then create a new_branch branch based on the dygraph of the upstream repo (upstream).
```bash linenums="1"
git fetch upstream
git checkout -b new_branch upstream/dygraph
```
> If for a newly forked PaddleOCR project, the user's remote repo (origin) has the same branch updates as the upstream repository (upstream), you can also create a new local branch based on the default branch of the origin repo or a specified branch with the following command
>
> ```bash linenums="1"
> # Create new_branch branch on user remote repo (origin) based on develop branch
> git checkout -b new_branch origin/develop
> # Create new_branch branch based on upstream remote repo develop branch
> # If you need to create a new branch from upstream,
> # you need to first use git fetch upstream to get upstream code
> git checkout -b new_branch upstream/develop
> ```
The final switch to the new branch is displayed with the following output information.
Branch new_branch set up to track remote branch develop from upstream.
Switched to a new branch 'new_branch'
After switching branches, file changes can be made on this branch
#### 3.2.4 Use Pre-Commit Hook
Paddle developers use the pre-commit tool to manage Git pre-submit hooks. It helps us format the source code (C++, Python) and automatically check for basic things (such as having only one EOL per file, not adding large files to Git) before committing it.
The pre-commit test is part of the unit test in Travis-CI. PR that does not satisfy the hook cannot be submitted to PaddleOCR. Install it first and run it in the current directory
```bash linenums="1"
pip install pre-commit
pre-commit install
```
> 1. Paddle uses clang-format to adjust the C/C++ source code format. Make sure the `clang-format` version is above 3.8.
>
> 2. Yapf installed through pip install pre-commit is slightly different from conda install-c conda-forge pre-commit, and PaddleOCR developers use `pip install pre-commit`.
#### 3.2.5 Modify And Submit Code
If you make some changes on `README.Md` on PaddleOCR, you can view the changed file through `git status`, and then add the changed file using `git add`。
```bash linenums="1"
git status # View change files
git add README.md
pre-commit
```
Repeat these steps until the pre-comit format check does not error. As shown below.
![img](./images/precommit_pass.png)
Use the following command to complete the submission.
```bash linenums="1"
git commit -m "your commit info"
```
#### 3.2.6 Keep Local Repo Up To Date
Get the latest code for upstream and update the current branch. Here the upstream comes from section 2.2, `Connecting to a remote repo`.
```bash linenums="1"
git fetch upstream
# If you want to commit to another branch, you need to pull code from another branch of upstream, here is develop
git pull upstream develop
```
#### 3.2.7 Push To Remote Repo
```bash linenums="1"
git push origin new_branch
```
#### 3.2.7 Submit Pull Request
Click the new pull request to select the local branch and the target branch, as shown in the following figure. In the description of PR, fill in the functions completed by the PR. Next, wait for review, and if you need to modify something, update the corresponding branch in origin with the steps above.
![banner](./images/pr.png)
#### 3.2.8 Sign CLA Agreement And Pass Unit Tests
Signing the CLA When submitting a Pull Request to PaddlePaddle for the first time, you need to sign a CLA (Contributor License Agreement) agreement to ensure that your code can be incorporated as follows:
1. Please check the Check section in PR, find the license/cla, and click on the right detail to enter the CLA website
2. Click Sign in with GitHub to agree on the CLA website and when clicked, it will jump back to your Pull Request page
#### 3.2.9 Delete Branch
- Remove remote branch
After PR is merged into the main repo, we can delete the branch of the remote repofrom the PR page.
You can also use `git push origin:branch name` to delete remote branches, such as:
```bash linenums="1"
git push origin :new_branch
```
- Delete local branch
```bash linenums="1"
# Switch to the development branch, otherwise the current branch cannot be deleted
git checkout develop
# Delete new_ Branch Branch
git branch -D new_branch
```
#### 3.2.10 Some Conventions For Submitting Code
In order for official maintainers to better focus on the code itself when reviewing it, please follow the following conventions each time you submit your code:
1Please ensure that the unit tests in Travis-CI pass smoothly. If not, indicate that there is a problem with the submitted code, and the official maintainer generally does not review it.
2Before submitting a Pull Request.
- Note the number of commits.
Reason: If you only modify one file and submit more than a dozen commits, each commit will only make a few modifications, which can be very confusing to the reviewer. The reviewer needs to look at each commit individually to see what changes have been made, and does not exclude the fact that changes between commits overlap each other.
Suggestion: Keep as few commits as possible each time you submit, and supplement your last commit with git commit --amend. For multiple commits that have been Push to a remote warehouse, you can refer to [squash commits after push](https://stackoverflow.com/questions/5667884/how-to-squash-commits-in-git-after-they-have-been-pushed ).
- Note the name of each commit: it should reflect the content of the current commit, not be too arbitrary.
3 If you have solved a problem, add in the first comment box of the Pull Request:fix #issue_numberThis will automatically close the corresponding Issue when the Pull Request is merged. Key words include:close, closes, closed, fix, fixes, fixed, resolve, resolves, resolved,please choose the right vocabulary. Detailed reference [Closing issues via commit messages](https://help.github.com/articles/closing-issues-via-commit-messages).
In addition, in response to the reviewer's comments, you are requested to abide by the following conventions:
1 Each review comment from an official maintainer would like a response, which would better enhance the contribution of the open source community.
- If you agree to the review opinion and modify it accordingly, give a simple Done.
- If you disagree with the review, please give your own reasons for refuting.
2If there are many reviews:
- Please give an overview of the changes.
- Please reply with `start a review', not directly. The reason is that each reply sends an e-mail message, which can cause a mail disaster.

View File

@@ -0,0 +1,327 @@
---
comments: true
typora-copy-images-to: images
---
# 附录
本附录包含了Python、文档规范以及Pull Request流程请各位开发者遵循相关内容
## 附录1Python代码规范
PaddleOCR的Python代码遵循 [PEP8规范](https://www.python.org/dev/peps/pep-0008/),其中一些关注的重点包括如下内容
- 空格
- 空格应该加在逗号、分号、冒号后,而非他们的前面
```python linenums="1"
# 正确:
print(x, y)
# 错误:
print(x , y)
```
- 在函数中指定关键字参数或默认参数值时, 不要在其两侧使用空格
```python linenums="1"
# 正确:
def complex(real, imag=0.0)
# 错误:
def complex(real, imag = 0.0)
```
- 注释
- 行内注释:行内注释使用 `#` 号表示,在代码与 `#` 之间需要空两个空格, `#` 与注释之间应当空一个空格,例如
```python linenums="1"
x = x + 1 # Compensate for border
```
- 函数和方法:每个函数的定义后的描述应该包括以下内容:
- 函数描述:函数的作用,输入输出的
- Args每个参数的名字以及对该参数的描述
- Returns返回值的含义和类型
```python linenums="1"
def fetch_bigtable_rows(big_table, keys, other_silly_variable=None):
"""Fetches rows from a Bigtable.
Retrieves rows pertaining to the given keys from the Table instance
represented by big_table. Silly things may happen if
other_silly_variable is not None.
Args:
big_table: An open Bigtable Table instance.
keys: A sequence of strings representing the key of each table row
to fetch.
other_silly_variable: Another optional variable, that has a much
longer name than the other args, and which does nothing.
Returns:
A dict mapping keys to the corresponding table row data
fetched. Each row is represented as a tuple of strings. For
example:
{'Serak': ('Rigel VII', 'Preparer'),
'Zim': ('Irk', 'Invader'),
'Lrrr': ('Omicron Persei 8', 'Emperor')}
If a key from the keys argument is missing from the dictionary,
then that row was not found in the table.
"""
pass
```
## 附录2文档规范
### 2.1 总体说明
- 文档位置如果您增加的新功能可以补充在原有的Markdown文件中请**不要重新新建**一个文件。如果您对添加的位置不清楚可以先PR代码然后在commit中询问官方人员。
- 新增Markdown文档名称使用英文描述文档内容一般由小写字母与下划线组合而成例如 `add_new_algorithm.md`
- 新增Markdown文档格式目录 - 正文 - FAQ
> 目录生成方法可以使用 [此网站](https://ecotrust-canada.github.io/markdown-toc/) 将md内容复制之后自动提取目录然后在md文件的每个标题前添加
- 中英双语:任何对文档的改动或新增都需要分别在中文和英文文档上进行。
### 2.2 格式规范
- 标题格式:文档标题格式按照:阿拉伯数字小数点组合 - 空格 - 标题的格式(例如 `2.1 XXXX` `2. XXXX`
- 代码块:通过代码块格式展示需要运行的代码,在代码块前描述命令参数的含义。例如:
> 检测+方向分类器+识别全流程:设置方向分类器参数 `--use_angle_cls true` 后可对竖排文本进行识别。
>
> ```bash linenums="1"
> paddleocr --image_dir ./imgs/11.jpg --use_angle_cls true
> ```
- 变量引用:如果在行内引用到代码变量或命令参数,需要用行内代码表示,例如上方 `--use_angle_cls true` ,并在前后各空一格
- 统一命名如PP-OCRv2、PP-OCR mobile、`paddleocr` whl包、PPOCRLabel、Paddle Lite等
- 补充说明:通过引用格式 `>` 补充说明,或对注意事项进行说明
- 图片:如果在说明文档中增加了图片,请规范图片的命名形式(描述图片内容),并将图片添加在 `doc/` 下
## 附录3Pull Request说明
### 3.1 PaddleOCR分支说明
PaddleOCR未来将维护2种分支分别为
- release/x.x系列分支为稳定的发行版本分支也是默认分支。PaddleOCR会根据功能更新情况发布新的release分支同时适配Paddle的release版本。随着版本迭代release/x.x系列分支会越来越多默认维护最新版本的release分支。
- dygraph分支为开发分支适配Paddle动态图的dygraph版本主要用于开发新功能。如果有同学需要进行二次开发请选择dygraph分支。为了保证dygraph分支能在需要的时候拉出release/x.x分支dygraph分支的代码只能使用Paddle最新release分支中有效的api。也就是说如果Paddle dygraph分支中开发了新的api但尚未出现在release分支代码中那么请不要在PaddleOCR中使用。除此之外对于不涉及api的性能优化、参数调整、策略更新等都可以正常进行开发。
PaddleOCR的历史分支未来将不再维护。考虑到一些同学可能仍在使用这些分支还会继续保留
- develop分支这个分支曾用于静态图的开发与测试目前兼容>=1.7版本的Paddle。如果有特殊需求要适配旧版本的Paddle那还可以使用这个分支但除了修复bug外不再更新代码。
PaddleOCR欢迎大家向repo中积极贡献代码下面给出一些贡献代码的基本流程。
### 3.2 PaddleOCR代码提交流程与规范
> 如果你熟悉Git使用可以直接跳转到 [3.2.10 提交代码的一些约定](#提交代码的一些约定)
#### 3.2.1 创建你的 `远程仓库`
- 在PaddleOCR的 [GitHub首页](https://github.com/PaddlePaddle/PaddleOCR),点击左上角 `Fork` 按钮,在你的个人目录下创建 `远程仓库`,比如`https://github.com/{your_name}/PaddleOCR`。
![banner](./images/banner.png)
- 将 `远程仓库` Clone到本地
```bash linenums="1"
# 拉取dygraph分支的代码
git clone https://github.com/{your_name}/PaddleOCR.git -b dygraph
cd PaddleOCR
```
> 多数情况下clone失败是由于网络原因请稍后重试或配置代理
#### 3.2.2 通过Token方式登录与建立连接
首先查看当前 `远程仓库` 的信息。
```bash linenums="1"
git remote -v
# origin https://github.com/{your_name}/PaddleOCR.git (fetch)
# origin https://github.com/{your_name}/PaddleOCR.git (push)
```
只有clone的 `远程仓库` 的信息,也就是自己用户名下的 PaddleOCR。由于Github的登录方式变化需要通过Token的方式重新配置 `远程仓库` 的地址。生成Token的方式如下
1. 找到个人访问令牌token在Github页面右上角点击自己的头像然后依次选择 Settings --> Developer settings --> Personal access tokens
2. 点击 Generate new token在Note中填入token名称例如paddle。在Select scopes选择repo必选、admin:repo_hook、delete_repo等可根据自身需要勾选。然后点击Generate token生成token。最后复制生成的token。
删除原始的origin配置
```bash linenums="1"
git remote rm origin
```
将remote分支改成 `https://oauth2:{token}@github.com/{your_name}/PaddleOCR.git`。例如如果token值为12345你的用户名为PPOCR则运行下方命令
```bash linenums="1"
git remote add origin https://oauth2:12345@github.com/PPOCR/PaddleOCR.git
```
这样我们就与自己的 `远程仓库` 建立了连接。接下来我们创建一个原始 PaddleOCR 仓库的远程主机,命名为 upstream。
```bash linenums="1"
git remote add upstream https://github.com/PaddlePaddle/PaddleOCR.git
```
使用 `git remote -v` 查看当前 `远程仓库` 的信息输出如下发现包括了origin和upstream 2个 `远程仓库` 。
```bash linenums="1"
origin https://oauth2:{token}@github.com/{your_name}/PaddleOCR.git (fetch)
origin https://oauth2:{token}@github.com/{your_name}/PaddleOCR.git (push)
upstream https://github.com/PaddlePaddle/PaddleOCR.git (fetch)
upstream https://github.com/PaddlePaddle/PaddleOCR.git (push)
```
这主要是为了后续在提交pull request(PR)时,始终保持本地仓库最新。
#### 3.2.3 创建本地分支
首先获取 upstream 的最新代码,然后基于上游仓库 (upstream)的dygraph创建new_branch分支。
```bash linenums="1"
git fetch upstream
git checkout -b new_branch upstream/dygraph
```
> 如果对于新Fork的PaddleOCR项目用户远程仓库(origin)与上游(upstream)仓库的分支更新情况相同也可以基于origin仓库的默认分支或指定分支创建新的本地分支命令如下。
>
> ```bash linenums="1"
> # 基于用户远程仓库(origin)的dygraph创建new_branch分支
> git checkout -b new_branch origin/dygraph
>
> # 基于用户远程仓库(origin)的默认分支创建new_branch分支
> git checkout -b new_branch
> ```
最终会显示切换到新的分支,输出信息如下
```bash linenums="1"
Branch new_branch set up to track remote branch develop from upstream.
Switched to a new branch 'new_branch'
```
切换分支之后即可在此分支上进行文件改动
#### 3.2.4 使用pre-commit勾子
Paddle 开发人员使用 pre-commit 工具来管理 Git 预提交钩子。 它可以帮助我们格式化源代码C++Python在提交commit前自动检查一些基本事宜如每个文件只有一个 EOLGit 中不要添加大文件等)。
pre-commit测试是 Travis-CI 中单元测试的一部分,不满足钩子的 PR 不能被提交到 PaddleOCR首先安装并在当前目录运行它
```bash linenums="1"
pip install pre-commit
pre-commit install
```
> 1. Paddle 使用 clang-format 来调整 C/C++ 源代码格式,请确保 `clang-format` 版本在 3.8 以上。
>
> 2. 通过pip install pre-commit和conda install -c conda-forge pre-commit安装的yapf稍有不同的PaddleOCR 开发人员使用的是 `pip install pre-commit`。
#### 3.2.5 修改与提交代码
假设对PaddleOCR的 `README.md` 做了一些修改,可以通过 `git status` 查看改动的文件,然后使用 `git add` 添加改动文件。
```bash linenums="1"
git status # 查看改动文件
git add README.md
pre-commit
```
重复上述步骤直到pre-comit格式检查不报错。如下所示。
![img](./images/precommit_pass.png)
提交修改,并写明修改内容("your commit info"
```bash linenums="1"
git commit -m "your commit info"
```
#### 3.2.6 Push到远程仓库
使用push命令将修改的commit提交到 `远程仓库`
```bash linenums="1"
git push origin new_branch
```
#### 3.2.7 提交Pull Request
打开自己的远程仓库界面选择提交的分支。点击new pull request或contribute进入PR界面。选择本地分支和目标分支如下图所示。在PR的描述说明中填写该PR所完成的功能。接下来等待review如果有需要修改的地方参照上述步骤更新 origin 中的对应分支即可。
![img](./images/pr.png)
#### 3.2.8 签署CLA协议和通过单元测试
- 签署CLA 在首次向PaddlePaddle提交Pull Request时您需要您签署一次CLA(Contributor License Agreement)协议,以保证您的代码可以被合入,具体签署方式如下:
1. 请您查看PR中的Check部分找到license/cla并点击右侧detail进入CLA网站
2. 点击CLA网站中的“Sign in with GitHub to agree”,点击完成后将会跳转回您的Pull Request页面
#### 3.2.9 删除分支
- 删除远程分支
在 PR 被 merge 进主仓库后,我们可以在 PR 的页面删除远程仓库的分支。
也可以使用 `git push origin :分支名` 删除远程分支,如:
```bash linenums="1"
git push origin :new_branch
```
- 删除本地分支
```bash linenums="1"
# 切换到dygraph分支否则无法删除当前分支
git checkout dygraph
# 删除new_branch分支
git branch -D new_branch
```
#### 3.2.10 提交代码的一些约定
为了使官方维护人员在评审代码时更好地专注于代码本身,请您每次提交代码时,遵守以下约定:
1请保证Travis-CI 中单元测试能顺利通过。如果没过,说明提交的代码存在问题,官方维护人员一般不做评审。
2提交Pull Request前
- 请注意commit的数量。
原因如果仅仅修改一个文件但提交了十几个commit每个commit只做了少量的修改这会给评审人带来很大困扰。评审人需要逐一查看每个commit才能知道做了哪些修改且不排除commit之间的修改存在相互覆盖的情况。
建议每次提交时保持尽量少的commit可以通过git commit --amend补充上次的commit。对已经Push到远程仓库的多个commit可以参考[squash commits after push](https://stackoverflow.com/questions/5667884/how-to-squash-commits-in-git-after-they-have-been-pushed)。
- 请注意每个commit的名称应能反映当前commit的内容不能太随意。
3如果解决了某个Issue的问题请在该Pull Request的第一个评论框中加上fix #issue_number这样当该Pull Request被合并后会自动关闭对应的Issue。关键词包括close, closes, closed, fix, fixes, fixed, resolve, resolves, resolved请选择合适的词汇。详细可参考[Closing issues via commit messages](https://help.github.com/articles/closing-issues-via-commit-messages)。
此外,在回复评审人意见时,请您遵守以下约定:
1官方维护人员的每一个review意见都希望得到回复这样会更好地提升开源社区的贡献。
- 对评审意见同意且按其修改完的给个简单的Done即可
- 对评审意见不同意的,请给出您自己的反驳理由。
2如果评审意见比较多:
- 请给出总体的修改情况。
- 请采用`start a review`进行回复,而非直接回复的方式。原因是每个回复都会发送一封邮件,会造成邮件灾难。

View File

@@ -0,0 +1,116 @@
---
comments: true
typora-copy-images-to: images
---
# 社区贡献
感谢大家长久以来对PaddleOCR的支持和关注与广大开发者共同构建一个专业、和谐、相互帮助的开源社区是PaddleOCR的目标。本文档展示了已有的社区贡献、对于各类贡献说明、新的机会与流程希望贡献流程更加高效、路径更加清晰。
PaddleOCR希望可以通过AI的力量助力任何一位有梦想的开发者实现自己的想法享受创造价值带来的愉悦。
<a href="https://github.com/PaddlePaddle/PaddleOCR/graphs/contributors">
<img src="https://contrib.rocks/image?repo=PaddlePaddle/PaddleOCR&max=400&columns=20" />
</a>
---
## 1. 社区贡献
### 1.1 基于PaddleOCR的社区项目
| 类别 | 项目 | 描述 | 开发者 |
| -------- | ------ | ------ | --------- |
| 通用工具 | [FastOCRLabel](https://gitee.com/BaoJianQiang/FastOCRLabel) | 完整的C#版本标注GUI | [包建强](https://gitee.com/BaoJianQiang) |
| 通用工具 | [DangoOCR离线版](https://github.com/PantsuDango/DangoOCR) | 通用型桌面级即时翻译GUI | [PantsuDango](https://github.com/PantsuDango) |
| 通用工具 | [scr2txt](https://github.com/lstwzd/scr2txt) | 截屏转文字GUI | [lstwzd](https://github.com/lstwzd) |
| 通用工具 | [ocr_sdk](https://github.com/mymagicpower/AIAS/blob/main/1_image_sdks/text_recognition/ocr_sdk) | OCR java SDK工具箱 | [Calvin](https://github.com/mymagicpower) |
| 通用工具 | [iocr](https://github.com/mymagicpower/AIAS/blob/main/8_suite_hub/iocr) | IOCR 自定义模板识别(支持表格识别) | [Calvin](https://github.com/mymagicpower) |
| 通用工具 | [Lmdb Dataset Format Conversion Tool](https://github.com/OneYearIsEnough/PaddleOCR-Recog-LmdbDataset-Conversion) | 文本识别任务中lmdb数据格式转换工具 | [OneYearIsEnough](https://github.com/OneYearIsEnough) |
| 通用工具 | [用paddleocr打造一款“盗幕笔记”](https://github.com/kjf4096/paddleocr_dmbj) | 用PaddleOCR记笔记 | [kjf4096](https://github.com/kjf4096) |
| 垂类工具 | [AI Studio项目](https://aistudio.baidu.com/aistudio/projectdetail/1054614?channelType=0&channel=0) | 英文视频自动生成字幕 | [叶月水狐](https://aistudio.baidu.com/aistudio/personalcenter/thirdview/322052) |
| 垂类工具 | [id_card_ocr](https://github.com/baseli/id_card_ocr) | 身份证复印件识别 | [baseli](https://github.com/baseli) |
| 垂类工具 | [Paddle_Table_Image_Reader](https://github.com/thunder95/Paddle_Table_Image_Reader) | 能看懂表格图片的数据助手 | [thunder95](https://github.com/thunder95]) |
| 垂类工具 | [AI Studio项目](https://aistudio.baidu.com/aistudio/projectdetail/3382897) | OCR流程中对手写体进行过滤 | [daassh](https://github.com/daassh) |
| 垂类场景调优 | [AI Studio项目](https://aistudio.baidu.com/aistudio/projectdetail/2803693) | 电表读数和编号识别 | [深渊上的坑](https://github.com/edencfc) |
| 垂类场景调优 | [AI Studio项目](https://aistudio.baidu.com/aistudio/projectdetail/3284199) | LCD液晶字符检测 | [Dream拒杰](https://github.com/zhangyingying520) |
| 前后处理 | [paddleOCRCorrectOutputs](https://github.com/yuranusduke/paddleOCRCorrectOutputs) | 获取OCR识别结果的key-value | [yuranusduke](https://github.com/yuranusduke) |
|前处理| [optlab](https://github.com/GreatV/optlab) |OCR前处理工具箱基于Qt和Leptonica。|[GreatV](https://github.com/GreatV)|
|应用部署| [PaddleOCRSharp](https://github.com/raoyutian/PaddleOCRSharp) |PaddleOCR的.NET封装与应用部署。|[raoyutian](https://github.com/raoyutian/PaddleOCRSharp)|
|应用部署| [PaddleSharp](https://github.com/sdcb/PaddleSharp) |PaddleOCR的.NET封装与应用部署支持跨平台、GPU|[sdcb](https://github.com/sdcb)|
| 应用部署 | [PaddleOCR-Streamlit-Demo](https://github.com/Lovely-Pig/PaddleOCR-Streamlit-Demo) | 使用Streamlit部署PaddleOCR | [Lovely-Pig](https://github.com/Lovely-Pig) |
| 应用部署 | [PaddleOCR-PyWebIO-Demo](https://github.com/Lovely-Pig/PaddleOCR-PyWebIO-Demo) | 使用PyWebIO部署PaddleOCR | [Lovely-Pig](https://github.com/Lovely-Pig) |
| 应用部署 | [PaddleOCR-Paddlejs-Vue-Demo](https://github.com/Lovely-Pig/PaddleOCR-Paddlejs-Vue-Demo) | 使用Paddle.js和Vue部署PaddleOCR | [Lovely-Pig](https://github.com/Lovely-Pig) |
| 应用部署 | [PaddleOCR-Paddlejs-React-Demo](https://github.com/Lovely-Pig/PaddleOCR-Paddlejs-React-Demo) | 使用Paddle.js和React部署PaddleOCR | [Lovely-Pig](https://github.com/Lovely-Pig) |
| 学术前沿模型训练与推理 | [AI Studio项目](https://aistudio.baidu.com/aistudio/projectdetail/3397137) | StarNet-MobileNetV3算法中文训练 | [xiaoyangyang2](https://github.com/xiaoyangyang2) |
| 学术前沿模型训练与推理 | [ABINet-paddle](https://github.com/Huntersdeng/abinet-paddle) | ABINet算法前向运算的paddle实现以及模型各部分的实现细节分析 | [Huntersdeng](https://github.com/Huntersdeng) |
### 1.2 为PaddleOCR新增功能
- 非常感谢 [authorfu](https://github.com/authorfu) 贡献Android([#340](https://github.com/PaddlePaddle/PaddleOCR/pull/340))和[xiadeye](https://github.com/xiadeye) 贡献IOS的demo代码([#325](https://github.com/PaddlePaddle/PaddleOCR/pull/325))
- 非常感谢 [tangmq](https://gitee.com/tangmq) 给PaddleOCR增加Docker化部署服务支持快速发布可调用的Restful API服务([#507](https://github.com/PaddlePaddle/PaddleOCR/pull/507))。
- 非常感谢 [lijinhan](https://github.com/lijinhan) 给PaddleOCR增加java SpringBoot 调用OCR Hubserving接口完成对OCR服务化部署的使用([#1027](https://github.com/PaddlePaddle/PaddleOCR/pull/1027))。
- 非常感谢 [Evezerest](https://github.com/Evezerest) [ninetailskim](https://github.com/ninetailskim) [edencfc](https://github.com/edencfc) [BeyondYourself](https://github.com/BeyondYourself) [1084667371](https://github.com/1084667371) 贡献了[PPOCRLabel](https://github.com/PaddlePaddle/PaddleOCR/blob/release/2.3/PPOCRLabel/README_ch.md) 的完整代码。
- 非常感谢 [bupt906](https://github.com/bupt906) 贡献MicroNet结构代码([#5251](https://github.com/PaddlePaddle/PaddleOCR/pull/5251))和贡献OneCycle学习率策略代码([#5252](https://github.com/PaddlePaddle/PaddleOCR/pull/5252))
### 1.3 代码修复
- 非常感谢 [zhangxin](https://github.com/ZhangXinNan)([Blog](https://blog.csdn.net/sdlypyzq)) 贡献新的可视化方式、添加.gitgnore、处理手动设置PYTHONPATH环境变量的问题([#210](https://github.com/PaddlePaddle/PaddleOCR/pull/210))。
- 非常感谢 [lyl120117](https://github.com/lyl120117) 贡献打印网络结构的代码([#304](https://github.com/PaddlePaddle/PaddleOCR/pull/304))。
- 非常感谢 [BeyondYourself](https://github.com/BeyondYourself) 给PaddleOCR提了很多非常棒的建议并简化了PaddleOCR的部分代码风格([so many commits)](https://github.com/PaddlePaddle/PaddleOCR/commits?author=BeyondYourself)。
### 1.4 文档优化与翻译
- 非常感谢 **[RangeKing](https://github.com/RangeKing)[HustBestCat](https://github.com/HustBestCat)[v3fc](https://github.com/v3fc)[1084667371](https://github.com/1084667371)** 贡献翻译《动手学OCR》notebook[电子书英文版](https://github.com/PaddlePaddle/PaddleOCR/tree/dygraph/notebook/notebook_en)。
- 非常感谢 [thunderstudying](https://github.com/thunderstudying)[RangeKing](https://github.com/RangeKing)[livingbody](https://github.com/livingbody) [WZMIAOMIAO](https://github.com/WZMIAOMIAO)[haigang1975](https://github.com/haigang1975) 补充多个英文markdown文档。
- 非常感谢 **[fanruinet](https://github.com/fanruinet)** 润色和修复35篇英文文档([#5205](https://github.com/PaddlePaddle/PaddleOCR/pull/5205))。
- 非常感谢 [Khanh Tran](https://github.com/xxxpsyduck) 和 [Karl Horky](https://github.com/karlhorky) 贡献修改英文文档。
### 1.5 多语言语料
- 非常感谢 [xiangyubo](https://github.com/xiangyubo) 贡献手写中文OCR数据集([#321](https://github.com/PaddlePaddle/PaddleOCR/pull/321))。
- 非常感谢 [Mejans](https://github.com/Mejans) 给PaddleOCR增加新语言奥克西坦语Occitan的字典和语料([#954](https://github.com/PaddlePaddle/PaddleOCR/pull/954))。
## 2. 贡献说明
### 2.1 新增功能类
PaddleOCR非常欢迎社区贡献以PaddleOCR为核心的各种服务、部署实例与软件应用经过认证的社区贡献会被添加在上述社区贡献表中为广大开发者增加曝光也是PaddleOCR的荣耀其中
- 项目形式官方社区认证的项目代码应有良好的规范和结构同时还应配备一个详细的README.md说明项目的使用方法。通过在requirements.txt文件中增加一行 `paddleocr` 可以自动收录到PaddleOCR的usedby中。
- 合入方式如果是对PaddleOCR现有工具的更新升级则会合入主repo。如果为PaddleOCR拓展了新功能请先与官方人员联系确认项目是否合入主repo*即使新功能未合入主repo我们同样也会以社区贡献的方式为您的个人项目增加曝光。*
### 2.2 代码优化
如果您在使用PaddleOCR时遇到了代码bug、功能不符合预期等问题可以为PaddleOCR贡献您的修改其中
- Python代码规范可参考[附录1Python代码规范](./code_and_doc.md#附录1python代码规范)。
- 提交代码前请再三确认不会引入新的bug并在PR中描述优化点。如果该PR解决了某个issue请在PR中连接到该issue。所有的PR都应该遵守附录3中的[3.2.10 提交代码的一些约定。](./code_and_doc.md#附录3pull-request说明)
- 请在提交之前参考下方的[附录3Pull Request说明](./code_and_doc.md#附录3pull-request说明)。如果您对git的提交流程不熟悉同样可以参考附录3的3.2节。
### 2.3 文档优化
如果您在使用PaddleOCR时遇到了文档表述不清楚、描述缺失、链接失效等问题可以为PaddleOCR贡献您的修改。文档书写规范请参考[附录2文档规范](./code_and_doc.md#附录2文档规范)。
## 3. 更多贡献机会
我们非常鼓励开发者使用PaddleOCR实现自己的想法同时我们也列出一些经过分析后认为有价值的拓展方向整体收集在社区项目常规赛中。
## 4. 联系我们
我们非常欢迎广大开发者在有意向为PaddleOCR贡献代码、文档、语料等内容前与我们联系这样可以大大降低PR过程中的沟通成本。同时如果您觉得某些想法个人难以实现我们也可以通过SIG的形式定向为项目招募志同道合的开发者一起共建。通过SIG渠道贡献的项目将会获得深层次的研发支持与运营资源如公众号宣传、直播课等
我们推荐的贡献流程是:
- 通过在github issue的题目中增加 `【third-party】` 标记,说明遇到的问题(以及解决的思路)或想拓展的功能,等待值班人员回复。例如 `【third-party】为PaddleOCR贡献IOS示例`
- 与我们沟通确认技术方案或bug、优化点准确无误后进行功能新增或相应的修改代码与文档遵循相关规范。
- PR链接到上述issue等待review。
## 5. 致谢与后续
- 合入代码之后会在本文档第一节中更新信息默认链接为github名字及主页如果有需要更换主页也可以联系我们。
- 新增重要功能类,会在用户群广而告之,享受开源社区荣誉时刻。
- **如果您有基于PaddleOCR的项目但未出现在上述列表中请按照 `4. 联系我们` 的步骤与我们联系。**

Binary file not shown.

After

Width:  |  Height:  |  Size: 138 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 538 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 110 KiB

View File

@@ -0,0 +1,31 @@
---
comments: true
---
# DATA ANNOTATION TOOLS
There are the commonly used data annotation tools, which will be continuously updated. Welcome to contribute tools~
## 1. labelImg
- Tool description: Rectangular label
- Tool address: <https://github.com/tzutalin/labelImg>
- Sketch diagram:
![labelimg](./images/labelimg.jpg)
## 2. roLabelImg
- Tool description: Label tool rewritten based on labelImg, supporting rotating rectangular label
- Tool address: <https://github.com/cgvict/roLabelImg>
- Sketch diagram:
![roLabelImg](./images/roLabelImg.png)
## 3. labelme
- Tool description: Support four points, polygons, circles and other labels
- Tool address: <https://github.com/wkentaro/labelme>
- Sketch diagram:
![labelme](./images/labelme.jpg)

View File

@@ -0,0 +1,35 @@
---
comments: true
---
# 数据标注工具
这里整理了常用的数据标注工具,持续更新中,欢迎各位小伙伴贡献工具~
## 1. labelImg
- 工具描述:矩形标注
- 工具地址:<https://github.com/tzutalin/labelImg>
- 示意图:
![](./images/labelimg.jpg)
## 2. roLabelImg
- 工具描述基于labelImg重写的标注工具支持旋转矩形标注
- 工具地址:<https://github.com/cgvict/roLabelImg>
- 示意图:
![](./images/roLabelImg.png)
## 3. labelme
- 工具描述:支持四点、多边形、圆形等多种标注
- 工具地址:<https://github.com/wkentaro/labelme>
- 示意图:
![](./images/labelme.jpg)
## 4. Vott
- 工具描述:支持矩形,多边形等图片标注.支持视频标注.方便使用的快捷键以及比较好看的界面.同时支持导出多种标签格式.
- 工具地址:<https://github.com/microsoft/VoTT>
- 示意图:
![](./images/VoTT.jpg)

View File

@@ -0,0 +1,17 @@
---
comments: true
---
# DATA SYNTHESIS TOOLS
In addition to open source data, users can also use synthesis tools to synthesize data.
There are the commonly used data synthesis tools, which will be continuously updated. Welcome to contribute tools~
* [Text_renderer](https://github.com/Sanster/text_renderer)
* [SynthText](https://github.com/ankush-me/SynthText)
* [SynthText_Chinese_version](https://github.com/JarveeLee/SynthText_Chinese_version)
* [TextRecognitionDataGenerator](https://github.com/Belval/TextRecognitionDataGenerator)
* [SynthText3D](https://github.com/MhLiao/SynthText3D)
* [UnrealText](https://github.com/Jyouhou/UnrealText/)
* [SynthTIGER](https://github.com/clovaai/synthtiger)

View File

@@ -0,0 +1,15 @@
---
comments: true
---
# 数据合成工具
除了开源数据,用户还可使用合成工具自行合成。这里整理了常用的数据合成工具,持续更新中,欢迎各位小伙伴贡献工具~
- [text_renderer](https://github.com/Sanster/text_renderer)
- [SynthText](https://github.com/ankush-me/SynthText)
- [SynthText_Chinese_version](https://github.com/JarveeLee/SynthText_Chinese_version)
- [TextRecognitionDataGenerator](https://github.com/Belval/TextRecognitionDataGenerator)
- [SynthText3D](https://github.com/MhLiao/SynthText3D)
- [UnrealText](https://github.com/Jyouhou/UnrealText/)
- [SynthTIGER](https://github.com/clovaai/synthtiger)

Binary file not shown.

After

Width:  |  Height:  |  Size: 165 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 89 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 953 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 MiB

View File

@@ -0,0 +1,6 @@
---
comments: true
---
- Semi-automatic Annotation Tool: PPOCRLabel: <https://github.com/PFCCLab/PPOCRLabel/blob/main/README_ch.md>
- Data Synthesis Tool: Style-Text: <https://github.com/PFCCLab/StyleText/blob/main/README_ch.md>

View File

@@ -0,0 +1,7 @@
---
comments: true
---
- 半自动标注工具 PPOCRLabel: <https://github.com/PFCCLab/PPOCRLabel/blob/main/README_ch.md>
- 数据合成工具 Style-Text: <https://github.com/PFCCLab/StyleText/blob/main/README_ch.md>

View File

@@ -0,0 +1,93 @@
---
comments: true
---
This is a collection of commonly used Chinese datasets, which is being updated continuously. You are welcome to contribute to this list
In addition to opensource data, users can also use synthesis tools to synthesize data themselves. Current available synthesis tools include [text_renderer](https://github.com/Sanster/text_renderer), [SynthText](https://github.com/ankush-me/SynthText), [TextRecognitionDataGenerator](https://github.com/Belval/TextRecognitionDataGenerator), etc.
#### 1. ICDAR2019-LSVT
- **Data sources**<https://ai.baidu.com/broad/introduction?dataset=lsvt>
- **Introduction** A total of 45w Chinese street view images, including 5w (2w test + 3w training) fully labeled data (text coordinates + text content), 40w weakly labeled data (text content only), as shown in the following figure:
![](./images/LSVT_1.jpg)
(a) Fully labeled data
![](./images/LSVT_2.jpg)
(b) Weakly labeled data
- **Download link**<https://ai.baidu.com/broad/download?dataset=lsvt>
#### 2. ICDAR2017-RCTW-17
- **Data sources**<https://rctw.vlrlab.net/>
- **Introduction**It contains 12000 + images, most of them are collected in the wild through mobile camera. Some are screenshots. These images show a variety of scenes, including street views, posters, menus, indoor scenes and screenshots of mobile applications.
![](./images/rctw.jpg)
- **Download link**<https://rctw.vlrlab.net/dataset/>
#### 3. Chinese Street View Text Recognition
- **Data sources**<https://aistudio.baidu.com/aistudio/competition/detail/8>
- **Introduction**A total of 290000 pictures are included, of which 210000 are used as training sets (with labels) and 80000 are used as test sets (without labels). The dataset is collected from the Chinese street view, and is formed by by cutting out the text line area (such as shop signs, landmarks, etc.) in the street view picture. All the images are preprocessed: by using affine transform, the text area is proportionally mapped to a picture with a height of 48 pixels, as shown in the figure:
![](./images/ch_street_rec_1.png)
(a) Label: 魅派集成吊顶
![](./images/ch_street_rec_2.png)
(b) Label: 母婴用品连锁
- **Download link**
<https://aistudio.baidu.com/aistudio/datasetdetail/8429>
#### 4. Chinese Document Text Recognition
- **Data sources**<https://github.com/YCG09/chinese_ocr>
- **Introduction**
- A total of 3.64 million pictures are divided into training set and validation set according to 99:1.
- Using Chinese corpus (news + classical Chinese), the data is randomly generated through changes in font, size, grayscale, blur, perspective, stretching, etc.
- 5990 characters including Chinese characters, English letters, numbers and punctuationCharacters set: <https://github.com/YCG09/chinese_ocr/blob/master/train/char_std_5990.txt>
- Each sample is fixed with 10 characters, and the characters are randomly intercepted from the sentences in the corpus
- Image resolution is 280x32
![](./images/ch_doc1.jpg)
![](./images/ch_doc3.jpg)
- **Download link**<https://pan.baidu.com/s/1QkI7kjah8SPHwOQ40rS1Pw> (Password: lu7m)
#### 5、ICDAR2019-ArT
- **Data source**<https://ai.baidu.com/broad/introduction?dataset=art>
- **Introduction**It includes 10166 images, 5603 in training sets and 4563 in test sets. It is composed of three parts: total text, scut-ctw1500 and Baidu curved scene text, including text with various shapes such as horizontal, multi-directional and curved.
![](./images/ArT.jpg)
- **Download link**<https://ai.baidu.com/broad/download?dataset=art>
#### 6. Electronic seal dataset
- **Data source**: <https://aistudio.baidu.com/aistudio/datasetdetail/154271/0>
- **Data introduction**: Contains 10,000 images in total, 8,000 images in the training set, and 2,000 images in the test set. The dataset is synthesized by a program and does not involve privacy security. It is mainly used for the training and detection of seal curved text. Contributed by developer [jingsongliujing](https://github.com/jingsongliujing)
- **Download address**: <https://aistudio.baidu.com/aistudio/datasetdetail/154271/0>
## References
**ICDAR 2019-LSVT Challenge**
```bibtex
@article{sun2019icdar,
title={ICDAR 2019 Competition on Large-scale Street View Text with Partial Labeling--RRC-LSVT},
author={Sun, Yipeng and Ni, Zihan and Chng, Chee-Kheng and Liu, Yuliang and Luo, Canjie and Ng, Chun Chet and Han, Junyu and Ding, Errui and Liu, Jingtuo and Karatzas, Dimosthenis and others},
journal={arXiv preprint arXiv:1909.07741},
year={2019}
}
```
**ICDAR 2019-ArT Challenge**
```bibtex
@article{chng2019icdar2019,
title={ICDAR2019 Robust Reading Challenge on Arbitrary-Shaped Text (RRC-ArT)},
author={Chng, Chee-Kheng and Liu, Yuliang and Sun, Yipeng and Ng, Chun Chet and Luo, Canjie and Ni, Zihan and Fang, ChuanMing and Zhang, Shuaitao and Han, Junyu and Ding, Errui and others},
journal={arXiv preprint arXiv:1909.07145},
year={2019}
}
```

93
docs/datasets/datasets.md Normal file
View File

@@ -0,0 +1,93 @@
---
comments: true
---
这里整理了常用中文数据集,持续更新中,欢迎各位小伙伴贡献数据集~
除了开源数据,用户还可使用合成工具自行合成,可参考[数据合成工具](../data_anno_synth/data_synthesis.md)
如果需要标注自己的数据,可参考[数据标注工具](../data_anno_synth/data_annotation.md)。
#### 1、ICDAR2019-LSVT
- **数据来源**<https://ai.baidu.com/broad/introduction?dataset=lsvt>
- **数据简介** 共45w中文街景图像包含5w2w测试+3w训练全标注数据文本坐标+文本内容40w弱标注数据仅文本内容如下图所示
![](./images/LSVT_1.jpg)
(a) 全标注数据
![](./images/LSVT_2.jpg)
(b) 弱标注数据
- **下载地址**<https://ai.baidu.com/broad/download?dataset=lsvt>
- **说明**其中test数据集的label目前没有开源如要评估结果可以去官网提交<https://rrc.cvc.uab.es/?ch=16>
#### 2、ICDAR2017-RCTW-17
- **数据来源**<https://rctw.vlrlab.net/>
- **数据简介**共包含12,000+图像,大部分图片是通过手机摄像头在野外采集的。有些是截图。这些图片展示了各种各样的场景,包括街景、海报、菜单、室内场景和手机应用程序的截图。
![](./images/rctw.jpg)
- **下载地址**<https://rctw.vlrlab.net/dataset/>
#### 3、中文街景文字识别
- **数据来源**<https://aistudio.baidu.com/aistudio/competition/detail/8>
- **数据简介**ICDAR2019-LSVT行识别任务共包括29万张图片其中21万张图片作为训练集带标注8万张作为测试集无标注。数据集采自中国街景并由街景图片中的文字行区域例如店铺标牌、地标等等截取出来而形成。所有图像都经过一些预处理将文字区域利用仿射变化等比映射为一张高为48像素的图片如图所示
![](./images/ch_street_rec_1.png)
(a) 标注:魅派集成吊顶
![](./images/ch_street_rec_2.png)
(b) 标注:母婴用品连锁
- **下载地址**
<https://aistudio.baidu.com/aistudio/datasetdetail/8429>
#### 4、中文文档文字识别
- **数据来源**<https://github.com/YCG09/chinese_ocr>
- **数据简介**
- 共约364万张图片按照99:1划分成训练集和验证集。
- 数据利用中文语料库(新闻 + 文言文),通过字体、大小、灰度、模糊、透视、拉伸等变化随机生成
- 包含汉字、英文字母、数字和标点共5990个字符字符集合<https://github.com/YCG09/chinese_ocr/blob/master/train/char_std_5990.txt>
- 每个样本固定10个字符字符随机截取自语料库中的句子
- 图片分辨率统一为280x32
![](./images/ch_doc1.jpg)
![](./images/ch_doc3.jpg)
- **下载地址**<https://pan.baidu.com/s/1QkI7kjah8SPHwOQ40rS1Pw> (密码lu7m)
#### 5、ICDAR2019-ArT
- **数据来源**<https://ai.baidu.com/broad/introduction?dataset=art>
- **数据简介**共包含10,166张图像训练集5603图测试集4563图。由Total-Text、SCUT-CTW1500、Baidu Curved Scene Text (ICDAR2019-LSVT部分弯曲数据) 三部分组成,包含水平、多方向和弯曲等多种形状的文本。
![](./images/ArT.jpg)
- **下载地址**<https://ai.baidu.com/broad/download?dataset=art>
#### 6、电子印章数据集
- **数据来源**<https://aistudio.baidu.com/aistudio/datasetdetail/154271/0>
- **数据简介**共包含10000张图像训练集8000图测试集2000图。数据集是用程序合成的并不涉及隐私安全主要用于印章弯曲文本的训练与检测。由开发者[jingsongliujing](https://github.com/jingsongliujing)贡献
- **下载地址**<https://aistudio.baidu.com/aistudio/datasetdetail/154271/0>
## 参考文献
**ICDAR 2019-LSVT Challenge**
```bibtex
@article{sun2019icdar,
title={ICDAR 2019 Competition on Large-scale Street View Text with Partial Labeling--RRC-LSVT},
author={Sun, Yipeng and Ni, Zihan and Chng, Chee-Kheng and Liu, Yuliang and Luo, Canjie and Ng, Chun Chet and Han, Junyu and Ding, Errui and Liu, Jingtuo and Karatzas, Dimosthenis and others},
journal={arXiv preprint arXiv:1909.07741},
year={2019}
}
```
**ICDAR 2019-ArT Challenge**
```bibtex
@article{chng2019icdar2019,
title={ICDAR2019 Robust Reading Challenge on Arbitrary-Shaped Text (RRC-ArT)},
author={Chng, Chee-Kheng and Liu, Yuliang and Sun, Yipeng and Ng, Chun Chet and Luo, Canjie and Ni, Zihan and Fang, ChuanMing and Zhang, Shuaitao and Han, Junyu and Ding, Errui and others},
journal={arXiv preprint arXiv:1909.07145},
year={2019}
}
```

View File

@@ -0,0 +1,31 @@
---
comments: true
---
# Handwritten OCR dataset
Here we have sorted out the commonly used handwritten OCR dataset datasets, which are being updated continuously. We welcome you to contribute datasets ~
- [Institute of automation, Chinese Academy of Sciences - handwritten Chinese dataset](#Institute of automation, Chinese Academy of Sciences - handwritten Chinese dataset)
- [NIST handwritten single character dataset - English](#NIST handwritten single character dataset - English)
## Institute of automation, Chinese Academy of Sciences - handwritten Chinese dataset
- **Data source**: <http://www.nlpr.ia.ac.cn/databases/handwriting/Download.html>
- **Data introduction**:
- It includes online and offline handwritten data,`HWDB1.0~1.2` has totally 3895135 handwritten single character samples, which belong to 7356 categories (7185 Chinese characters and 171 English letters, numbers and symbols);`HWDB2.0~2.2` has totally 5091 pages of images, which are divided into 52230 text lines and 1349414 words. All text and text samples are stored as grayscale images. Some sample words are shown below.
![](./images/CASIA_0.jpg)
- **Download address**:<http://www.nlpr.ia.ac.cn/databases/handwriting/Download.html>
- **使用建议**:Data for single character, white background, can form a large number of text lines for training. White background can be processed into transparent state, which is convenient to add various backgrounds. For the case of semantic needs, it is suggested to extract single character from real corpus to form text lines.
## NIST handwritten single character dataset - English(NIST Handprinted Forms and Characters Database)
- **Data source**: [https://www.nist.gov/srd/nist-special-database-19](https://www.nist.gov/srd/nist-special-database-19)
- **Data introduction**: NIST19 dataset is suitable for handwritten document and character recognition model training. It is extracted from the handwritten sample form of 3600 authors and contains 810000 character images in total. Nine of them are shown below.
![](./images/nist_demo.png)
- **Download address**: [https://www.nist.gov/srd/nist-special-database-19](https://www.nist.gov/srd/nist-special-database-19)

View File

@@ -0,0 +1,28 @@
---
comments: true
---
# 手写OCR数据集
这里整理了常用手写数据集,持续更新中,欢迎各位小伙伴贡献数据集~
## 中科院自动化研究所-手写中文数据集
- **数据来源**<http://www.nlpr.ia.ac.cn/databases/handwriting/Download.html>
- **数据简介**
- 包含在线和离线两类手写数据,`HWDB1.0~1.2`总共有3895135个手写单字样本分属7356类7185个汉字和171个英文字母、数字、符号`HWDB2.0~2.2`总共有5091页图像分割为52230个文本行和1349414个文字。所有文字和文本样本均存为灰度图像。部分单字样本图片如下所示。
![](./images/CASIA_0.jpg)
- **下载地址**<http://www.nlpr.ia.ac.cn/databases/handwriting/Download.html>
- **使用建议**:数据为单字,白色背景,可以大量合成文字行进行训练。白色背景可以处理成透明状态,方便添加各种背景。对于需要语义的情况,建议从真实语料出发,抽取单字组成文字行
## NIST手写单字数据集-英文(NIST Handprinted Forms and Characters Database)
- **数据来源**: [https://www.nist.gov/srd/nist-special-database-19](https://www.nist.gov/srd/nist-special-database-19)
- **数据简介**: NIST19数据集适用于手写文档和字符识别的模型训练从3600位作者的手写样本表格中提取得到总共包含81万张字符图片。其中9张图片示例如下
![](./images/nist_demo.png)
- **下载地址**: [https://www.nist.gov/srd/nist-special-database-19](https://www.nist.gov/srd/nist-special-database-19)

Binary file not shown.

After

Width:  |  Height:  |  Size: 413 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 594 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 628 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 123 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 94 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 166 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 305 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 100 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 114 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 90 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 237 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 110 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 80 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 921 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 163 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 120 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 93 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 233 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 233 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 613 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 224 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 181 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 175 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 636 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 756 KiB

View File

@@ -0,0 +1,47 @@
---
comments: true
---
## Key Information Extraction dataset
Here are the common datasets key information extraction, which are being updated continuously. Welcome to contribute datasets.
### 1. FUNSD dataset
- **Data source**: <https://guillaumejaume.github.io/FUNSD/>
- **Data Introduction**: The FUNSD dataset is a dataset for form comprehension. It contains 199 real, fully annotated scanned images, including market reports, advertisements, and academic reports, etc., and is divided into 149 training set and 50 test set. The FUNSD dataset is suitable for many types of DocVQA tasks, such as field-level entity classification, field-level entity connection, etc. Part of the image and the annotation box visualization are shown below:
![](./images/funsd_demo/gt_train_00040534.jpg)
![](./images/funsd_demo/gt_train_00070353.jpg)
In the figure, the orange area represents `header`, the light blue area represents `question`, the green area represents `answer`, and the pink area represents `other`.
- **Download address**: <https://guillaumejaume.github.io/FUNSD/download/>
### 2. XFUND dataset
- **Data source**: <https://github.com/doc-analysis/XFUND>
- **Data introduction**: XFUND is a multilingual form comprehension dataset, which contains form data in 7 different languages, and all are manually annotated in the form of key-value pairs. The data for each language contains 199 form data, which are divided into 149 training sets and 50 test sets. Part of the image and the annotation box visualization are shown below.
![](./images/xfund_demo/gt_zh_train_0.jpg)
![](./images/xfund_demo/gt_zh_train_1.jpg)
- **Download address**: <https://github.com/doc-analysis/XFUND/releases/tag/v1.0>
### 3. wildreceipt dataset
- **Data source**: <https://arxiv.org/abs/2103.14470>
- **Data introduction**: wildreceipt is an English receipt dataset, which contains 26 different categories. There are 1267 training images and 472 evaluation images, in which 50,000 textlines and boxes are annotated. Part of the image and the annotation box visualization are shown below.
![](./images/wildreceipt_demo/2769.jpeg)
![](./images/wildreceipt_demo/1bbe854b8817dedb8585e0732089fd1f752d2cec.jpeg)
**Note** Boxes with category `Ignore` or `Others` are not visualized here.
- **Download address**
- Official dataset: [link](https://download.openmmlab.com/mmocr/data/wildreceipt.tar)
- Dataset converted for PaddleOCR training process: [link](https://paddleocr.bj.bcebos.com/ppstructure/dataset/wildreceipt.tar)

View File

@@ -0,0 +1,49 @@
---
comments: true
---
# 关键信息抽取数据集
这里整理了常见的关键信息抽取数据集,持续更新中,欢迎各位小伙伴贡献数据集~
## 1. FUNSD数据集
- **数据来源**<https://guillaumejaume.github.io/FUNSD/>
- **数据简介**FUNSD数据集是一个用于表单理解的数据集它包含199张真实的、完全标注的扫描版图片类型包括市场报告、广告以及学术报告等并分为149张训练集以及50张测试集。FUNSD数据集适用于多种类型的DocVQA任务如字段级实体分类、字段级实体连接等。部分图像以及标注框可视化如下所示:
<div align="center">
<img src="./images/funsd_demo/gt_train_00040534.jpg" width="500">
<img src="./images/funsd_demo/gt_train_00070353.jpg" width="500">
</div>
图中,橙色区域代表`header`,淡蓝色区域代表`question`, 绿色区域表`answer`,粉红色代区域表`other`
- **下载地址**<https://guillaumejaume.github.io/FUNSD/download/>
## 2. XFUND数据集
- **数据来源**<https://github.com/doc-analysis/XFUND>
- **数据简介**XFUND是一个多语种表单理解数据集它包含7种不同语种的表单数据并且全部用人工进行了键-值对形式的标注。其中每个语种的数据都包含了199张表单数据并分为149张训练集以及50张测试集。部分图像以及标注框可视化如下所示:
<div align="center">
<img src="./images/xfund_demo/gt_zh_train_0.jpg" width="500">
<img src="./images/xfund_demo/gt_zh_train_1.jpg" width="500">
</div>
- **下载地址**<https://github.com/doc-analysis/XFUND/releases/tag/v1.0>
## 3. wildreceipt数据集
- **数据来源**<https://arxiv.org/abs/2103.14470>
- **数据简介**wildreceipt数据集是英文发票数据集包含26个类别此处类别体系包含`Ignore`类别共标注了50000个文本框。其中训练集包含1267张图片测试集包含472张图片。部分图像以及标注框可视化如下所示:
<div align="center">
<img src="./images/wildreceipt_demo/2769.jpeg" width="500">
<img src="./images/wildreceipt_demo/1bbe854b8817dedb8585e0732089fd1f752d2cec.jpeg" width="500">
</div>
**注:** 这里对于类别为`Ignore`或者`Others`的文本,没有进行可视化。
- **下载地址**
- 原始数据下载地址:[链接](https://download.openmmlab.com/mmocr/data/wildreceipt.tar)
- 数据格式转换后适配于PaddleOCR训练的数据下载地址[链接](https://paddleocr.bj.bcebos.com/ppstructure/dataset/wildreceipt.tar)

View File

@@ -0,0 +1,46 @@
---
comments: true
---
## Layout Analysis Dataset
Here are the common datasets of layout analysis, which are being updated continuously. Welcome to contribute datasets.
Most of the layout analysis datasets are object detection datasets. In addition to open source datasets, you can also label or synthesize datasets using tools such as [labelme](https://github.com/wkentaro/labelme) and so on.
### 1. PubLayNet dataset
- **Data source**: <https://github.com/ibm-aur-nlp/PubLayNet>
- **Data introduction**: The PubLayNet dataset contains 350000 training images and 11000 validation images. There are 5 categories in total, namely: `text, title, list, table, figure`. Some images and their annotations as shown below.
![](./images/publaynet_demo/gt_PMC3724501_00006.jpg)
![](./images/publaynet_demo/gt_PMC5086060_00002.jpg)
- **Download address**: <https://developer.ibm.com/exchanges/data/all/publaynet/>
- **Note**: When using this dataset, you need to follow [CDLA-Permissive](https://cdla.io/permissive-1-0/) license.
### 2、CDLA dataset
- **Data source**: <https://github.com/buptlihang/CDLA>
- **Data introduction**: CDLA dataset contains 5000 training images and 1000 validation images with 10 categories, which are `Text, Title, Figure, Figure caption, Table, Table caption, Header, Footer, Reference, Equation`. Some images and their annotations as shown below.
![](./images/CDLA_demo/val_0633.jpg)
![](./images/CDLA_demo/val_0941.jpg)
- **Download address**: <https://github.com/buptlihang/CDLA>
- **Note**: When you train detection model on CDLA dataset using [PaddleDetection](https://github.com/PaddlePaddle/PaddleDetection/tree/develop), you need to remove the label `__ignore__` and `_background_`.
### 3、TableBank dataset
- **Data source**: <https://doc-analysis.github.io/tablebank-page/index.html>
- **Data introduction**: TableBank dataset contains 2 types of document: Latex (187199 training images, 7265 validation images and 5719 testing images) and Word (73383 training images 2735 validation images and 2281 testing images). Some images and their annotations as shown below.
![](./images/tablebank_demo/004.png)
![](./images/tablebank_demo/005.png)
- **Data source**: <https://doc-analysis.github.io/tablebank-page/index.html>
- **Note**: When using this dataset, you need to follow [Apache-2.0](https://github.com/doc-analysis/TableBank/blob/master/LICENSE) license.

View File

@@ -0,0 +1,49 @@
---
comments: true
---
## 版面分析数据集
这里整理了常用版面分析数据集,持续更新中,欢迎各位小伙伴贡献数据集~
版面分析数据集多为目标检测数据集,除了开源数据,用户还可使用合成工具自行合成,如[labelme](https://github.com/wkentaro/labelme)等。
### 1、publaynet数据集
- **数据来源**<https://github.com/ibm-aur-nlp/PubLayNet>
- **数据简介**publaynet数据集的训练集合中包含35万张图像验证集合中包含1.1万张图像。总共包含5个类别分别是 `text, title, list, table, figure`。部分图像以及标注框可视化如下所示。
<div align="center">
<img src="./images/publaynet_demo/gt_PMC3724501_00006.jpg" width="500">
<img src="./images/publaynet_demo/gt_PMC5086060_00002.jpg" width="500">
</div>
- **下载地址**<https://developer.ibm.com/exchanges/data/all/publaynet/>
- **说明**:使用该数据集时,需要遵守[CDLA-Permissive](https://cdla.io/permissive-1-0/)协议。
### 2、CDLA数据集
- **数据来源**<https://github.com/buptlihang/CDLA>
- **数据简介**CDLA据集的训练集合中包含5000张图像验证集合中包含1000张图像。总共包含10个类别分别是 `Text, Title, Figure, Figure caption, Table, Table caption, Header, Footer, Reference, Equation`。部分图像以及标注框可视化如下所示。
<div align="center">
<img src="./images/CDLA_demo/val_0633.jpg" width="500">
<img src="./images/CDLA_demo/val_0941.jpg" width="500">
</div>
- **下载地址**<https://github.com/buptlihang/CDLA>
- **说明**:基于[PaddleDetection](https://github.com/PaddlePaddle/PaddleDetection/tree/develop)套件在该数据集上训练目标检测模型时在转换label时需要将`label.txt`中的`__ignore__``_background_`去除。
### 3、TableBank数据集
- **数据来源**<https://doc-analysis.github.io/tablebank-page/index.html>
- **数据简介**TableBank数据集包含Latex训练集187199张验证集7265张测试集5719张与Word训练集73383张验证集2735张测试集2281张两种类别的文档。仅包含`Table` 1个类别。部分图像以及标注框可视化如下所示。
<div align="center">
<img src="./images/tablebank_demo/004.png" height="700">
<img src="./images/tablebank_demo/005.png" height="700">
</div>
- **下载地址**<https://doc-analysis.github.io/tablebank-page/index.html>
- **说明**:使用该数据集时,需要遵守[Apache-2.0](https://github.com/doc-analysis/TableBank/blob/master/LICENSE)协议。

View File

@@ -0,0 +1,154 @@
---
comments: true
---
# OCR datasets
Here is a list of public datasets commonly used in OCR, which are being continuously updated. Welcome to contribute datasets!
## 1. Text detection
### 1.1 PaddleOCR text detection format annotation
The annotation file formats supported by the PaddleOCR text detection algorithm are as follows, separated by "\t":
```text linenums="1"
"Image file name Image annotation information encoded by json.dumps"
ch4_test_images/img_61.jpg [{"transcription": "MASA", "points": [[310, 104], [416, 141], [418, 216], [312, 179]]}, {...}]
```
The image annotation after **json.dumps()** encoding is a list containing multiple dictionaries.
The `points` in the dictionary represent the coordinates (x, y) of the four points of the text box, arranged clockwise from the point at the upper left corner.
`transcription` represents the text of the current text box. **When its content is "###" it means that the text box is invalid and will be skipped during training.**
If you want to train PaddleOCR on other datasets, please build the annotation file according to the above format.
### 1.2 Public dataset
| dataset | Image download link | PaddleOCR format annotation download link |
|---|---|---|
| ICDAR 2015 | <https://rrc.cvc.uab.es/?ch=4&com=downloads> | [train](https://paddleocr.bj.bcebos.com/dataset/train_icdar2015_label.txt) / [test](https://paddleocr.bj.bcebos.com/dataset/test_icdar2015_label.txt) |
| ctw1500 | <https://paddleocr.bj.bcebos.com/dataset/ctw1500.zip> | Included in the downloaded image zip |
| total text | <https://paddleocr.bj.bcebos.com/dataset/total_text.tar> | Included in the downloaded image zip |
#### 1.2.1 ICDAR 2015
The icdar2015 dataset contains train set which has 1000 images obtained with wearable cameras and test set which has 500 images obtained with wearable cameras. The icdar2015 dataset can be downloaded from the link in the table above. Registration is required for downloading.
After registering and logging in, download the part marked in the red box in the figure below. And, the content downloaded by `Training Set Images` should be saved as the folder `icdar_c4_train_imgs`, and the content downloaded by `Test Set Images` is saved as the folder `ch4_test_images`
![](./images/ic15_location_download.png)
Decompress the downloaded dataset to the working directory, assuming it is decompressed under PaddleOCR/train_data/. Then download the PaddleOCR format annotation file from the table above.
PaddleOCR also provides a data format conversion script, which can convert the official website label to the PaddleOCR format. The data conversion tool is in `ppocr/utils/gen_label.py`, here is the training set as an example:
```bash linenums="1"
# Convert the label file downloaded from the official website to train_icdar2015_label.txt
python gen_label.py --mode="det" --root_path="/path/to/icdar_c4_train_imgs/" \
--input_path="/path/to/ch4_training_localization_transcription_gt" \
--output_label="/path/to/train_icdar2015_label.txt"
```
After decompressing the data set and downloading the annotation file, PaddleOCR/train_data/ has two folders and two files, which are:
```text linenums="1"
/PaddleOCR/train_data/icdar2015/text_localization/
└─ icdar_c4_train_imgs/ Training data of icdar dataset
└─ ch4_test_images/ Testing data of icdar dataset
└─ train_icdar2015_label.txt Training annotation of icdar dataset
└─ test_icdar2015_label.txt Test annotation of icdar dataset
```
## 2. Text recognition
### 2.1 PaddleOCR text recognition format annotation
The text recognition algorithm in PaddleOCR supports two data formats:
- `lmdb` is used to train data sets stored in lmdb format, use [lmdb_dataset.py](../../../ppocr/data/lmdb_dataset.py) to load;
- `common dataset` is used to train data sets stored in text files, use [simple_dataset.py](../../../ppocr/data/simple_dataset.py) to load.
If you want to use your own data for training, please refer to the following to organize your data.
#### Training set
It is recommended to put the training images in the same folder, and use a txt file (rec_gt_train.txt) to store the image path and label. The contents of the txt file are as follows:
- Note: by default, the image path and image label are split with \t, if you use other methods to split, it will cause training error
```text linenums="1"
" Image file name Image annotation "
train_data/rec/train/word_001.jpg 简单可依赖
train_data/rec/train/word_002.jpg 用科技让复杂的世界更简单
...
```
The final training set should have the following file structure:
```text linenums="1"
|-train_data
|-rec
|- rec_gt_train.txt
|- train
|- word_001.png
|- word_002.jpg
|- word_003.jpg
| ...
```
#### Test set
Similar to the training set, the test set also needs to be provided a folder containing all images (test) and a rec_gt_test.txt. The structure of the test set is as follows:
```text linenums="1"
|-train_data
|-rec
|-ic15_data
|- rec_gt_test.txt
|- test
|- word_001.jpg
|- word_002.jpg
|- word_003.jpg
| ...
```
### 2.2 Public dataset
| dataset | Image download link | PaddleOCR format annotation download link |
|---|---|---|
| en benchmark(MJ, SJ, IIIT, SVT, IC03, IC13, IC15, SVTP, and CUTE.) | [DTRB](https://github.com/clovaai/deep-text-recognition-benchmark#download-lmdb-dataset-for-traininig-and-evaluation-from-here) | LMDB format, which can be loaded directly with [lmdb_dataset.py](../../../ppocr/data/lmdb_dataset.py) |
|ICDAR 2015| <http://rrc.cvc.uab.es/?ch=4&com=downloads> | [train](https://paddleocr.bj.bcebos.com/dataset/rec_gt_train.txt)/ [test](https://paddleocr.bj.bcebos.com/dataset/rec_gt_test.txt) |
| Multilingual datasets |[Baidu network disk](https://pan.baidu.com/s/1bS_u207Rm7YbY33wOECKDA) Extraction code: frgi <br> [google drive](https://drive.google.com/file/d/18cSWX7wXSy4G0tbKJ0d9PuIaiwRLHpjA/view) | Included in the downloaded image zip |
#### 2.1 ICDAR 2015
The ICDAR 2015 dataset can be downloaded from the link in the table above for quick validation. The lmdb format dataset required by en benchmark can also be downloaded from the table above.
Then download the PaddleOCR format annotation file from the table above.
PaddleOCR also provides a data format conversion script, which can convert the ICDAR official website label to the data format supported by PaddleOCR. The data conversion tool is in `ppocr/utils/gen_label.py`, here is the training set as an example:
```bash linenums="1"
# Convert the label file downloaded from the official website to rec_gt_label.txt
python gen_label.py --mode="rec" --input_path="{path/of/origin/label}" --output_label="rec_gt_label.txt"
```
The data format is as follows, (a) is the original picture, (b) is the Ground Truth text file corresponding to each picture:
![](./images/icdar_rec.png)
## 3. Data storage path
The default storage path for PaddleOCR training data is `PaddleOCR/train_data`, if you already have a dataset on your disk, just create a soft link to the dataset directory:
```bash linenums="1"
# linux and mac os
ln -sf <path/to/dataset> <path/to/paddle_ocr>/train_data/dataset
# windows
mklink /d <path/to/paddle_ocr>/train_data/dataset <path/to/dataset>
```

View File

@@ -0,0 +1,160 @@
---
comments: true
---
# OCR数据集
这里整理了OCR中常用的公开数据集持续更新中欢迎各位小伙伴贡献数据集
## 1. 文本检测
### 1.1 PaddleOCR 文字检测数据格式
PaddleOCR 中的文本检测算法支持的标注文件格式如下,中间用"\t"分隔:
```text linenums="1"
" 图像文件名 json.dumps编码的图像标注信息"
ch4_test_images/img_61.jpg [{"transcription": "MASA", "points": [[310, 104], [416, 141], [418, 216], [312, 179]]}, {...}]
```
json.dumps编码前的图像标注信息是包含多个字典的list字典中的 `points` 表示文本框的四个点的坐标(x, y),从左上角的点开始顺时针排列。
`transcription` 表示当前文本框的文字,**当其内容为“###”时,表示该文本框无效,在训练时会跳过。**
如果您想在我们未提供的数据集上训练,可以按照上述形式构建标注文件。
### 1.2 公开数据集
| 数据集名称 |图片下载地址| PaddleOCR 标注下载地址 |
|---|---|---|
| ICDAR 2015 |<https://rrc.cvc.uab.es/?ch=4&com=downloads>| [train](https://paddleocr.bj.bcebos.com/dataset/train_icdar2015_label.txt) / [test](https://paddleocr.bj.bcebos.com/dataset/test_icdar2015_label.txt) |
| ctw1500 |<https://paddleocr.bj.bcebos.com/dataset/ctw1500.zip>| 图片下载地址中已包含 |
| total text |<https://paddleocr.bj.bcebos.com/dataset/total_text.tar>| 图片下载地址中已包含 |
| td tr |<https://paddleocr.bj.bcebos.com/dataset/TD_TR.tar>| 图片下载地址中已包含 |
#### 1.2.1 ICDAR 2015
ICDAR 2015 数据集包含1000张训练图像和500张测试图像。ICDAR 2015 数据集可以从上表中链接下载,首次下载需注册。
注册完成登陆后,下载下图中红色框标出的部分,其中, `Training Set Images`下载的内容保存在`icdar_c4_train_imgs`文件夹下,`Test Set Images` 下载的内容保存早`ch4_test_images`文件夹下
<img src="./images/ic15_location_download.png" align="middle" width = "700"/>
将下载到的数据集解压到工作目录下,假设解压在 PaddleOCR/train_data/下。然后从上表中下载转换好的标注文件。
PaddleOCR 也提供了数据格式转换脚本,可以将官网 label 转换支持的数据格式。 数据转换工具在 `ppocr/utils/gen_label.py`, 这里以训练集为例:
```bash linenums="1"
# 将官网下载的标签文件转换为 train_icdar2015_label.txt
python gen_label.py --mode="det" --root_path="/path/to/icdar_c4_train_imgs/" \
--input_path="/path/to/ch4_training_localization_transcription_gt" \
--output_label="/path/to/train_icdar2015_label.txt"
```
解压数据集和下载标注文件后PaddleOCR/train_data/ 有两个文件夹和两个文件按照如下方式组织icdar2015数据集
```text linenums="1"
/PaddleOCR/train_data/icdar2015/text_localization/
└─ icdar_c4_train_imgs/ icdar 2015 数据集的训练数据
└─ ch4_test_images/ icdar 2015 数据集的测试数据
└─ train_icdar2015_label.txt icdar 2015 数据集的训练标注
└─ test_icdar2015_label.txt icdar 2015 数据集的测试标注
```
## 2. 文本识别
### 2.1 PaddleOCR 文字识别数据格式
PaddleOCR 中的文字识别算法支持两种数据格式:
- `lmdb` 用于训练以lmdb格式存储的数据集使用 [lmdb_dataset.py](../../../ppocr/data/lmdb_dataset.py) 进行读取;
- `通用数据` 用于训练以文本文件存储的数据集,使用 [simple_dataset.py](../../../ppocr/data/simple_dataset.py)进行读取。
下面以通用数据集为例, 介绍如何准备数据集:
#### 训练集
建议将训练图片放入同一个文件夹并用一个txt文件rec_gt_train.txt记录图片路径和标签txt文件里的内容如下:
**注意:** txt文件中默认请将图片路径和图片标签用 \t 分割,如用其他方式分割将造成训练报错。
```text linenums="1"
" 图像文件名 图像标注信息 "
train_data/rec/train/word_001.jpg 简单可依赖
train_data/rec/train/word_002.jpg 用科技让复杂的世界更简单
...
```
最终训练集应有如下文件结构:
```text linenums="1"
|-train_data
|-rec
|- rec_gt_train.txt
|- train
|- word_001.png
|- word_002.jpg
|- word_003.jpg
| ...
```
除上述单张图像为一行格式之外PaddleOCR也支持对离线增广后的数据进行训练为了防止相同样本在同一个batch中被多次采样我们可以将相同标签对应的图片路径写在一行中以列表的形式给出在训练中PaddleOCR会随机选择列表中的一张图片进行训练。对应地标注文件的格式如下
```text linenums="1"
["11.jpg", "12.jpg"] 简单可依赖
["21.jpg", "22.jpg", "23.jpg"] 用科技让复杂的世界更简单
3.jpg ocr
```
上述示例标注文件中,"11.jpg"和"12.jpg"的标签相同,都是`简单可依赖`,在训练的时候,对于该行标注,会随机选择其中的一张图片进行训练。
#### 验证集
同训练集类似验证集也需要提供一个包含所有图片的文件夹test和一个rec_gt_test.txt验证集的结构如下所示
```text linenums="1"
|-train_data
|-rec
|- rec_gt_test.txt
|- test
|- word_001.jpg
|- word_002.jpg
|- word_003.jpg
| ...
```
### 2.2 公开数据集
| 数据集名称 | 图片下载地址 | PaddleOCR 标注下载地址 |
|---|---|---------------------------------------------------------------------|
| en benchmark(MJ, SJ, IIIT, SVT, IC03, IC13, IC15, SVTP, and CUTE.) | [DTRB](https://github.com/clovaai/deep-text-recognition-benchmark#download-lmdb-dataset-for-traininig-and-evaluation-from-here) | LMDB格式可直接用[lmdb_dataset.py](../../../ppocr/data/lmdb_dataset.py)加载 |
|ICDAR 2015| <http://rrc.cvc.uab.es/?ch=4&com=downloads> | [train](https://paddleocr.bj.bcebos.com/dataset/rec_gt_train.txt)/ [test](https://paddleocr.bj.bcebos.com/dataset/rec_gt_test.txt) |
| 多语言数据集 |[百度网盘](https://pan.baidu.com/s/1bS_u207Rm7YbY33wOECKDA) 提取码frgi <br> [google drive](https://drive.google.com/file/d/18cSWX7wXSy4G0tbKJ0d9PuIaiwRLHpjA/view) | 图片下载地址中已包含 |
#### 2.1 ICDAR 2015
ICDAR 2015 数据集可以在上表中链接下载,用于快速验证。也可以从上表中下载 en benchmark 所需的lmdb格式数据集。
下载完图片后从上表中下载转换好的标注文件。
PaddleOCR 也提供了数据格式转换脚本可以将ICDAR官网 label 转换为PaddleOCR支持的数据格式。 数据转换工具在 `ppocr/utils/gen_label.py`, 这里以训练集为例:
```bash linenums="1"
# 将官网下载的标签文件转换为 rec_gt_label.txt
python gen_label.py --mode="rec" --input_path="{path/of/origin/label}" --output_label="rec_gt_label.txt"
```
数据样式格式如下,(a)为原始图片,(b)为每张图片对应的 Ground Truth 文本文件:
![](./images/icdar_rec.png)
## 3. 数据存放路径
PaddleOCR训练数据的默认存储路径是 `PaddleOCR/train_data`,如果您的磁盘上已有数据集,只需创建软链接至数据集目录:
```bash linenums="1"
# linux and mac os
ln -sf <path/to/dataset> <path/to/paddle_ocr>/train_data/dataset
# windows
mklink /d <path/to/paddle_ocr>/train_data/dataset <path/to/dataset>
```

View File

@@ -0,0 +1,40 @@
---
comments: true
---
# Table Recognition Datasets
Here are the commonly used table recognition datasets, which are being updated continuously. Welcome to contribute datasets~
## Dataset Summary
| dataset | Image download link | PPOCR format annotation download link |
|---|---|---|
| PubTabNet |<https://github.com/ibm-aur-nlp/PubTabNet>| jsonl format, which can be loaded directly with [pubtab_dataset.py](https://github.com/PaddlePaddle/PaddleOCR/blob/main/ppocr/data/pubtab_dataset.py) |
| TAL Table Recognition Competition Dataset |<https://ai.100tal.com/dataset>| jsonl format, which can be loaded directly with [pubtab_dataset.py](https://github.com/PaddlePaddle/PaddleOCR/blob/main/ppocr/data/pubtab_dataset.py) |
| WTW Chinese scene table dataset |<https://github.com/wangwen-whu/WTW-Dataset>| Conversion is required to load with [pubtab_dataset.py](https://github.com/PaddlePaddle/PaddleOCR/blob/main/ppocr/data/pubtab_dataset.py)|
## 1. PubTabNet
- **Data Introduction**The training set of the PubTabNet dataset contains 500,000 images and the validation set contains 9000 images. Part of the image visualization is shown below.
![](./images/table_PubTabNet_demo/PMC524509_007_00.png)
![](./images/table_PubTabNet_demo/PMC535543_007_01.png)
- **illustrate**When using this dataset, the [CDLA-Permissive](https://cdla.io/permissive-1-0/) protocol is required.
## 2. TAL Table Recognition Competition Dataset
- **Data Introduction**The training set of the TAL table recognition competition dataset contains 16,000 images. The validation set does not give trainable annotations.
![](./images/table_tal_demo/1.jpg)
![](./images/table_tal_demo/2.jpg)
## 3. WTW Chinese scene table dataset
- **Data Introduction**The WTW Chinese scene table dataset consists of two parts: table detection and table data. The dataset contains images of two scenes, scanned and photographed.
![img](./images/20210816_210413.gif)

View File

@@ -0,0 +1,43 @@
---
comments: true
typora-copy-images-to: images
---
# 表格识别数据集
这里整理了常用表格识别数据集,持续更新中,欢迎各位小伙伴贡献数据集~
## 数据集汇总
| 数据集名称 |图片下载地址| PPOCR标注下载地址 |
|---|---|---|
| PubTabNet |<https://github.com/ibm-aur-nlp/PubTabNet>| jsonl格式可直接用[pubtab_dataset.py](https://github.com/PaddlePaddle/PaddleOCR/blob/main/ppocr/data/pubtab_dataset.py)加载 |
| 好未来表格识别竞赛数据集 |<https://ai.100tal.com/dataset>| jsonl格式可直接用[pubtab_dataset.py](https://github.com/PaddlePaddle/PaddleOCR/blob/main/ppocr/data/pubtab_dataset.py)加载 |
| WTW中文场景表格数据集 |<https://github.com/wangwen-whu/WTW-Dataset>| 需要进行转换后才能用[pubtab_dataset.py](https://github.com/PaddlePaddle/PaddleOCR/blob/main/ppocr/data/pubtab_dataset.py)加载 |
## 1. PubTabNet数据集
- **数据简介**PubTabNet数据集的训练集合中包含50万张图像验证集合中包含0.9万张图像。部分图像可视化如下所示。
<div align="center">
<img src="./images/table_PubTabNet_demo/PMC524509_007_00.png" width="500">
<img src="./images/table_PubTabNet_demo/PMC535543_007_01.png" width="500">
</div>
- **说明**:使用该数据集时,需要遵守[CDLA-Permissive](https://cdla.io/permissive-1-0/)协议。
## 2. 好未来表格识别竞赛数据集
- **数据简介**好未来表格识别竞赛数据集的训练集合中包含1.6万张图像。验证集未给出可训练的标注。
<div align="center">
<img src="./images/table_tal_demo/1.jpg" width="500">
<img src="./images/table_tal_demo/2.jpg" width="500">
</div>
## 3. WTW中文场景表格数据集
- **数据简介**WTW中文场景表格数据集包含表格检测和表格数据两部分数据数据集中同时包含扫描和拍照两张场景的图像。
![img](./images/20210816_210413.gif)

View File

@@ -0,0 +1,72 @@
---
comments: true
---
# Vertical multi-language OCR dataset
Here we have sorted out the commonly used vertical multi-language OCR dataset datasets, which are being updated continuously. We welcome you to contribute datasets
- [Chinese urban license plate dataset](#Chinese urban license plate dataset)
- [Bank credit card dataset](#Bank credit card dataset)
- [Captcha dataset-Captcha](#Captcha dataset-Captcha)
- [multi-language dataset](#multi-language dataset)
## Chinese urban license plate dataset
- **Data source**[CCPD](https://github.com/detectRecog/CCPD)
- **Data introduction**: It contains more than 250000 vehicle license plate images and vehicle license plate detection and recognition information labeling. It contains the following license plate image information in different scenes.
- CCPD-Base: General license plate picture
- CCPD-DB: The brightness of license plate area is bright, dark or uneven
- CCPD-FN: The license plate is farther or closer to the camera location
- CCPD-Rotate: License plate includes rotation (horizontal 20\~50 degrees, vertical-10\~10 degrees)
- CCPD-Tilt: License plate includes rotation (horizontal 15\~45 degrees, vertical 15\~45 degrees)
- CCPD-Blur: The license plate contains blurring due to camera lens jitter
- CCPD-Weather: The license plate is photographed on rainy, snowy or foggy days
- CCPD-Challenge: So far, some of the most challenging images in license plate detection and recognition tasks
- CCPD-NP: Pictures of new cars without license plates.
![](./images/ccpd_demo.png)
- **Download address**
- Baidu cloud download address (extracted code is hm0U): [https://pan.baidu.com/s/1i5AOjAbtkwb17Zy-NQGqkw](https://pan.baidu.com/s/1i5AOjAbtkwb17Zy-NQGqkw)
- Google drive download address:[https://drive.google.com/file/d/1rdEsCUcIUaYOVRkx5IMTRNA7PcGMmSgc/view](https://drive.google.com/file/d/1rdEsCUcIUaYOVRkx5IMTRNA7PcGMmSgc/view)
## Bank credit card dataset
- **Data source**: [source](https://www.kesci.com/home/dataset/5954cf1372ead054a5e25870)
- **Data introduction**: There are three types of training data
- 1.Sample card data of China Merchants Bank: including card image data and annotation data, a total of 618 pictures
- 2.Single character data: including pictures and annotation data, 37 pictures in total.
- 3.There are only other bank cards, no more detailed information, a total of 50 pictures.
- The demo image is shown as follows. The annotation information is stored in excel, and the demo image below is marked as
- Top 8 card number: 62257583
- Card type: card of our bank
- End of validity: 07/41
- Chinese phonetic alphabet of card users: MICHAEL
![](./images/cmb_demo.jpg)
- **Download address**: [cmb2017-2.zip](https://cdn.kesci.com/cmb2017-2.zip)
## Captcha dataset-Captcha
- **Data source**: [captcha](https://github.com/lepture/captcha)
- **Data introduction**: This is a toolkit for data synthesis. You can output captcha images according to the input text. Use the toolkit to generate several demo images as follows.
![](./images/captcha_demo.png)
- **Download address**: The dataset is generated and has no download address.
## multi-language dataset(Multi-lingual scene text detection and recognition)
- **Data source**: [source](https://rrc.cvc.uab.es/?ch=15&com=downloads)
- **Data introduction**: Multi language detection dataset MLT contains both language recognition and detection tasks.
- In the detection task, the training set contains 10000 images in 10 languages, and each language contains 1000 training images. The test set contains 10000 images.
- In the recognition task, the training set contains 111998 samples.
- **Download address**: The training set is large and can be downloaded in two parts. It can only be downloaded after registering on the website:
[source](https://rrc.cvc.uab.es/?ch=15&com=downloads)

View File

@@ -0,0 +1,65 @@
---
comments: true
---
# 垂类多语言OCR数据集
这里整理了常用垂类和多语言OCR数据集持续更新中欢迎各位小伙伴贡献数据集
## 中国城市车牌数据集
- **数据来源**[CCPD](https://github.com/detectRecog/CCPD)
- **数据简介**: 包含超过25万张中国城市车牌图片及车牌检测、识别信息的标注。包含以下几种不同场景中的车牌图片信息。
- CCPD-Base: 通用车牌图片
- CCPD-DB: 车牌区域亮度较亮、较暗或者不均匀
- CCPD-FN: 车牌离摄像头拍摄位置相对更远或者更近
- CCPD-Rotate: 车牌包含旋转水平20\~50度竖直-10\~10度
- CCPD-Tilt: 车牌包含旋转水平15\~45度竖直15\~45度
- CCPD-Blur: 车牌包含由于摄像机镜头抖动导致的模糊情况
- CCPD-Weather: 车牌在雨天、雪天或者雾天拍摄得到
- CCPD-Challenge: 至今在车牌检测识别任务中最有挑战性的一些图片
- CCPD-NP: 没有安装车牌的新车图片。
![](./images/ccpd_demo.png)
- **下载地址**
- 百度云下载地址(提取码是hm0U): [link](https://pan.baidu.com/s/1i5AOjAbtkwb17Zy-NQGqkw)
- Google drive下载地址[link](https://drive.google.com/file/d/1rdEsCUcIUaYOVRkx5IMTRNA7PcGMmSgc/view)
## 银行信用卡数据集
- **数据来源**: [source](https://www.kesci.com/home/dataset/5954cf1372ead054a5e25870)
- **数据简介**: 训练数据共提供了三类数据
- 1.招行样卡数据: 包括卡面图片数据及标注数据总共618张图片
- 2.单字符数据: 包括图片及标注数据总共37张图片。
- 3.仅包含其他银行卡面不具有更细致的信息总共50张图片。
- demo图片展示如下标注信息存储在excel表格中下面的demo图片标注为
- 前8位卡号62257583
- 卡片种类:本行卡
- 有效期结束07/41
- 卡用户拼音MICHAEL
![](./images/cmb_demo.jpg)
- **下载地址**: [cmb2017-2.zip](https://cdn.kesci.com/cmb2017-2.zip)
## 验证码数据集-Captcha
- **数据来源**: [captcha](https://github.com/lepture/captcha)
- **数据简介**: 这是一个数据合成的工具包可以根据输入的文本输出验证码图片使用该工具包生成几张demo图片如下
![](./images/captcha_demo.png)
- **下载地址**: 该数据集是生成得到,无下载地址。
## 多语言数据集(Multi-lingual scene text detection and recognition)
- **数据来源**: [source](https://rrc.cvc.uab.es/?ch=15&com=downloads)
- **数据简介**: 多语言检测数据集MLT同时包含了语种识别和检测任务。
- 在检测任务中训练集包含10000张图片共有10种语言每种语言包含1000张训练图片。测试集包含10000张图片。
- 在识别任务中训练集包含111998个样本。
- **下载地址**: 训练集较大分2部分下载需要在网站上注册之后才能下载
[link](https://rrc.cvc.uab.es/?ch=15&com=downloads)

BIN
docs/images/00006737.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 212 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 234 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 143 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 910 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 247 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 189 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 344 KiB

BIN
docs/images/Arch.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 212 KiB

BIN
docs/images/Arch_cn.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 MiB

BIN
docs/images/Banner.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 448 KiB

BIN
docs/images/Banner_cn.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 442 KiB

BIN
docs/images/Banner_ja.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 521 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 97 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 139 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 89 KiB

BIN
docs/images/blue_v3.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 MiB

BIN
docs/images/demo.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 MiB

BIN
docs/images/en_1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 636 KiB

BIN
docs/images/en_2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 626 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 498 KiB

BIN
docs/images/en_3.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 498 KiB

BIN
docs/images/japan_2.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 478 KiB

BIN
docs/images/korean_1.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 158 KiB

BIN
docs/images/ppocrv4.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 MiB

BIN
docs/images/ppocrv4_en.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 409 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 MiB

BIN
docs/images/test_add_91.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 78 KiB

43
docs/index.en.md Normal file
View File

@@ -0,0 +1,43 @@
---
comments: true
hide:
- navigation
- toc
---
![PaddleOCR Banner](./images/Banner.png)
Since its initial release, PaddleOCR has gained widespread acclaim across academia, industry, and research communities, thanks to its cutting-edge algorithms and proven performance in real-world applications. Its already powering popular open-source projects like Umi-OCR, OmniParser, MinerU, and RAGFlow, making it the go-to OCR toolkit for developers worldwide.
On May 20, 2025, the PaddlePaddle team unveiled PaddleOCR 3.0, fully compatible with the official release of the [PaddlePaddle 3.0](https://github.com/PaddlePaddle/Paddle) framework. This update further **boosts text-recognition accuracy**, adds support for **multiple text-type recognition** and **handwriting recognition**, and meets the growing demand from large-model applications for **high-precision parsing of complex documents**. When combined with the **ERNIE 4.5 Turbo**, it significantly enhances key-information extraction accuracy. PaddleOCR 3.0 also introduces support for domestic hardware platforms such as **KUNLUNXIN** and **Ascend**.
Three Major New Features in PaddleOCR 3.0:
- 🖼️ Universal-Scene Text Recognition Model [PP-OCRv5](version3.x/algorithm/PP-OCRv5/PP-OCRv5.en.md): A single model that handles five different text types plus complex handwriting. Overall recognition accuracy has increased by 13 percentage points over the previous generation.[Online Demo](https://aistudio.baidu.com/community/app/91660/webUI)
- 🧮 General Document-Parsing Solution [PP-StructureV3](./version3.x/algorithm/PP-StructureV3/PP-StructureV3.en.md): Delivers high-precision parsing of multi-layout, multi-scene PDFs, outperforming many open- and closed-source solutions on public benchmarks. [Online Demo](https://aistudio.baidu.com/community/app/518494/webUI)
- 📈 Intelligent Document-Understanding Solution [PP-ChatOCRv4](./version3.x/algorithm/PP-ChatOCRv4/PP-ChatOCRv4.en.md): Natively powered by the ERNIE 4.5 Turbo, achieving 15 percentage points higher accuracy than its predecessor.[Online Demo](https://aistudio.baidu.com/community/app/518493/webUI)
In addition to providing an outstanding model library, PaddleOCR 3.0 also offers user-friendly tools covering model training, inference, and service deployment, so developers can rapidly bring AI applications to production.
![PaddleOCR Arch](./images/Arch.png)
You can [Quick Start](./quick_start.en.md) directly, find comprehensive documentation in the [PaddleOCR Docs](https://paddlepaddle.github.io/PaddleOCR/main/index.html), get support via [Github Issus](https://github.com/PaddlePaddle/PaddleOCR/issues), and explore our OCR courses on [OCR courses on AIStudio](https://aistudio.baidu.com/course/introduce/25207).
## 🔄 Quick Overview of Execution Results
![PP-OCRv5 Demo](./images/demo.gif)
![PP-StructureV3 Demo](./images/blue_v3.gif)
## 👩‍👩‍👧‍👦 Community
* 👫 Join the [PaddlePaddle Community](https://github.com/PaddlePaddle/community), where you can engage with [paddlepaddle developers](https://www.paddlepaddle.org.cn/developercommunity), researchers, and enthusiasts from around the world.
* 🎓 Learn from experts through workshops, tutorials, and Q&A sessions [hosted by the AI Studio](https://aistudio.baidu.com/learn/center).
* 🏆 Participate in [hackathons, challenges, and competitions](https://aistudio.baidu.com/competition) to showcase your skills and win exciting prizes.
* 📣 Stay updated with the latest news, announcements, and events by following our [Twitter](https://x.com/PaddlePaddle) and [WeChat](https://mp.weixin.qq.com/s/vYj1ZDcAfJ1lu_DzlOKgtQ)).

60
docs/index.md Normal file
View File

@@ -0,0 +1,60 @@
---
comments: true
hide:
- navigation
- toc
---
<div align="center">
<p>
<a href="https://paddlepaddle.github.io/PaddleOCR/latest/index.html" target="_blank">
<img width="100%" src="./images/Banner_cn.png" alt="PaddleOCR Banner"></a>
</p>
</div>
PaddleOCR自发布以来凭借学术前沿算法和产业落地实践受到了产学研各方的喜爱并被广泛应用于众多知名开源项目例如Umi-OCR、OmniParser、MinerU、RAGFlow等已成为广大开发者心中的开源OCR领域的首选工具。2025年5月20日飞桨团队发布**PaddleOCR 3.0**,全面适配[飞桨框架3.0](https://github.com/PaddlePaddle/Paddle)正式版,进一步**提升文字识别精度**,支持**多文字类型识别**和**手写体识别**,满足大模型应用对**复杂文档高精度解析**的旺盛需求,结合**文心大模型4.5 Turbo**显著提升关键信息抽取精度,并新增**对昆仑芯、昇腾等国产硬件**的支持。
PaddleOCR 3.0**新增**三大特色能力:
- 🖼️全场景文字识别模型[PP-OCRv5](./version3.x/algorithm/PP-OCRv5/PP-OCRv5.md):单模型支持五种文字类型和复杂手写体识别;整体识别精度相比上一代**提升13个百分点**。[在线体验](https://aistudio.baidu.com/community/app/91660/webUI)
- 🧮通用文档解析方案[PP-StructureV3](./version3.x/algorithm/PP-StructureV3/PP-StructureV3.md):支持多场景、多版式 PDF 高精度解析,在公开评测集中**领先众多开源和闭源方案**。[在线体验](https://aistudio.baidu.com/community/app/518494/webUI)
- 📈智能文档理解方案[PP-ChatOCRv4](./version3.x/algorithm/PP-ChatOCRv4/PP-ChatOCRv4.md)原生支持文心大模型4.5 Turbo精度相比上一代**提升15个百分点**。[在线体验](https://aistudio.baidu.com/community/app/518493/webUI)
PaddleOCR 3.0除了提供优秀的模型库外还提供好学易用的工具覆盖模型训练、推理和服务化部署方便开发者快速落地AI应用。
<div align="center">
<p>
<a href="https://paddlepaddle.github.io/PaddleOCR/latest/index.html" target="_blank">
<img width="100%" src="./images/Arch_cn.png" alt="PaddleOCR Architecture"></a>
</p>
</div>
您可直接[快速开始](./quick_start.md),或查阅完整的 [PaddleOCR 文档](https://paddlepaddle.github.io/PaddleOCR/main/index.html),或通过 [Github Issues](https://github.com/PaddlePaddle/PaddleOCR/issues) 获取支持,或在 [AIStudio 课程平台](https://aistudio.baidu.com/course/introduce/25207) 探索我们的 OCR 课程。
## 🔄 快速一览运行效果
<div align="center">
<p>
<a href="https://paddlepaddle.github.io/PaddleOCR/latest/index.html" target="_blank">
<img width="100%" src="./images/demo.gif" alt="PP-OCRv5 Demo"></a>
</p>
</div>
<div align="center">
<p>
<a href="https://paddlepaddle.github.io/PaddleOCR/latest/index.html" target="_blank">
<img width="100%" src="./images/blue_v3.gif" alt="PP-StructureV3 Demo"></a>
</p>
</div>
## 👩‍👩‍👧‍👦 开发者社区
* 👫 加入 [PaddlePaddle 开发者社区](https://github.com/PaddlePaddle/community),与全球开发者、研究人员互动交流
* 🎓 通过 AI Studio 的 [技术研讨会](https://aistudio.baidu.com/learn/center) 学习前沿技术
* 🏆 参与 [黑客马拉松](https://aistudio.baidu.com/competition) 展示才能,赢取奖励
* 📣 关注 [微信公众号](https://mp.weixin.qq.com/s/vYj1ZDcAfJ1lu_DzlOKgtQ) 获取最新动态

Some files were not shown because too many files have changed in this diff Show More