Merge branch 'release/2.0' into release2.0

This commit is contained in:
Evezerest 2021-03-05 21:59:15 +08:00 committed by GitHub
commit 84ef96f35d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 67 additions and 48 deletions

View File

@ -8,7 +8,7 @@ PaddleOCR同时支持动态图与静态图两种编程范式
- 静态图版本develop分支
**近期更新**
- 2021.2.22 [FAQ](./doc/doc_ch/FAQ.md)新增5个高频问题总数172个,每周一都会更新,欢迎大家持续关注。
- 2021.3.1 [FAQ](./doc/doc_ch/FAQ.md)新增5个高频问题总数177个,每周一都会更新,欢迎大家持续关注。
- 2021.2.8 正式发布PaddleOCRv2.0(branch release/2.0)并设置为推荐用户使用的默认分支. 发布的详细内容,请参考: https://github.com/PaddlePaddle/PaddleOCR/releases/tag/v2.0.0
- 2021.1.26,28,29 PaddleOCR官方研发团队带来技术深入解读三日直播课1月26日、28日、29日晚上19:30[直播地址](https://live.bilibili.com/21689802)
- 2021.1.21 更新多语言识别模型目前支持语种超过27种[多语言模型下载](./doc/doc_ch/models_list.md),包括中文简体、中文繁体、英文、法文、德文、韩文、日文、意大利文、西班牙文、葡萄牙文、俄罗斯文、阿拉伯文等,后续计划可以参考[多语言研发计划](https://github.com/PaddlePaddle/PaddleOCR/issues/1048)

View File

@ -131,7 +131,7 @@ if __name__ == '__main__':
if FLAGS.val:
global_config['Eval']['dataset']['label_file_list'] = [FLAGS.val]
eval_label_path = os.path.join(project_path,FLAGS.val)
loss_file(Eval_label_path)
loss_file(eval_label_path)
if FLAGS.dict:
global_config['Global']['character_dict_path'] = FLAGS.dict
dict_path = os.path.join(project_path,FLAGS.dict)

View File

@ -76,7 +76,7 @@ void CRNNRecognizer::Run(std::vector<std::vector<std::vector<int>>> boxes,
float(*std::max_element(&predict_batch[n * predict_shape[2]],
&predict_batch[(n + 1) * predict_shape[2]]));
if (argmax_idx > 0 && (!(i > 0 && argmax_idx == last_index))) {
if (argmax_idx > 0 && (!(n > 0 && argmax_idx == last_index))) {
score += max_value;
count += 1;
str_res.push_back(label_list_[argmax_idx]);

View File

@ -9,55 +9,47 @@
## PaddleOCR常见问题汇总(持续更新)
* [近期更新2021.2.22](#近期更新)
* [近期更新2021.3.1](#近期更新)
* [【精选】OCR精选10个问题](#OCR精选10个问题)
* [【理论篇】OCR通用32个问题](#OCR通用问题)
* [基础知识7题](#基础知识)
* [数据集7题](#数据集2)
* [模型训练调优18题](#模型训练调优2)
* [【实战篇】PaddleOCR实战125个问题](#PaddleOCR实战问题)
* [使用咨询43题](#使用咨询)
* [【实战篇】PaddleOCR实战130个问题](#PaddleOCR实战问题)
* [使用咨询48题](#使用咨询)
* [数据集18题](#数据集3)
* [模型训练调优30题](#模型训练调优3)
* [预测部署39题](#预测部署3)
<a name="近期更新"></a>
## 近期更新2021.2.22
## 近期更新2021.3.1
#### Q3.1.42: 训练识别任务的时候在CPU上运行时报错`The setting of Parameter-Server must has server_num or servers`。
#### Q3.1.44: 文字识别训练设置图像高度不等于32时报错
**A**ctc decode的时候输入需要是1维向量因此降采样之后建议特征图高度为1ppocr中特征图会降采样32倍之后高度正好为1所以有2种解决方案
- 指定输入shape高度为32推荐
- 在backbone的mv3中添加更多的降采样模块保证输出的特征图高度为1
**A**:这是训练任务启动方式不对造成的。
#### Q3.1.45: 增大batch_size模型训练速度没有明显提升
如果bs打得太大加速效果不明显的话可以试一下增大初始化内存的值运行代码前设置环境变量
```
export FLAGS_initial_cpu_memory_in_mb=2000 # 设置初始化内存约2G左右
```
1. 在使用CPU或者单块GPU训练的时候可以直接使用`python3 tools/train.py -c xxx.yml`的方式启动。
2. 在使用多块GPU训练的时候需要使用`distributed.launch`的方式启动,如`python3 -m paddle.distributed.launch --gpus '0,1,2,3' tools/train.py -c xxx.yml`这种方式需要安装NCCL库如果没有的话会报错。
#### Q3.1.46: 动态图分支(dygraph,release/2.0),训练模型和推理模型效果不一致
当前问题表现为使用训练完的模型直接测试结果较好但是转换为inference model后预测结果不一致出现这个问题一般是两个原因
- 1. 预处理函数设置的不一致
- 2. 后处理参数不一致
repo中config.yml文件的前后处理参数和inference预测默认的超参数有不一致的地方建议排查下训练模型预测和inference预测的前后处理
参考[issue](https://github.com/PaddlePaddle/PaddleOCR/issues/2080)。
#### Q3.1.43使用StyleText进行数据合成时文本(TextInput)的长度远超StyleInput的长度该怎么处理与合成呢
#### Q3.1.47: paddleocr package 报错 FatalError: `Process abort signal` is detected by the operating system
首先,按照[安装文档](./installation.md)安装PaddleOCR的运行环境另外检查python环境python3.6/3.8上可能会出现这个问题建议用python3.7
参考[issue](https://github.com/PaddlePaddle/PaddleOCR/issues/2069)。
**A**在使用StyleText进行数据合成的时候建议StyleInput的长度长于TextInput的长度。有2种方法可以处理上述问题
1. 将StyleInput按列的方向进行复制与扩充直到其超过TextInput的长度。
2. 将TextInput进行裁剪保证每段TextInput都稍短于StyleInput分别合成之后,再拼接在一起。
实际使用中发现使用第2种方法的效果在长文本合成的场景中的合成效果更好StyleText中提供的也是第2种数据合成的逻辑。
#### Q3.4.37: 在windows上进行cpp inference的部署时总是提示找不到`paddle_fluid.dll`和`opencv_world346.dll`
**A**有2种方法可以解决这个问题
1. 将paddle预测库和opencv库的地址添加到系统环境变量中。
2. 将提示缺失的dll文件拷贝到编译产出的`ocr_system.exe`文件夹中。
#### Q3.4.38想在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)
#### Q3.4.39:内网环境如何进行服务化部署呢?
**A**仍然可以使用PaddleServing或者HubServing进行服务化部署保证内网地址可以访问即可。
#### Q3.1.48: 下载的识别模型解压后缺失文件没有期望的inference.pdiparams, inference.pdmodel等文件
用解压软件解压可能会出现这个问题,建议二次解压下或者用命令行解压`tar xf `
<a name="OCR精选10个问题"></a>
@ -531,6 +523,35 @@ release/2.0-rc1-0是基于Paddle 2.0rc1的稳定版本release/2.0是基于Pad
实际使用中发现使用第2种方法的效果在长文本合成的场景中的合成效果更好StyleText中提供的也是第2种数据合成的逻辑。
#### Q3.1.44: 文字识别训练设置图像高度不等于32时报错
**A**ctc decode的时候输入需要是1维向量因此降采样之后建议特征图高度为1ppocr中特征图会降采样32倍之后高度正好为1所以有2种解决方案
- 指定输入shape高度为32推荐
- 在backbone的mv3中添加更多的降采样模块保证输出的特征图高度为1
#### Q3.1.45: 增大batch_size模型训练速度没有明显提升
如果bs打得太大加速效果不明显的话可以试一下增大初始化内存的值运行代码前设置环境变量
```
export FLAGS_initial_cpu_memory_in_mb=2000 # 设置初始化内存约2G左右
```
#### Q3.1.46: 动态图分支(dygraph,release/2.0),训练模型和推理模型效果不一致
当前问题表现为使用训练完的模型直接测试结果较好但是转换为inference model后预测结果不一致出现这个问题一般是两个原因
- 1. 预处理函数设置的不一致
- 2. 后处理参数不一致
repo中config.yml文件的前后处理参数和inference预测默认的超参数有不一致的地方建议排查下训练模型预测和inference预测的前后处理
参考[issue](https://github.com/PaddlePaddle/PaddleOCR/issues/2080)。
#### Q3.1.47: paddleocr package 报错 FatalError: `Process abort signal` is detected by the operating system
首先,按照[安装文档](./installation.md)安装PaddleOCR的运行环境另外检查python环境python3.6/3.8上可能会出现这个问题建议用python3.7
参考[issue](https://github.com/PaddlePaddle/PaddleOCR/issues/2069)。
#### Q3.1.48: 下载的识别模型解压后缺失文件没有期望的inference.pdiparams, inference.pdmodel等文件
用解压软件解压可能会出现这个问题,建议二次解压下或者用命令行解压`tar xf `
<a name="数据集3"></a>
### 数据集

View File

@ -32,7 +32,6 @@ class MakeShrinkMap(object):
text_polys, ignore_tags = self.validate_polygons(text_polys,
ignore_tags, h, w)
gt = np.zeros((h, w), dtype=np.float32)
# gt = np.zeros((1, h, w), dtype=np.float32)
mask = np.ones((h, w), dtype=np.float32)
for i in range(len(text_polys)):
polygon = text_polys[i]
@ -51,7 +50,8 @@ class MakeShrinkMap(object):
shrinked = []
# Increase the shrink ratio every time we get multiple polygon returned back
possible_ratios = np.arange(self.shrink_ratio, 1, self.shrink_ratio)
possible_ratios = np.arange(self.shrink_ratio, 1,
self.shrink_ratio)
np.append(possible_ratios, 1)
# print(possible_ratios)
for ratio in possible_ratios:
@ -104,4 +104,4 @@ class MakeShrinkMap(object):
edge += (polygon[next_index, 0] - polygon[i, 0]) * (
polygon[next_index, 1] - polygon[i, 1])
return edge / 2.
return edge / 2.

View File

@ -14,7 +14,6 @@
import logging
import os
import imghdr
import cv2
@ -51,13 +50,15 @@ def get_image_file_list(img_file):
if img_file is None or not os.path.exists(img_file):
raise Exception("not found any img file in {}".format(img_file))
img_end = {'jpg', 'bmp', 'png', 'jpeg', 'rgb', 'tif', 'tiff', 'gif', 'GIF'}
if os.path.isfile(img_file) and imghdr.what(img_file) in img_end:
img_end = {'jpg', 'bmp', 'png', 'jpeg', 'rgb', 'tif', 'tiff', 'gif'}
if os.path.isfile(img_file) and os.path.splitext(img_file)[-1][1:].lower(
) in img_end:
imgs_lists.append(img_file)
elif os.path.isdir(img_file):
for single_file in os.listdir(img_file):
file_path = os.path.join(img_file, single_file)
if os.path.isfile(file_path) and imghdr.what(file_path) in img_end:
if os.path.isfile(file_path) and os.path.splitext(file_path)[-1][
1:].lower() in img_end:
imgs_lists.append(file_path)
if len(imgs_lists) == 0:
raise Exception("not found any img file in {}".format(img_file))
@ -76,4 +77,4 @@ def check_and_read_gif(img_path):
frame = cv2.cvtColor(frame, cv2.COLOR_GRAY2RGB)
imgvalue = frame[:, :, ::-1]
return imgvalue, True
return None, False
return None, False

View File

@ -39,10 +39,7 @@ class TextDetector(object):
self.args = args
self.det_algorithm = args.det_algorithm
pre_process_list = [{
'DetResizeForTest': {
'limit_side_len': args.det_limit_side_len,
'limit_type': args.det_limit_type
}
'DetResizeForTest': None
}, {
'NormalizeImage': {
'std': [0.229, 0.224, 0.225],

View File

@ -97,7 +97,7 @@ def main():
preds = model(images)
post_result = post_process_class(preds, shape_list)
boxes = post_result[0]['points']
# write resule
# write result
dt_boxes_json = []
for box in boxes:
tmp_json = {"transcription": ""}