未验证 提交 9a717433 编写于 作者: T topduke 提交者: GitHub

Merge branch 'PaddlePaddle:dygraph' into dygraph

此差异已折叠。
5ZQ
I4UL
PWL
SNOG
ZL02
1C30
O3H
YHRS
N03S
1U5Y
JTK
EN4F
YKJ
DWNH
R42W
X0V
4OF5
08AM
Y93S
GWE2
0KR
9U2A
DBQ
Y6J
ROZ
K06
KIEY
NZQJ
UN1B
6X4
\ No newline at end of file
# copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""
This code is refer from:
https://github.com/zcswdt/Color_OCR_image_generator
"""
import os
import random
from PIL import Image, ImageDraw, ImageFont
import json
import argparse
def get_char_lines(txt_root_path):
"""
desc:get corpus line
"""
txt_files = os.listdir(txt_root_path)
char_lines = []
for txt in txt_files:
f = open(os.path.join(txt_root_path, txt), mode='r', encoding='utf-8')
lines = f.readlines()
f.close()
for line in lines:
char_lines.append(line.strip())
return char_lines
def get_horizontal_text_picture(image_file, chars, fonts_list, cf):
"""
desc:gen horizontal text picture
"""
img = Image.open(image_file)
if img.mode != 'RGB':
img = img.convert('RGB')
img_w, img_h = img.size
# random choice font
font_path = random.choice(fonts_list)
# random choice font size
font_size = random.randint(cf.font_min_size, cf.font_max_size)
font = ImageFont.truetype(font_path, font_size)
ch_w = []
ch_h = []
for ch in chars:
wt, ht = font.getsize(ch)
ch_w.append(wt)
ch_h.append(ht)
f_w = sum(ch_w)
f_h = max(ch_h)
# add space
char_space_width = max(ch_w)
f_w += (char_space_width * (len(chars) - 1))
x1 = random.randint(0, img_w - f_w)
y1 = random.randint(0, img_h - f_h)
x2 = x1 + f_w
y2 = y1 + f_h
crop_y1 = y1
crop_x1 = x1
crop_y2 = y2
crop_x2 = x2
best_color = (0, 0, 0)
draw = ImageDraw.Draw(img)
for i, ch in enumerate(chars):
draw.text((x1, y1), ch, best_color, font=font)
x1 += (ch_w[i] + char_space_width)
crop_img = img.crop((crop_x1, crop_y1, crop_x2, crop_y2))
return crop_img, chars
def get_vertical_text_picture(image_file, chars, fonts_list, cf):
"""
desc:gen vertical text picture
"""
img = Image.open(image_file)
if img.mode != 'RGB':
img = img.convert('RGB')
img_w, img_h = img.size
# random choice font
font_path = random.choice(fonts_list)
# random choice font size
font_size = random.randint(cf.font_min_size, cf.font_max_size)
font = ImageFont.truetype(font_path, font_size)
ch_w = []
ch_h = []
for ch in chars:
wt, ht = font.getsize(ch)
ch_w.append(wt)
ch_h.append(ht)
f_w = max(ch_w)
f_h = sum(ch_h)
x1 = random.randint(0, img_w - f_w)
y1 = random.randint(0, img_h - f_h)
x2 = x1 + f_w
y2 = y1 + f_h
crop_y1 = y1
crop_x1 = x1
crop_y2 = y2
crop_x2 = x2
best_color = (0, 0, 0)
draw = ImageDraw.Draw(img)
i = 0
for ch in chars:
draw.text((x1, y1), ch, best_color, font=font)
y1 = y1 + ch_h[i]
i = i + 1
crop_img = img.crop((crop_x1, crop_y1, crop_x2, crop_y2))
crop_img = crop_img.transpose(Image.ROTATE_90)
return crop_img, chars
def get_fonts(fonts_path):
"""
desc: get all fonts
"""
font_files = os.listdir(fonts_path)
fonts_list=[]
for font_file in font_files:
font_path=os.path.join(fonts_path, font_file)
fonts_list.append(font_path)
return fonts_list
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('--num_img', type=int, default=30, help="Number of images to generate")
parser.add_argument('--font_min_size', type=int, default=11)
parser.add_argument('--font_max_size', type=int, default=12,
help="Help adjust the size of the generated text and the size of the picture")
parser.add_argument('--bg_path', type=str, default='./background',
help='The generated text pictures will be pasted onto the pictures of this folder')
parser.add_argument('--det_bg_path', type=str, default='./det_background',
help='The generated text pictures will use the pictures of this folder as the background')
parser.add_argument('--fonts_path', type=str, default='../../StyleText/fonts',
help='The font used to generate the picture')
parser.add_argument('--corpus_path', type=str, default='./corpus',
help='The corpus used to generate the text picture')
parser.add_argument('--output_dir', type=str, default='./output/', help='Images save dir')
cf = parser.parse_args()
# save path
if not os.path.exists(cf.output_dir):
os.mkdir(cf.output_dir)
# get corpus
txt_root_path = cf.corpus_path
char_lines = get_char_lines(txt_root_path=txt_root_path)
# get all fonts
fonts_path = cf.fonts_path
fonts_list = get_fonts(fonts_path)
# rec bg
img_root_path = cf.bg_path
imnames=os.listdir(img_root_path)
# det bg
det_bg_path = cf.det_bg_path
bg_pics = os.listdir(det_bg_path)
# OCR det files
det_val_file = open(cf.output_dir + 'det_gt_val.txt', 'w', encoding='utf-8')
det_train_file = open(cf.output_dir + 'det_gt_train.txt', 'w', encoding='utf-8')
# det imgs
det_save_dir = 'imgs/'
if not os.path.exists(cf.output_dir + det_save_dir):
os.mkdir(cf.output_dir + det_save_dir)
det_val_save_dir = 'imgs_val/'
if not os.path.exists(cf.output_dir + det_val_save_dir):
os.mkdir(cf.output_dir + det_val_save_dir)
# OCR rec files
rec_val_file = open(cf.output_dir + 'rec_gt_val.txt', 'w', encoding='utf-8')
rec_train_file = open(cf.output_dir + 'rec_gt_train.txt', 'w', encoding='utf-8')
# rec imgs
rec_save_dir = 'rec_imgs/'
if not os.path.exists(cf.output_dir + rec_save_dir):
os.mkdir(cf.output_dir + rec_save_dir)
rec_val_save_dir = 'rec_imgs_val/'
if not os.path.exists(cf.output_dir + rec_val_save_dir):
os.mkdir(cf.output_dir + rec_val_save_dir)
val_ratio = cf.num_img * 0.2 # val dataset ratio
print('start generating...')
for i in range(0, cf.num_img):
imname = random.choice(imnames)
img_path = os.path.join(img_root_path, imname)
rnd = random.random()
# gen horizontal text picture
if rnd < 0.5:
gen_img, chars = get_horizontal_text_picture(img_path, char_lines[i], fonts_list, cf)
ori_w, ori_h = gen_img.size
gen_img = gen_img.crop((0, 3, ori_w, ori_h))
# gen vertical text picture
else:
gen_img, chars = get_vertical_text_picture(img_path, char_lines[i], fonts_list, cf)
ori_w, ori_h = gen_img.size
gen_img = gen_img.crop((3, 0, ori_w, ori_h))
ori_w, ori_h = gen_img.size
# rec imgs
save_img_name = str(i).zfill(4) + '.jpg'
if i < val_ratio:
save_dir = os.path.join(rec_val_save_dir, save_img_name)
line = save_dir + '\t' + char_lines[i] + '\n'
rec_val_file.write(line)
else:
save_dir = os.path.join(rec_save_dir, save_img_name)
line = save_dir + '\t' + char_lines[i] + '\n'
rec_train_file.write(line)
gen_img.save(cf.output_dir + save_dir, quality = 95, subsampling=0)
# det img
# random choice bg
bg_pic = random.sample(bg_pics, 1)[0]
det_img = Image.open(os.path.join(det_bg_path, bg_pic))
# the PCB position is fixed, modify it according to your own scenario
if bg_pic == '1.png':
x1 = 38
y1 = 3
else:
x1 = 34
y1 = 1
det_img.paste(gen_img, (x1, y1))
# text pos
chars_pos = [[x1, y1], [x1 + ori_w, y1], [x1 + ori_w, y1 + ori_h], [x1, y1 + ori_h]]
label = [{"transcription":char_lines[i], "points":chars_pos}]
if i < val_ratio:
save_dir = os.path.join(det_val_save_dir, save_img_name)
det_val_file.write(save_dir + '\t' + json.dumps(
label, ensure_ascii=False) + '\n')
else:
save_dir = os.path.join(det_save_dir, save_img_name)
det_train_file.write(save_dir + '\t' + json.dumps(
label, ensure_ascii=False) + '\n')
det_img.save(cf.output_dir + save_dir, quality = 95, subsampling=0)
...@@ -249,7 +249,7 @@ tar -xf ch_PP-OCRv3_det_distill_train.tar ...@@ -249,7 +249,7 @@ tar -xf ch_PP-OCRv3_det_distill_train.tar
cd /home/aistudio/PaddleOCR cd /home/aistudio/PaddleOCR
``` ```
预训练模型下载完成后,我们使用[ch_PP-OCRv3_det_student.yml](../configs/chepai/ch_PP-OCRv3_det_student.yml) 配置文件进行后续实验,在开始评估之前需要对配置文件中部分字段进行设置,具体如下: 预训练模型下载完成后,我们使用[ch_PP-OCRv3_det_student.yml](../configs/det/ch_PP-OCRv3/ch_PP-OCRv3_det_student.yml) 配置文件进行后续实验,在开始评估之前需要对配置文件中部分字段进行设置,具体如下:
1. 模型存储和训练相关: 1. 模型存储和训练相关:
1. Global.pretrained_model: 指向PP-OCRv3文本检测预训练模型地址 1. Global.pretrained_model: 指向PP-OCRv3文本检测预训练模型地址
...@@ -787,12 +787,12 @@ python tools/infer/predict_system.py \ ...@@ -787,12 +787,12 @@ python tools/infer/predict_system.py \
- 端侧部署 - 端侧部署
端侧部署我们采用基于 PaddleLite 的 cpp 推理。Paddle Lite是飞桨轻量化推理引擎,为手机、IOT端提供高效推理能力,并广泛整合跨平台硬件,为端侧部署及应用落地问题提供轻量化的部署方案。具体可参考 [PaddleOCR lite教程](../dygraph/deploy/lite/readme_ch.md) 端侧部署我们采用基于 PaddleLite 的 cpp 推理。Paddle Lite是飞桨轻量化推理引擎,为手机、IOT端提供高效推理能力,并广泛整合跨平台硬件,为端侧部署及应用落地问题提供轻量化的部署方案。具体可参考 [PaddleOCR lite教程](../deploy/lite/readme_ch.md)
### 4.5 实验总结 ### 4.5 实验总结
我们分别使用PP-OCRv3中英文超轻量预训练模型在车牌数据集上进行了直接评估和 fine-tune 和 fine-tune +量化3种方案的实验,并基于[PaddleOCR lite教程](https://github.com/PaddlePaddle/PaddleOCR/blob/dygraph/deploy/lite/readme_ch.md)进行了速度测试,指标对比如下: 我们分别使用PP-OCRv3中英文超轻量预训练模型在车牌数据集上进行了直接评估和 fine-tune 和 fine-tune +量化3种方案的实验,并基于[PaddleOCR lite教程](../deploy/lite/readme_ch.md)进行了速度测试,指标对比如下:
- 检测 - 检测
......
...@@ -83,7 +83,7 @@ void CRNNRecognizer::Run(std::vector<cv::Mat> img_list, ...@@ -83,7 +83,7 @@ void CRNNRecognizer::Run(std::vector<cv::Mat> img_list,
int out_num = std::accumulate(predict_shape.begin(), predict_shape.end(), 1, int out_num = std::accumulate(predict_shape.begin(), predict_shape.end(), 1,
std::multiplies<int>()); std::multiplies<int>());
predict_batch.resize(out_num); predict_batch.resize(out_num);
// predict_batch is the result of Last FC with softmax
output_t->CopyToCpu(predict_batch.data()); output_t->CopyToCpu(predict_batch.data());
auto inference_end = std::chrono::steady_clock::now(); auto inference_end = std::chrono::steady_clock::now();
inference_diff += inference_end - inference_start; inference_diff += inference_end - inference_start;
...@@ -98,9 +98,11 @@ void CRNNRecognizer::Run(std::vector<cv::Mat> img_list, ...@@ -98,9 +98,11 @@ void CRNNRecognizer::Run(std::vector<cv::Mat> img_list,
float max_value = 0.0f; float max_value = 0.0f;
for (int n = 0; n < predict_shape[1]; n++) { for (int n = 0; n < predict_shape[1]; n++) {
// get idx
argmax_idx = int(Utility::argmax( argmax_idx = int(Utility::argmax(
&predict_batch[(m * predict_shape[1] + n) * predict_shape[2]], &predict_batch[(m * predict_shape[1] + n) * predict_shape[2]],
&predict_batch[(m * predict_shape[1] + n + 1) * predict_shape[2]])); &predict_batch[(m * predict_shape[1] + n + 1) * predict_shape[2]]));
// get score
max_value = float(*std::max_element( max_value = float(*std::max_element(
&predict_batch[(m * predict_shape[1] + n) * predict_shape[2]], &predict_batch[(m * predict_shape[1] + n) * predict_shape[2]],
&predict_batch[(m * predict_shape[1] + n + 1) * predict_shape[2]])); &predict_batch[(m * predict_shape[1] + n + 1) * predict_shape[2]]));
......
...@@ -136,7 +136,7 @@ The recognition model is the same. ...@@ -136,7 +136,7 @@ The recognition model is the same.
2. Run the following command to start the service. 2. Run the following command to start the service.
``` ```
# Start the service and save the running log in log.txt # Start the service and save the running log in log.txt
python3 web_service.py &>log.txt & python3 web_service.py --config=config.yml &>log.txt &
``` ```
After the service is successfully started, a log similar to the following will be printed in log.txt After the service is successfully started, a log similar to the following will be printed in log.txt
![](./imgs/start_server.png) ![](./imgs/start_server.png)
...@@ -217,7 +217,7 @@ The C++ service deployment is the same as python in the environment setup and da ...@@ -217,7 +217,7 @@ The C++ service deployment is the same as python in the environment setup and da
2. Run the following command to start the service. 2. Run the following command to start the service.
``` ```
# Start the service and save the running log in log.txt # Start the service and save the running log in log.txt
python3 -m paddle_serving_server.serve --model ppocr_det_v3_serving ppocr_rec_v3_serving --op GeneralDetectionOp GeneralInferOp --port 9293 &>log.txt & python3 -m paddle_serving_server.serve --model ppocr_det_v3_serving ppocr_rec_v3_serving --op GeneralDetectionOp GeneralInferOp --port 8181 &>log.txt &
``` ```
After the service is successfully started, a log similar to the following will be printed in log.txt After the service is successfully started, a log similar to the following will be printed in log.txt
![](./imgs/start_server.png) ![](./imgs/start_server.png)
......
...@@ -135,7 +135,7 @@ python3 -m paddle_serving_client.convert --dirname ./ch_PP-OCRv3_rec_infer/ \ ...@@ -135,7 +135,7 @@ python3 -m paddle_serving_client.convert --dirname ./ch_PP-OCRv3_rec_infer/ \
2. 启动服务可运行如下命令: 2. 启动服务可运行如下命令:
``` ```
# 启动服务,运行日志保存在log.txt # 启动服务,运行日志保存在log.txt
python3 web_service.py &>log.txt & python3 web_service.py --config=config.yml &>log.txt &
``` ```
成功启动服务后,log.txt中会打印类似如下日志 成功启动服务后,log.txt中会打印类似如下日志
![](./imgs/start_server.png) ![](./imgs/start_server.png)
...@@ -230,7 +230,7 @@ cp -rf general_detection_op.cpp Serving/core/general-server/op ...@@ -230,7 +230,7 @@ cp -rf general_detection_op.cpp Serving/core/general-server/op
``` ```
# 启动服务,运行日志保存在log.txt # 启动服务,运行日志保存在log.txt
python3 -m paddle_serving_server.serve --model ppocr_det_v3_serving ppocr_rec_v3_serving --op GeneralDetectionOp GeneralInferOp --port 9293 &>log.txt & python3 -m paddle_serving_server.serve --model ppocr_det_v3_serving ppocr_rec_v3_serving --op GeneralDetectionOp GeneralInferOp --port 8181 &>log.txt &
``` ```
成功启动服务后,log.txt中会打印类似如下日志 成功启动服务后,log.txt中会打印类似如下日志
![](./imgs/start_server.png) ![](./imgs/start_server.png)
......
...@@ -22,15 +22,16 @@ import cv2 ...@@ -22,15 +22,16 @@ import cv2
from paddle_serving_app.reader import Sequential, URL2Image, ResizeByFactor from paddle_serving_app.reader import Sequential, URL2Image, ResizeByFactor
from paddle_serving_app.reader import Div, Normalize, Transpose from paddle_serving_app.reader import Div, Normalize, Transpose
from ocr_reader import OCRReader from ocr_reader import OCRReader
import codecs
client = Client() client = Client()
# TODO:load_client need to load more than one client model. # TODO:load_client need to load more than one client model.
# this need to figure out some details. # this need to figure out some details.
client.load_client_config(sys.argv[1:]) client.load_client_config(sys.argv[1:])
client.connect(["127.0.0.1:9293"]) client.connect(["127.0.0.1:8181"])
import paddle import paddle
test_img_dir = "../../doc/imgs/" test_img_dir = "../../doc/imgs/1.jpg"
ocr_reader = OCRReader(char_dict_path="../../ppocr/utils/ppocr_keys_v1.txt") ocr_reader = OCRReader(char_dict_path="../../ppocr/utils/ppocr_keys_v1.txt")
...@@ -40,14 +41,43 @@ def cv2_to_base64(image): ...@@ -40,14 +41,43 @@ def cv2_to_base64(image):
'utf8') #data.tostring()).decode('utf8') 'utf8') #data.tostring()).decode('utf8')
for img_file in os.listdir(test_img_dir): def _check_image_file(path):
with open(os.path.join(test_img_dir, img_file), 'rb') as file: img_end = {'jpg', 'bmp', 'png', 'jpeg', 'rgb', 'tif', 'tiff', 'gif'}
return any([path.lower().endswith(e) for e in img_end])
test_img_list = []
if os.path.isfile(test_img_dir) and _check_image_file(test_img_dir):
test_img_list.append(test_img_dir)
elif os.path.isdir(test_img_dir):
for single_file in os.listdir(test_img_dir):
file_path = os.path.join(test_img_dir, single_file)
if os.path.isfile(file_path) and _check_image_file(file_path):
test_img_list.append(file_path)
if len(test_img_list) == 0:
raise Exception("not found any img file in {}".format(test_img_dir))
for img_file in test_img_list:
with open(img_file, 'rb') as file:
image_data = file.read() image_data = file.read()
image = cv2_to_base64(image_data) image = cv2_to_base64(image_data)
res_list = [] res_list = []
fetch_map = client.predict(feed={"x": image}, fetch=[], batch=True) fetch_map = client.predict(feed={"x": image}, fetch=[], batch=True)
one_batch_res = ocr_reader.postprocess(fetch_map, with_score=True) if fetch_map is None:
for res in one_batch_res: print('no results')
res_list.append(res[0]) else:
res = {"res": str(res_list)} if "text" in fetch_map:
print(res) for x in fetch_map["text"]:
x = codecs.encode(x)
words = base64.b64decode(x).decode('utf-8')
res_list.append(words)
else:
try:
one_batch_res = ocr_reader.postprocess(
fetch_map, with_score=True)
for res in one_batch_res:
res_list.append(res[0])
except:
print('no results')
res = {"res": str(res_list)}
print(res)
...@@ -339,7 +339,7 @@ class CharacterOps(object): ...@@ -339,7 +339,7 @@ class CharacterOps(object):
class OCRReader(object): class OCRReader(object):
def __init__(self, def __init__(self,
algorithm="CRNN", algorithm="CRNN",
image_shape=[3, 32, 320], image_shape=[3, 48, 320],
char_type="ch", char_type="ch",
batch_num=1, batch_num=1,
char_dict_path="./ppocr_keys_v1.txt"): char_dict_path="./ppocr_keys_v1.txt"):
...@@ -356,7 +356,7 @@ class OCRReader(object): ...@@ -356,7 +356,7 @@ class OCRReader(object):
def resize_norm_img(self, img, max_wh_ratio): def resize_norm_img(self, img, max_wh_ratio):
imgC, imgH, imgW = self.rec_image_shape imgC, imgH, imgW = self.rec_image_shape
if self.character_type == "ch": if self.character_type == "ch":
imgW = int(32 * max_wh_ratio) imgW = int(imgH * max_wh_ratio)
h = img.shape[0] h = img.shape[0]
w = img.shape[1] w = img.shape[1]
ratio = w / float(h) ratio = w / float(h)
...@@ -377,7 +377,7 @@ class OCRReader(object): ...@@ -377,7 +377,7 @@ class OCRReader(object):
def preprocess(self, img_list): def preprocess(self, img_list):
img_num = len(img_list) img_num = len(img_list)
norm_img_batch = [] norm_img_batch = []
max_wh_ratio = 0 max_wh_ratio = 320/48.
for ino in range(img_num): for ino in range(img_num):
h, w = img_list[ino].shape[0:2] h, w = img_list[ino].shape[0:2]
wh_ratio = w * 1.0 / h wh_ratio = w * 1.0 / h
......
...@@ -36,11 +36,27 @@ def cv2_to_base64(image): ...@@ -36,11 +36,27 @@ def cv2_to_base64(image):
return base64.b64encode(image).decode('utf8') return base64.b64encode(image).decode('utf8')
def _check_image_file(path):
img_end = {'jpg', 'bmp', 'png', 'jpeg', 'rgb', 'tif', 'tiff', 'gif'}
return any([path.lower().endswith(e) for e in img_end])
url = "http://127.0.0.1:9998/ocr/prediction" url = "http://127.0.0.1:9998/ocr/prediction"
test_img_dir = args.image_dir test_img_dir = args.image_dir
for idx, img_file in enumerate(os.listdir(test_img_dir)): test_img_list = []
with open(os.path.join(test_img_dir, img_file), 'rb') as file: if os.path.isfile(test_img_dir) and _check_image_file(test_img_dir):
test_img_list.append(test_img_dir)
elif os.path.isdir(test_img_dir):
for single_file in os.listdir(test_img_dir):
file_path = os.path.join(test_img_dir, single_file)
if os.path.isfile(file_path) and _check_image_file(file_path):
test_img_list.append(file_path)
if len(test_img_list) == 0:
raise Exception("not found any img file in {}".format(test_img_dir))
for idx, img_file in enumerate(test_img_list):
with open(img_file, 'rb') as file:
image_data1 = file.read() image_data1 = file.read()
# print file name # print file name
print('{}{}{}'.format('*' * 10, img_file, '*' * 10)) print('{}{}{}'.format('*' * 10, img_file, '*' * 10))
...@@ -70,4 +86,4 @@ for idx, img_file in enumerate(os.listdir(test_img_dir)): ...@@ -70,4 +86,4 @@ for idx, img_file in enumerate(os.listdir(test_img_dir)):
print( print(
"For details about error message, see PipelineServingLogs/pipeline.log" "For details about error message, see PipelineServingLogs/pipeline.log"
) )
print("==> total number of test imgs: ", len(os.listdir(test_img_dir))) print("==> total number of test imgs: ", len(test_img_list))
feed_var {
name: "x"
alias_name: "x"
is_lod_tensor: false
feed_type: 20
shape: 1
}
fetch_var {
name: "save_infer_model/scale_0.tmp_1"
alias_name: "save_infer_model/scale_0.tmp_1"
is_lod_tensor: false
fetch_type: 1
shape: 1
shape: 640
shape: 640
}
...@@ -19,7 +19,7 @@ import copy ...@@ -19,7 +19,7 @@ import copy
import cv2 import cv2
import base64 import base64
# from paddle_serving_app.reader import OCRReader # from paddle_serving_app.reader import OCRReader
from ocr_reader import OCRReader, DetResizeForTest from ocr_reader import OCRReader, DetResizeForTest, ArgsParser
from paddle_serving_app.reader import Sequential, ResizeByFactor from paddle_serving_app.reader import Sequential, ResizeByFactor
from paddle_serving_app.reader import Div, Normalize, Transpose from paddle_serving_app.reader import Div, Normalize, Transpose
from paddle_serving_app.reader import DBPostProcess, FilterBoxes, GetRotateCropImage, SortedBoxes from paddle_serving_app.reader import DBPostProcess, FilterBoxes, GetRotateCropImage, SortedBoxes
...@@ -63,7 +63,6 @@ class DetOp(Op): ...@@ -63,7 +63,6 @@ class DetOp(Op):
dt_boxes_list = self.post_func(det_out, [ratio_list]) dt_boxes_list = self.post_func(det_out, [ratio_list])
dt_boxes = self.filter_func(dt_boxes_list[0], [self.ori_h, self.ori_w]) dt_boxes = self.filter_func(dt_boxes_list[0], [self.ori_h, self.ori_w])
out_dict = {"dt_boxes": dt_boxes, "image": self.raw_im} out_dict = {"dt_boxes": dt_boxes, "image": self.raw_im}
return out_dict, None, "" return out_dict, None, ""
...@@ -86,7 +85,7 @@ class RecOp(Op): ...@@ -86,7 +85,7 @@ class RecOp(Op):
dt_boxes = copy.deepcopy(self.dt_list) dt_boxes = copy.deepcopy(self.dt_list)
feed_list = [] feed_list = []
img_list = [] img_list = []
max_wh_ratio = 0 max_wh_ratio = 320 / 48.
## Many mini-batchs, the type of feed_data is list. ## Many mini-batchs, the type of feed_data is list.
max_batch_size = 6 # len(dt_boxes) max_batch_size = 6 # len(dt_boxes)
...@@ -150,7 +149,8 @@ class RecOp(Op): ...@@ -150,7 +149,8 @@ class RecOp(Op):
for i in range(dt_num): for i in range(dt_num):
text = rec_list[i] text = rec_list[i]
dt_box = self.dt_list[i] dt_box = self.dt_list[i]
result_list.append([text, dt_box.tolist()]) if text[1] >= 0.5:
result_list.append([text, dt_box.tolist()])
res = {"result": str(result_list)} res = {"result": str(result_list)}
return res, None, "" return res, None, ""
...@@ -163,5 +163,6 @@ class OcrService(WebService): ...@@ -163,5 +163,6 @@ class OcrService(WebService):
uci_service = OcrService(name="ocr") uci_service = OcrService(name="ocr")
uci_service.prepare_pipeline_config("config.yml") FLAGS = ArgsParser().parse_args()
uci_service.prepare_pipeline_config(yml_dict=FLAGS.conf_dict)
uci_service.run_service() uci_service.run_service()
...@@ -720,6 +720,13 @@ C++TensorRT预测需要使用支持TRT的预测库并在编译时打开[-DWITH_T ...@@ -720,6 +720,13 @@ C++TensorRT预测需要使用支持TRT的预测库并在编译时打开[-DWITH_T
注:建议使用TensorRT大于等于6.1.0.5以上的版本。 注:建议使用TensorRT大于等于6.1.0.5以上的版本。
#### Q: 为什么识别模型做预测的时候,预测图片的数量数量还会影响预测的精度
**A**: 推理时识别模型默认的batch_size=6, 如预测图片长度变化大,可能影响预测效果。如果出现上述问题可在推理的时候设置识别bs=1,命令如下:
```
python3 tools/infer/predict_rec.py --image_dir="./doc/imgs_words/ch/word_4.jpg" --rec_model_dir="./ch_PP-OCRv3_rec_infer/" --rec_batch_num=1
```
<a name="213"></a> <a name="213"></a>
### 2.13 推理部署 ### 2.13 推理部署
......
...@@ -15,8 +15,8 @@ ...@@ -15,8 +15,8 @@
- **数据简介**:publaynet数据集的训练集合中包含35万张图像,验证集合中包含1.1万张图像。总共包含5个类别,分别是: `text, title, list, table, figure`。部分图像以及标注框可视化如下所示。 - **数据简介**:publaynet数据集的训练集合中包含35万张图像,验证集合中包含1.1万张图像。总共包含5个类别,分别是: `text, title, list, table, figure`。部分图像以及标注框可视化如下所示。
<div align="center"> <div align="center">
<img src="../datasets/publaynet_demo/gt_PMC3724501_00006.jpg" width="500"> <img src="../../datasets/publaynet_demo/gt_PMC3724501_00006.jpg" width="500">
<img src="../datasets/publaynet_demo/gt_PMC5086060_00002.jpg" width="500"> <img src="../../datasets/publaynet_demo/gt_PMC5086060_00002.jpg" width="500">
</div> </div>
- **下载地址**:https://developer.ibm.com/exchanges/data/all/publaynet/ - **下载地址**:https://developer.ibm.com/exchanges/data/all/publaynet/
...@@ -30,8 +30,8 @@ ...@@ -30,8 +30,8 @@
- **数据简介**:CDLA据集的训练集合中包含5000张图像,验证集合中包含1000张图像。总共包含10个类别,分别是: `Text, Title, Figure, Figure caption, Table, Table caption, Header, Footer, Reference, Equation`。部分图像以及标注框可视化如下所示。 - **数据简介**:CDLA据集的训练集合中包含5000张图像,验证集合中包含1000张图像。总共包含10个类别,分别是: `Text, Title, Figure, Figure caption, Table, Table caption, Header, Footer, Reference, Equation`。部分图像以及标注框可视化如下所示。
<div align="center"> <div align="center">
<img src="../datasets/CDLA_demo/val_0633.jpg" width="500"> <img src="../../datasets/CDLA_demo/val_0633.jpg" width="500">
<img src="../datasets/CDLA_demo/val_0941.jpg" width="500"> <img src="../../datasets/CDLA_demo/val_0941.jpg" width="500">
</div> </div>
- **下载地址**:https://github.com/buptlihang/CDLA - **下载地址**:https://github.com/buptlihang/CDLA
...@@ -45,8 +45,8 @@ ...@@ -45,8 +45,8 @@
- **数据简介**:TableBank数据集包含Latex(训练集187199张,验证集7265张,测试集5719张)与Word(训练集73383张,验证集2735张,测试集2281张)两种类别的文档。仅包含`Table` 1个类别。部分图像以及标注框可视化如下所示。 - **数据简介**:TableBank数据集包含Latex(训练集187199张,验证集7265张,测试集5719张)与Word(训练集73383张,验证集2735张,测试集2281张)两种类别的文档。仅包含`Table` 1个类别。部分图像以及标注框可视化如下所示。
<div align="center"> <div align="center">
<img src="../datasets/tablebank_demo/004.png" height="700"> <img src="../../datasets/tablebank_demo/004.png" height="700">
<img src="../datasets/tablebank_demo/005.png" height="700"> <img src="../../datasets/tablebank_demo/005.png" height="700">
</div> </div>
- **下载地址**:https://doc-analysis.github.io/tablebank-page/index.html - **下载地址**:https://doc-analysis.github.io/tablebank-page/index.html
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
- [2.5 分布式训练](#25-分布式训练) - [2.5 分布式训练](#25-分布式训练)
- [2.6 知识蒸馏训练](#26-知识蒸馏训练) - [2.6 知识蒸馏训练](#26-知识蒸馏训练)
- [2.7 其他训练环境](#27-其他训练环境) - [2.7 其他训练环境](#27-其他训练环境)
- [2.8 模型微调](#28-模型微调)
- [3. 模型评估与预测](#3-模型评估与预测) - [3. 模型评估与预测](#3-模型评估与预测)
- [3.1 指标评估](#31-指标评估) - [3.1 指标评估](#31-指标评估)
- [3.2 测试检测效果](#32-测试检测效果) - [3.2 测试检测效果](#32-测试检测效果)
...@@ -141,7 +142,8 @@ python3 tools/train.py -c configs/det/det_mv3_db.yml \ ...@@ -141,7 +142,8 @@ python3 tools/train.py -c configs/det/det_mv3_db.yml \
Global.use_amp=True Global.scale_loss=1024.0 Global.use_dynamic_loss_scaling=True Global.use_amp=True Global.scale_loss=1024.0 Global.use_dynamic_loss_scaling=True
``` ```
<a name="26---fleet---"></a> <a name="25---fleet---"></a>
## 2.5 分布式训练 ## 2.5 分布式训练
多机多卡训练时,通过 `--ips` 参数设置使用的机器IP地址,通过 `--gpus` 参数设置使用的GPU ID: 多机多卡训练时,通过 `--ips` 参数设置使用的机器IP地址,通过 `--gpus` 参数设置使用的GPU ID:
...@@ -151,7 +153,7 @@ python3 -m paddle.distributed.launch --ips="xx.xx.xx.xx,xx.xx.xx.xx" --gpus '0,1 ...@@ -151,7 +153,7 @@ python3 -m paddle.distributed.launch --ips="xx.xx.xx.xx,xx.xx.xx.xx" --gpus '0,1
-o Global.pretrained_model=./pretrain_models/MobileNetV3_large_x0_5_pretrained -o Global.pretrained_model=./pretrain_models/MobileNetV3_large_x0_5_pretrained
``` ```
**注意:** 采用多机多卡训练时,需要替换上面命令中的ips值为您机器的地址,机器之间需要能够相互ping通。另外,训练时需要在多个机器上分别启动命令。查看机器ip地址的命令为`ifconfig` **注意:** (1)采用多机多卡训练时,需要替换上面命令中的ips值为您机器的地址,机器之间需要能够相互ping通;(2)训练时需要在多个机器上分别启动命令。查看机器ip地址的命令为`ifconfig`;(3)更多关于分布式训练的性能优势等信息,请参考:[分布式训练教程](./distributed_training.md)
<a name="26---distill---"></a> <a name="26---distill---"></a>
...@@ -177,6 +179,13 @@ Windows平台只支持`单卡`的训练与预测,指定GPU进行训练`set CUD ...@@ -177,6 +179,13 @@ Windows平台只支持`单卡`的训练与预测,指定GPU进行训练`set CUD
- Linux DCU - Linux DCU
DCU设备上运行需要设置环境变量 `export HIP_VISIBLE_DEVICES=0,1,2,3`,其余训练评估预测命令与Linux GPU完全相同。 DCU设备上运行需要设置环境变量 `export HIP_VISIBLE_DEVICES=0,1,2,3`,其余训练评估预测命令与Linux GPU完全相同。
<a name="28-模型微调"></a>
## 2.8 模型微调
实际使用过程中,建议加载官方提供的预训练模型,在自己的数据集中进行微调,关于检测模型的微调方法,请参考:[模型微调教程](./finetune.md)。
<a name="3--------"></a> <a name="3--------"></a>
# 3. 模型评估与预测 # 3. 模型评估与预测
...@@ -196,6 +205,7 @@ python3 tools/eval.py -c configs/det/det_mv3_db.yml -o Global.checkpoints="{pat ...@@ -196,6 +205,7 @@ python3 tools/eval.py -c configs/det/det_mv3_db.yml -o Global.checkpoints="{pat
## 3.2 测试检测效果 ## 3.2 测试检测效果
测试单张图像的检测效果: 测试单张图像的检测效果:
```shell ```shell
python3 tools/infer_det.py -c configs/det/det_mv3_db.yml -o Global.infer_img="./doc/imgs_en/img_10.jpg" Global.pretrained_model="./output/det_db/best_accuracy" python3 tools/infer_det.py -c configs/det/det_mv3_db.yml -o Global.infer_img="./doc/imgs_en/img_10.jpg" Global.pretrained_model="./output/det_db/best_accuracy"
``` ```
...@@ -226,14 +236,19 @@ python3 tools/export_model.py -c configs/det/det_mv3_db.yml -o Global.pretrained ...@@ -226,14 +236,19 @@ python3 tools/export_model.py -c configs/det/det_mv3_db.yml -o Global.pretrained
``` ```
DB检测模型inference 模型预测: DB检测模型inference 模型预测:
```shell ```shell
python3 tools/infer/predict_det.py --det_algorithm="DB" --det_model_dir="./output/det_db_inference/" --image_dir="./doc/imgs/" --use_gpu=True python3 tools/infer/predict_det.py --det_algorithm="DB" --det_model_dir="./output/det_db_inference/" --image_dir="./doc/imgs/" --use_gpu=True
``` ```
如果是其他检测,比如EAST模型,det_algorithm参数需要修改为EAST,默认为DB算法: 如果是其他检测,比如EAST模型,det_algorithm参数需要修改为EAST,默认为DB算法:
```shell ```shell
python3 tools/infer/predict_det.py --det_algorithm="EAST" --det_model_dir="./output/det_db_inference/" --image_dir="./doc/imgs/" --use_gpu=True python3 tools/infer/predict_det.py --det_algorithm="EAST" --det_model_dir="./output/det_db_inference/" --image_dir="./doc/imgs/" --use_gpu=True
``` ```
更多关于推理超参数的配置与解释,请参考:[模型推理超参数解释教程](./inference_args.md)。
<a name="5-faq"></a> <a name="5-faq"></a>
# 5. FAQ # 5. FAQ
......
...@@ -41,11 +41,16 @@ python3 -m paddle.distributed.launch \ ...@@ -41,11 +41,16 @@ python3 -m paddle.distributed.launch \
## 性能效果测试 ## 性能效果测试
* 基于单机8卡P40,和2机8卡P40,在26W公开识别数据集(LSVT, RCTW, MTWI)上进行训练,最终耗时如下。 * 在2机8卡P40的机器上,基于26W公开识别数据集(LSVT, RCTW, MTWI)上进行训练,最终耗时如下。
| 模型 | 配置文件 | 机器数量 | 每台机器的GPU数量 | 训练时间 | 识别Acc | 加速比 | | 模型 | 配置 | 精度 | 单机8卡耗时 | 2机8卡耗时 | 加速比 |
| :----------------------: | :------------: | :------------: | :---------------: | :----------: | :-----------: | :-----------: | |------|-----|--------|--------|--------|-----|
| CRNN | configs/rec/ch_ppocr_v2.0/rec_chinese_lite_train_v2.0.yml | 1 | 8 | 60h | 66.7% | - | | CRNN | [rec_chinese_lite_train_v2.0.yml](../../configs/rec/ch_ppocr_v2.0/rec_chinese_lite_train_v2.0.yml) | 67.0% | 2.50d | 1.67d | **1.5** |
| CRNN | configs/rec/ch_ppocr_v2.0/rec_chinese_lite_train_v2.0.yml | 2 | 8 | 40h | 67.0% | 150% |
可以看出,精度没有下降的情况下,训练时间由60h缩短为了40h,加速比可以达到60h/40h=150%,效率为60h/(40h*2)=75%。
* 在4机8卡V100的机器上,基于全量数据训练,最终耗时如下
| 模型 | 配置 | 精度 | 单机8卡耗时 | 4机8卡耗时 | 加速比 |
|------|-----|--------|--------|--------|-----|
| SVTR | [ch_PP-OCRv3_rec_distillation.yml](../../configs/rec/PP-OCRv3/ch_PP-OCRv3_rec_distillation.yml) | 74.0% | 10d | 2.84d | **3.5** |
# PaddleOCR模型推理参数解释
在使用PaddleOCR进行模型推理时,可以自定义修改参数,来修改模型、数据、预处理、后处理等内容(参数文件:[utility.py](../../tools/infer/utility.py)),详细的参数解释如下所示。
* 全局信息
| 参数名称 | 类型 | 默认值 | 含义 |
| :--: | :--: | :--: | :--: |
| image_dir | str | 无,必须显式指定 | 图像或者文件夹路径 |
| vis_font_path | str | "./doc/fonts/simfang.ttf" | 用于可视化的字体路径 |
| drop_score | float | 0.5 | 识别得分小于该值的结果会被丢弃,不会作为返回结果 |
| use_pdserving | bool | False | 是否使用Paddle Serving进行预测 |
| warmup | bool | False | 是否开启warmup,在统计预测耗时的时候,可以使用这种方法 |
| draw_img_save_dir | str | "./inference_results" | 系统串联预测OCR结果的保存文件夹 |
| save_crop_res | bool | False | 是否保存OCR的识别文本图像 |
| crop_res_save_dir | str | "./output" | 保存OCR识别出来的文本图像路径 |
| use_mp | bool | False | 是否开启多进程预测 |
| total_process_num | int | 6 | 开启的进城数,`use_mp``True`时生效 |
| process_id | int | 0 | 当前进程的id号,无需自己修改 |
| benchmark | bool | False | 是否开启benchmark,对预测速度、显存占用等进行统计 |
| save_log_path | str | "./log_output/" | 开启`benchmark`时,日志结果的保存文件夹 |
| show_log | bool | True | 是否显示预测中的日志信息 |
| use_onnx | bool | False | 是否开启onnx预测 |
* 预测引擎相关
| 参数名称 | 类型 | 默认值 | 含义 |
| :--: | :--: | :--: | :--: |
| use_gpu | bool | True | 是否使用GPU进行预测 |
| ir_optim | bool | True | 是否对计算图进行分析与优化,开启后可以加速预测过程 |
| use_tensorrt | bool | False | 是否开启tensorrt |
| min_subgraph_size | int | 15 | tensorrt中最小子图size,当子图的size大于该值时,才会尝试对该子图使用trt engine计算 |
| precision | str | fp32 | 预测的精度,支持`fp32`, `fp16`, `int8` 3种输入 |
| enable_mkldnn | bool | True | 是否开启mkldnn |
| cpu_threads | int | 10 | 开启mkldnn时,cpu预测的线程数 |
* 文本检测模型相关
| 参数名称 | 类型 | 默认值 | 含义 |
| :--: | :--: | :--: | :--: |
| det_algorithm | str | "DB" | 文本检测算法名称,目前支持`DB`, `EAST`, `SAST`, `PSE` |
| det_model_dir | str | xx | 检测inference模型路径 |
| det_limit_side_len | int | 960 | 检测的图像边长限制 |
| det_limit_type | str | "max" | 检测的变成限制类型,目前支持`min`, `max``min`表示保证图像最短边不小于`det_limit_side_len``max`表示保证图像最长边不大于`det_limit_side_len` |
其中,DB算法相关参数如下
| 参数名称 | 类型 | 默认值 | 含义 |
| :--: | :--: | :--: | :--: |
| det_db_thresh | float | 0.3 | DB输出的概率图中,得分大于该阈值的像素点才会被认为是文字像素点 |
| det_db_box_thresh | float | 0.6 | 检测结果边框内,所有像素点的平均得分大于该阈值时,该结果会被认为是文字区域 |
| det_db_unclip_ratio | float | 1.5 | `Vatti clipping`算法的扩张系数,使用该方法对文字区域进行扩张 |
| max_batch_size | int | 10 | 预测的batch size |
| use_dilation | bool | False | 是否对分割结果进行膨胀以获取更优检测效果 |
| det_db_score_mode | str | "fast" | DB的检测结果得分计算方法,支持`fast``slow``fast`是根据polygon的外接矩形边框内的所有像素计算平均得分,`slow`是根据原始polygon内的所有像素计算平均得分,计算速度相对较慢一些,但是更加准确一些。 |
EAST算法相关参数如下
| 参数名称 | 类型 | 默认值 | 含义 |
| :--: | :--: | :--: | :--: |
| det_east_score_thresh | float | 0.8 | EAST后处理中score map的阈值 |
| det_east_cover_thresh | float | 0.1 | EAST后处理中文本框的平均得分阈值 |
| det_east_nms_thresh | float | 0.2 | EAST后处理中nms的阈值 |
SAST算法相关参数如下
| 参数名称 | 类型 | 默认值 | 含义 |
| :--: | :--: | :--: | :--: |
| det_sast_score_thresh | float | 0.5 | SAST后处理中的得分阈值 |
| det_sast_nms_thresh | float | 0.5 | SAST后处理中nms的阈值 |
| det_sast_polygon | bool | False | 是否多边形检测,弯曲文本场景(如Total-Text)设置为True |
PSE算法相关参数如下
| 参数名称 | 类型 | 默认值 | 含义 |
| :--: | :--: | :--: | :--: |
| det_pse_thresh | float | 0.0 | 对输出图做二值化的阈值 |
| det_pse_box_thresh | float | 0.85 | 对box进行过滤的阈值,低于此阈值的丢弃 |
| det_pse_min_area | float | 16 | box的最小面积,低于此阈值的丢弃 |
| det_pse_box_type | str | "box" | 返回框的类型,box:四点坐标,poly: 弯曲文本的所有点坐标 |
| det_pse_scale | int | 1 | 输入图像相对于进后处理的图的比例,如`640*640`的图像,网络输出为`160*160`,scale为2的情况下,进后处理的图片shape为`320*320`。这个值调大可以加快后处理速度,但是会带来精度的下降 |
* 文本识别模型相关
| 参数名称 | 类型 | 默认值 | 含义 |
| :--: | :--: | :--: | :--: |
| rec_algorithm | str | "CRNN" | 文本识别算法名称,目前支持`CRNN`, `SRN`, `RARE`, `NETR`, `SAR` |
| rec_model_dir | str | 无,如果使用识别模型,该项是必填项 | 识别inference模型路径 |
| rec_image_shape | list | [3, 32, 320] | 识别时的图像尺寸, |
| rec_batch_num | int | 6 | 识别的batch size |
| max_text_length | int | 25 | 识别结果最大长度,在`SRN`中有效 |
| rec_char_dict_path | str | "./ppocr/utils/ppocr_keys_v1.txt" | 识别的字符字典文件 |
| use_space_char | bool | True | 是否包含空格,如果为`True`,则会在最后字符字典中补充`空格`字符 |
* 端到端文本检测与识别模型相关
| 参数名称 | 类型 | 默认值 | 含义 |
| :--: | :--: | :--: | :--: |
| e2e_algorithm | str | "PGNet" | 端到端算法名称,目前支持`PGNet` |
| e2e_model_dir | str | 无,如果使用端到端模型,该项是必填项 | 端到端模型inference模型路径 |
| e2e_limit_side_len | int | 768 | 端到端的输入图像边长限制 |
| e2e_limit_type | str | "max" | 端到端的边长限制类型,目前支持`min`, `max``min`表示保证图像最短边不小于`e2e_limit_side_len``max`表示保证图像最长边不大于`e2e_limit_side_len` |
| e2e_pgnet_score_thresh | float | 0.5 | 端到端得分阈值,小于该阈值的结果会被丢弃 |
| e2e_char_dict_path | str | "./ppocr/utils/ic15_dict.txt" | 识别的字典文件路径 |
| e2e_pgnet_valid_set | str | "totaltext" | 验证集名称,目前支持`totaltext`, `partvgg`,不同数据集对应的后处理方式不同,与训练过程保持一致即可 |
| e2e_pgnet_mode | str | "fast" | PGNet的检测结果得分计算方法,支持`fast``slow``fast`是根据polygon的外接矩形边框内的所有像素计算平均得分,`slow`是根据原始polygon内的所有像素计算平均得分,计算速度相对较慢一些,但是更加准确一些。 |
* 方向分类器模型相关
| 参数名称 | 类型 | 默认值 | 含义 |
| :--: | :--: | :--: | :--: |
| use_angle_cls | bool | False | 是否使用方向分类器 |
| cls_model_dir | str | 无,如果需要使用,则必须显式指定路径 | 方向分类器inference模型路径 |
| cls_image_shape | list | [3, 48, 192] | 预测尺度 |
| label_list | list | ['0', '180'] | class id对应的角度值 |
| cls_batch_num | int | 6 | 方向分类器预测的batch size |
| cls_thresh | float | 0.9 | 预测阈值,模型预测结果为180度,且得分大于该阈值时,认为最终预测结果为180度,需要翻转 |
...@@ -30,11 +30,11 @@ PP-OCR系统pipeline如下: ...@@ -30,11 +30,11 @@ PP-OCR系统pipeline如下:
PP-OCR系统在持续迭代优化,目前已发布PP-OCR和PP-OCRv2两个版本: PP-OCR系统在持续迭代优化,目前已发布PP-OCR和PP-OCRv2两个版本:
PP-OCR从骨干网络选择和调整、预测头部的设计、数据增强、学习率变换策略、正则化参数选择、预训练模型使用以及模型自动裁剪量化8个方面,采用19个有效策略,对各个模块的模型进行效果调优和瘦身(如绿框所示),最终得到整体大小为3.5M的超轻量中英文OCR和2.8M的英文数字OCR。更多细节请参考PP-OCR技术方案 https://arxiv.org/abs/2009.09941 PP-OCR从骨干网络选择和调整、预测头部的设计、数据增强、学习率变换策略、正则化参数选择、预训练模型使用以及模型自动裁剪量化8个方面,采用19个有效策略,对各个模块的模型进行效果调优和瘦身(如绿框所示),最终得到整体大小为3.5M的超轻量中英文OCR和2.8M的英文数字OCR。更多细节请参考[PP-OCR技术报告](https://arxiv.org/abs/2009.09941)
#### PP-OCRv2 #### PP-OCRv2
PP-OCRv2在PP-OCR的基础上,进一步在5个方面重点优化,检测模型采用CML协同互学习知识蒸馏策略和CopyPaste数据增广策略;识别模型采用LCNet轻量级骨干网络、UDML 改进知识蒸馏策略和[Enhanced CTC loss](./enhanced_ctc_loss.md)损失函数改进(如上图红框所示),进一步在推理速度和预测效果上取得明显提升。更多细节请参考PP-OCRv2[技术报告](https://arxiv.org/abs/2109.03144) PP-OCRv2在PP-OCR的基础上,进一步在5个方面重点优化,检测模型采用CML协同互学习知识蒸馏策略和CopyPaste数据增广策略;识别模型采用LCNet轻量级骨干网络、UDML 改进知识蒸馏策略和[Enhanced CTC loss](./enhanced_ctc_loss.md)损失函数改进(如上图红框所示),进一步在推理速度和预测效果上取得明显提升。更多细节请参考[PP-OCRv2技术报告](https://arxiv.org/abs/2109.03144)
#### PP-OCRv3 #### PP-OCRv3
...@@ -48,7 +48,7 @@ PP-OCRv3系统pipeline如下: ...@@ -48,7 +48,7 @@ PP-OCRv3系统pipeline如下:
<img src="../ppocrv3_framework.png" width="800"> <img src="../ppocrv3_framework.png" width="800">
</div> </div>
更多细节请参考PP-OCRv3[技术报告](./PP-OCRv3_introduction.md) 更多细节请参考[PP-OCRv3技术报告](https://arxiv.org/abs/2206.03001v2) 👉[中文简洁版](./PP-OCRv3_introduction.md)
<a name="2"></a> <a name="2"></a>
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
- [2.6. 知识蒸馏训练](#26-知识蒸馏训练) - [2.6. 知识蒸馏训练](#26-知识蒸馏训练)
- [2.7. 多语言模型训练](#27-多语言模型训练) - [2.7. 多语言模型训练](#27-多语言模型训练)
- [2.8. 其他训练环境](#28-其他训练环境) - [2.8. 其他训练环境](#28-其他训练环境)
- [2.9. 模型微调](#29-模型微调)
- [3. 模型评估与预测](#3-模型评估与预测) - [3. 模型评估与预测](#3-模型评估与预测)
- [3.1. 指标评估](#31-指标评估) - [3.1. 指标评估](#31-指标评估)
- [3.2. 测试识别效果](#32-测试识别效果) - [3.2. 测试识别效果](#32-测试识别效果)
...@@ -217,6 +218,30 @@ python3 tools/train.py -c configs/rec/PP-OCRv3/en_PP-OCRv3_rec.yml -o Global.pre ...@@ -217,6 +218,30 @@ python3 tools/train.py -c configs/rec/PP-OCRv3/en_PP-OCRv3_rec.yml -o Global.pre
python3 -m paddle.distributed.launch --gpus '0,1,2,3' tools/train.py -c configs/rec/PP-OCRv3/en_PP-OCRv3_rec.yml -o Global.pretrained_model=./pretrain_models/en_PP-OCRv3_rec_train/best_accuracy python3 -m paddle.distributed.launch --gpus '0,1,2,3' tools/train.py -c configs/rec/PP-OCRv3/en_PP-OCRv3_rec.yml -o Global.pretrained_model=./pretrain_models/en_PP-OCRv3_rec_train/best_accuracy
``` ```
正常启动训练后,会看到以下log输出:
```
[2022/02/22 07:58:05] root INFO: epoch: [1/800], iter: 10, lr: 0.000000, loss: 0.754281, acc: 0.000000, norm_edit_dis: 0.000008, reader_cost: 0.55541 s, batch_cost: 0.91654 s, samples: 1408, ips: 153.62133
[2022/02/22 07:58:13] root INFO: epoch: [1/800], iter: 20, lr: 0.000001, loss: 0.924677, acc: 0.000000, norm_edit_dis: 0.000008, reader_cost: 0.00236 s, batch_cost: 0.28528 s, samples: 1280, ips: 448.68599
[2022/02/22 07:58:23] root INFO: epoch: [1/800], iter: 30, lr: 0.000002, loss: 0.967231, acc: 0.000000, norm_edit_dis: 0.000008, reader_cost: 0.14527 s, batch_cost: 0.42714 s, samples: 1280, ips: 299.66507
[2022/02/22 07:58:31] root INFO: epoch: [1/800], iter: 40, lr: 0.000003, loss: 0.895318, acc: 0.000000, norm_edit_dis: 0.000008, reader_cost: 0.00173 s, batch_cost: 0.27719 s, samples: 1280, ips: 461.77252
```
log 中自动打印如下信息:
| 字段 | 含义 |
| :----: | :------: |
| epoch | 当前迭代轮次 |
| iter | 当前迭代次数 |
| lr | 当前学习率 |
| loss | 当前损失函数 |
| acc | 当前batch的准确率 |
| norm_edit_dis | 当前 batch 的编辑距离 |
| reader_cost | 当前 batch 数据处理耗时 |
| batch_cost | 当前 batch 总耗时 |
| samples | 当前 batch 内的样本数 |
| ips | 每秒处理图片的数量 |
PaddleOCR支持训练和评估交替进行, 可以在 `configs/rec/PP-OCRv3/en_PP-OCRv3_rec.yml` 中修改 `eval_batch_step` 设置评估频率,默认每500个iter评估一次。评估过程中默认将最佳acc模型,保存为 `output/en_PP-OCRv3_rec/best_accuracy` PaddleOCR支持训练和评估交替进行, 可以在 `configs/rec/PP-OCRv3/en_PP-OCRv3_rec.yml` 中修改 `eval_batch_step` 设置评估频率,默认每500个iter评估一次。评估过程中默认将最佳acc模型,保存为 `output/en_PP-OCRv3_rec/best_accuracy`
...@@ -363,7 +388,7 @@ python3 -m paddle.distributed.launch --ips="xx.xx.xx.xx,xx.xx.xx.xx" --gpus '0,1 ...@@ -363,7 +388,7 @@ python3 -m paddle.distributed.launch --ips="xx.xx.xx.xx,xx.xx.xx.xx" --gpus '0,1
-o Global.pretrained_model=./pretrain_models/en_PP-OCRv3_rec_train/best_accuracy -o Global.pretrained_model=./pretrain_models/en_PP-OCRv3_rec_train/best_accuracy
``` ```
**注意:** 采用多机多卡训练时,需要替换上面命令中的ips值为您机器的地址,机器之间需要能够相互ping通。另外,训练时需要在多个机器上分别启动命令。查看机器ip地址的命令为`ifconfig` **注意:** (1)采用多机多卡训练时,需要替换上面命令中的ips值为您机器的地址,机器之间需要能够相互ping通;(2)训练时需要在多个机器上分别启动命令。查看机器ip地址的命令为`ifconfig`;(3)更多关于分布式训练的性能优势等信息,请参考:[分布式训练教程](./distributed_training.md)
## 2.6. 知识蒸馏训练 ## 2.6. 知识蒸馏训练
...@@ -438,6 +463,11 @@ Windows平台只支持`单卡`的训练与预测,指定GPU进行训练`set CUD ...@@ -438,6 +463,11 @@ Windows平台只支持`单卡`的训练与预测,指定GPU进行训练`set CUD
- Linux DCU - Linux DCU
DCU设备上运行需要设置环境变量 `export HIP_VISIBLE_DEVICES=0,1,2,3`,其余训练评估预测命令与Linux GPU完全相同。 DCU设备上运行需要设置环境变量 `export HIP_VISIBLE_DEVICES=0,1,2,3`,其余训练评估预测命令与Linux GPU完全相同。
## 2.9 模型微调
实际使用过程中,建议加载官方提供的预训练模型,在自己的数据集中进行微调,关于识别模型的微调方法,请参考:[模型微调教程](./finetune.md)。
# 3. 模型评估与预测 # 3. 模型评估与预测
## 3.1. 指标评估 ## 3.1. 指标评估
...@@ -540,12 +570,13 @@ inference/en_PP-OCRv3_rec/ ...@@ -540,12 +570,13 @@ inference/en_PP-OCRv3_rec/
- 自定义模型推理 - 自定义模型推理
如果训练时修改了文本的字典,在使用inference模型预测时,需要通过`--rec_char_dict_path`指定使用的字典路径 如果训练时修改了文本的字典,在使用inference模型预测时,需要通过`--rec_char_dict_path`指定使用的字典路径,更多关于推理超参数的配置与解释,请参考:[模型推理超参数解释教程](./inference_args.md)。
``` ```
python3 tools/infer/predict_rec.py --image_dir="./doc/imgs_words_en/word_336.png" --rec_model_dir="./your inference model" --rec_image_shape="3, 48, 320" --rec_char_dict_path="your text dict path" python3 tools/infer/predict_rec.py --image_dir="./doc/imgs_words_en/word_336.png" --rec_model_dir="./your inference model" --rec_image_shape="3, 48, 320" --rec_char_dict_path="your text dict path"
``` ```
# 5. FAQ # 5. FAQ
Q1: 训练模型转inference 模型之后预测效果不一致? Q1: 训练模型转inference 模型之后预测效果不一致?
......
...@@ -159,7 +159,7 @@ python3 -m paddle.distributed.launch --ips="xx.xx.xx.xx,xx.xx.xx.xx" --gpus '0,1 ...@@ -159,7 +159,7 @@ python3 -m paddle.distributed.launch --ips="xx.xx.xx.xx,xx.xx.xx.xx" --gpus '0,1
-o Global.pretrained_model=./pretrain_models/MobileNetV3_large_x0_5_pretrained -o Global.pretrained_model=./pretrain_models/MobileNetV3_large_x0_5_pretrained
``` ```
**Note:** When using multi-machine and multi-gpu training, you need to replace the ips value in the above command with the address of your machine, and the machines need to be able to ping each other. In addition, training needs to be launched separately on multiple machines. The command to view the ip address of the machine is `ifconfig`. **Note:** (1) When using multi-machine and multi-gpu training, you need to replace the ips value in the above command with the address of your machine, and the machines need to be able to ping each other. (2) Training needs to be launched separately on multiple machines. The command to view the ip address of the machine is `ifconfig`. (3) For more details about the distributed training speedup ratio, please refer to [Distributed Training Tutorial](./distributed_training_en.md).
### 2.6 Training with knowledge distillation ### 2.6 Training with knowledge distillation
......
...@@ -40,11 +40,17 @@ python3 -m paddle.distributed.launch \ ...@@ -40,11 +40,17 @@ python3 -m paddle.distributed.launch \
## Performance comparison ## Performance comparison
* Based on 26W public recognition dataset (LSVT, rctw, mtwi), training on single 8-card P40 and dual 8-card P40, the final time consumption is as follows. * On two 8-card P40 graphics cards, the final time consumption and speedup ratio for public recognition dataset (LSVT, RCTW, MTWI) containing 260k images are as follows.
| Model | Config file | Number of machines | Number of GPUs per machine | Training time | Recognition acc | Speedup ratio |
| :-------: | :------------: | :----------------: | :----------------------------: | :------------------: | :--------------: | :-----------: |
| CRNN | configs/rec/ch_ppocr_v2.0/rec_chinese_lite_train_v2.0.yml | 1 | 8 | 60h | 66.7% | - |
| CRNN | configs/rec/ch_ppocr_v2.0/rec_chinese_lite_train_v2.0.yml | 2 | 8 | 40h | 67.0% | 150% |
It can be seen that the training time is shortened from 60h to 40h, the speedup ratio can reach 150% (60h / 40h), and the efficiency is 75% (60h / (40h * 2)). | Model | Config file | Recognition acc | single 8-card training time | two 8-card training time | Speedup ratio |
|------|-----|--------|--------|--------|-----|
| CRNN | [rec_chinese_lite_train_v2.0.yml](../../configs/rec/ch_ppocr_v2.0/rec_chinese_lite_train_v2.0.yml) | 67.0% | 2.50d | 1.67d | **1.5** |
* On four 8-card V100 graphics cards, the final time consumption and speedup ratio for full data are as follows.
| Model | Config file | Recognition acc | single 8-card training time | four 8-card training time | Speedup ratio |
|------|-----|--------|--------|--------|-----|
| SVTR | [ch_PP-OCRv3_rec_distillation.yml](../../configs/rec/PP-OCRv3/ch_PP-OCRv3_rec_distillation.yml) | 74.0% | 10d | 2.84d | **3.5** |
...@@ -29,10 +29,10 @@ PP-OCR pipeline is as follows: ...@@ -29,10 +29,10 @@ PP-OCR pipeline is as follows:
PP-OCR system is in continuous optimization. At present, PP-OCR and PP-OCRv2 have been released: PP-OCR system is in continuous optimization. At present, PP-OCR and PP-OCRv2 have been released:
PP-OCR adopts 19 effective strategies from 8 aspects including backbone network selection and adjustment, prediction head design, data augmentation, learning rate transformation strategy, regularization parameter selection, pre-training model use, and automatic model tailoring and quantization to optimize and slim down the models of each module (as shown in the green box above). The final results are an ultra-lightweight Chinese and English OCR model with an overall size of 3.5M and a 2.8M English digital OCR model. For more details, please refer to the PP-OCR technical article (https://arxiv.org/abs/2009.09941). PP-OCR adopts 19 effective strategies from 8 aspects including backbone network selection and adjustment, prediction head design, data augmentation, learning rate transformation strategy, regularization parameter selection, pre-training model use, and automatic model tailoring and quantization to optimize and slim down the models of each module (as shown in the green box above). The final results are an ultra-lightweight Chinese and English OCR model with an overall size of 3.5M and a 2.8M English digital OCR model. For more details, please refer to [PP-OCR technical report](https://arxiv.org/abs/2009.09941).
#### PP-OCRv2 #### PP-OCRv2
On the basis of PP-OCR, PP-OCRv2 is further optimized in five aspects. The detection model adopts CML(Collaborative Mutual Learning) knowledge distillation strategy and CopyPaste data expansion strategy. The recognition model adopts LCNet lightweight backbone network, U-DML knowledge distillation strategy and enhanced CTC loss function improvement (as shown in the red box above), which further improves the inference speed and prediction effect. For more details, please refer to the technical report of PP-OCRv2 (https://arxiv.org/abs/2109.03144). On the basis of PP-OCR, PP-OCRv2 is further optimized in five aspects. The detection model adopts CML(Collaborative Mutual Learning) knowledge distillation strategy and CopyPaste data expansion strategy. The recognition model adopts LCNet lightweight backbone network, U-DML knowledge distillation strategy and enhanced CTC loss function improvement (as shown in the red box above), which further improves the inference speed and prediction effect. For more details, please refer to [PP-OCRv2 technical report](https://arxiv.org/abs/2109.03144).
#### PP-OCRv3 #### PP-OCRv3
...@@ -46,7 +46,7 @@ PP-OCRv3 pipeline is as follows: ...@@ -46,7 +46,7 @@ PP-OCRv3 pipeline is as follows:
<img src="../ppocrv3_framework.png" width="800"> <img src="../ppocrv3_framework.png" width="800">
</div> </div>
For more details, please refer to [PP-OCRv3 technical report](./PP-OCRv3_introduction_en.md). For more details, please refer to [PP-OCRv3 technical report](https://arxiv.org/abs/2206.03001v2).
<a name="2"></a> <a name="2"></a>
## 2. Features ## 2. Features
......
...@@ -306,7 +306,7 @@ python3 -m paddle.distributed.launch --ips="xx.xx.xx.xx,xx.xx.xx.xx" --gpus '0,1 ...@@ -306,7 +306,7 @@ python3 -m paddle.distributed.launch --ips="xx.xx.xx.xx,xx.xx.xx.xx" --gpus '0,1
-o Global.pretrained_model=./pretrain_models/rec_mv3_none_bilstm_ctc_v2.0_train -o Global.pretrained_model=./pretrain_models/rec_mv3_none_bilstm_ctc_v2.0_train
``` ```
**Note:** When using multi-machine and multi-gpu training, you need to replace the ips value in the above command with the address of your machine, and the machines need to be able to ping each other. In addition, training needs to be launched separately on multiple machines. The command to view the ip address of the machine is `ifconfig`. **Note:** (1) When using multi-machine and multi-gpu training, you need to replace the ips value in the above command with the address of your machine, and the machines need to be able to ping each other. (2) Training needs to be launched separately on multiple machines. The command to view the ip address of the machine is `ifconfig`. (3) For more details about the distributed training speedup ratio, please refer to [Distributed Training Tutorial](./distributed_training_en.md).
<a name="kd"></a> <a name="kd"></a>
### 2.6 Training with Knowledge Distillation ### 2.6 Training with Knowledge Distillation
......
...@@ -27,12 +27,12 @@ class CosineEmbeddingLoss(nn.Layer): ...@@ -27,12 +27,12 @@ class CosineEmbeddingLoss(nn.Layer):
self.epsilon = 1e-12 self.epsilon = 1e-12
def forward(self, x1, x2, target): def forward(self, x1, x2, target):
similarity = paddle.fluid.layers.reduce_sum( similarity = paddle.sum(
x1 * x2, dim=-1) / (paddle.norm( x1 * x2, dim=-1) / (paddle.norm(
x1, axis=-1) * paddle.norm( x1, axis=-1) * paddle.norm(
x2, axis=-1) + self.epsilon) x2, axis=-1) + self.epsilon)
one_list = paddle.full_like(target, fill_value=1) one_list = paddle.full_like(target, fill_value=1)
out = paddle.fluid.layers.reduce_mean( out = paddle.mean(
paddle.where( paddle.where(
paddle.equal(target, one_list), 1. - similarity, paddle.equal(target, one_list), 1. - similarity,
paddle.maximum( paddle.maximum(
......
...@@ -19,7 +19,6 @@ from __future__ import print_function ...@@ -19,7 +19,6 @@ from __future__ import print_function
import paddle import paddle
from paddle import nn from paddle import nn
from paddle.nn import functional as F from paddle.nn import functional as F
from paddle import fluid
class TableAttentionLoss(nn.Layer): class TableAttentionLoss(nn.Layer):
def __init__(self, structure_weight, loc_weight, use_giou=False, giou_weight=1.0, **kwargs): def __init__(self, structure_weight, loc_weight, use_giou=False, giou_weight=1.0, **kwargs):
...@@ -36,13 +35,13 @@ class TableAttentionLoss(nn.Layer): ...@@ -36,13 +35,13 @@ class TableAttentionLoss(nn.Layer):
:param bbox:[[x1,y1,x2,y2], [x1,y1,x2,y2],,,] :param bbox:[[x1,y1,x2,y2], [x1,y1,x2,y2],,,]
:return: loss :return: loss
''' '''
ix1 = fluid.layers.elementwise_max(preds[:, 0], bbox[:, 0]) ix1 = paddle.maximum(preds[:, 0], bbox[:, 0])
iy1 = fluid.layers.elementwise_max(preds[:, 1], bbox[:, 1]) iy1 = paddle.maximum(preds[:, 1], bbox[:, 1])
ix2 = fluid.layers.elementwise_min(preds[:, 2], bbox[:, 2]) ix2 = paddle.minimum(preds[:, 2], bbox[:, 2])
iy2 = fluid.layers.elementwise_min(preds[:, 3], bbox[:, 3]) iy2 = paddle.minimum(preds[:, 3], bbox[:, 3])
iw = fluid.layers.clip(ix2 - ix1 + 1e-3, 0., 1e10) iw = paddle.clip(ix2 - ix1 + 1e-3, 0., 1e10)
ih = fluid.layers.clip(iy2 - iy1 + 1e-3, 0., 1e10) ih = paddle.clip(iy2 - iy1 + 1e-3, 0., 1e10)
# overlap # overlap
inters = iw * ih inters = iw * ih
...@@ -55,12 +54,12 @@ class TableAttentionLoss(nn.Layer): ...@@ -55,12 +54,12 @@ class TableAttentionLoss(nn.Layer):
# ious # ious
ious = inters / uni ious = inters / uni
ex1 = fluid.layers.elementwise_min(preds[:, 0], bbox[:, 0]) ex1 = paddle.minimum(preds[:, 0], bbox[:, 0])
ey1 = fluid.layers.elementwise_min(preds[:, 1], bbox[:, 1]) ey1 = paddle.minimum(preds[:, 1], bbox[:, 1])
ex2 = fluid.layers.elementwise_max(preds[:, 2], bbox[:, 2]) ex2 = paddle.maximum(preds[:, 2], bbox[:, 2])
ey2 = fluid.layers.elementwise_max(preds[:, 3], bbox[:, 3]) ey2 = paddle.maximum(preds[:, 3], bbox[:, 3])
ew = fluid.layers.clip(ex2 - ex1 + 1e-3, 0., 1e10) ew = paddle.clip(ex2 - ex1 + 1e-3, 0., 1e10)
eh = fluid.layers.clip(ey2 - ey1 + 1e-3, 0., 1e10) eh = paddle.clip(ey2 - ey1 + 1e-3, 0., 1e10)
# enclose erea # enclose erea
enclose = ew * eh + eps enclose = ew * eh + eps
......
...@@ -175,12 +175,7 @@ class Kie_backbone(nn.Layer): ...@@ -175,12 +175,7 @@ class Kie_backbone(nn.Layer):
img, relations, texts, gt_bboxes, tag, img_size) img, relations, texts, gt_bboxes, tag, img_size)
x = self.img_feat(img) x = self.img_feat(img)
boxes, rois_num = self.bbox2roi(gt_bboxes) boxes, rois_num = self.bbox2roi(gt_bboxes)
feats = paddle.fluid.layers.roi_align( feats = paddle.vision.ops.roi_align(
x, x, boxes, spatial_scale=1.0, output_size=7, boxes_num=rois_num)
boxes,
spatial_scale=1.0,
pooled_height=7,
pooled_width=7,
rois_num=rois_num)
feats = self.maxpool(feats).squeeze(-1).squeeze(-1) feats = self.maxpool(feats).squeeze(-1).squeeze(-1)
return [relations, texts, feats] return [relations, texts, feats]
...@@ -18,7 +18,6 @@ from __future__ import print_function ...@@ -18,7 +18,6 @@ from __future__ import print_function
from paddle import nn, ParamAttr from paddle import nn, ParamAttr
from paddle.nn import functional as F from paddle.nn import functional as F
import paddle.fluid as fluid
import paddle import paddle
import numpy as np import numpy as np
......
...@@ -20,13 +20,11 @@ import math ...@@ -20,13 +20,11 @@ import math
import paddle import paddle
from paddle import nn, ParamAttr from paddle import nn, ParamAttr
from paddle.nn import functional as F from paddle.nn import functional as F
import paddle.fluid as fluid
import numpy as np import numpy as np
from .self_attention import WrapEncoderForFeature from .self_attention import WrapEncoderForFeature
from .self_attention import WrapEncoder from .self_attention import WrapEncoder
from paddle.static import Program from paddle.static import Program
from ppocr.modeling.backbones.rec_resnet_fpn import ResNetFPN from ppocr.modeling.backbones.rec_resnet_fpn import ResNetFPN
import paddle.fluid.framework as framework
from collections import OrderedDict from collections import OrderedDict
gradient_clip = 10 gradient_clip = 10
......
...@@ -22,7 +22,6 @@ import paddle ...@@ -22,7 +22,6 @@ import paddle
from paddle import ParamAttr, nn from paddle import ParamAttr, nn
from paddle import nn, ParamAttr from paddle import nn, ParamAttr
from paddle.nn import functional as F from paddle.nn import functional as F
import paddle.fluid as fluid
import numpy as np import numpy as np
gradient_clip = 10 gradient_clip = 10
...@@ -288,10 +287,10 @@ class PrePostProcessLayer(nn.Layer): ...@@ -288,10 +287,10 @@ class PrePostProcessLayer(nn.Layer):
"layer_norm_%d" % len(self.sublayers()), "layer_norm_%d" % len(self.sublayers()),
paddle.nn.LayerNorm( paddle.nn.LayerNorm(
normalized_shape=d_model, normalized_shape=d_model,
weight_attr=fluid.ParamAttr( weight_attr=paddle.ParamAttr(
initializer=fluid.initializer.Constant(1.)), initializer=paddle.nn.initializer.Constant(1.)),
bias_attr=fluid.ParamAttr( bias_attr=paddle.ParamAttr(
initializer=fluid.initializer.Constant(0.))))) initializer=paddle.nn.initializer.Constant(0.)))))
elif cmd == "d": # add dropout elif cmd == "d": # add dropout
self.functors.append(lambda x: F.dropout( self.functors.append(lambda x: F.dropout(
x, p=dropout_rate, mode="downscale_in_infer") x, p=dropout_rate, mode="downscale_in_infer")
...@@ -324,7 +323,7 @@ class PrepareEncoder(nn.Layer): ...@@ -324,7 +323,7 @@ class PrepareEncoder(nn.Layer):
def forward(self, src_word, src_pos): def forward(self, src_word, src_pos):
src_word_emb = src_word src_word_emb = src_word
src_word_emb = fluid.layers.cast(src_word_emb, 'float32') src_word_emb = paddle.cast(src_word_emb, 'float32')
src_word_emb = paddle.scale(x=src_word_emb, scale=self.src_emb_dim**0.5) src_word_emb = paddle.scale(x=src_word_emb, scale=self.src_emb_dim**0.5)
src_pos = paddle.squeeze(src_pos, axis=-1) src_pos = paddle.squeeze(src_pos, axis=-1)
src_pos_enc = self.emb(src_pos) src_pos_enc = self.emb(src_pos)
...@@ -367,7 +366,7 @@ class PrepareDecoder(nn.Layer): ...@@ -367,7 +366,7 @@ class PrepareDecoder(nn.Layer):
self.dropout_rate = dropout_rate self.dropout_rate = dropout_rate
def forward(self, src_word, src_pos): def forward(self, src_word, src_pos):
src_word = fluid.layers.cast(src_word, 'int64') src_word = paddle.cast(src_word, 'int64')
src_word = paddle.squeeze(src_word, axis=-1) src_word = paddle.squeeze(src_word, axis=-1)
src_word_emb = self.emb0(src_word) src_word_emb = self.emb0(src_word)
src_word_emb = paddle.scale(x=src_word_emb, scale=self.src_emb_dim**0.5) src_word_emb = paddle.scale(x=src_word_emb, scale=self.src_emb_dim**0.5)
......
...@@ -18,7 +18,7 @@ The table recognition mainly contains three models ...@@ -18,7 +18,7 @@ The table recognition mainly contains three models
The table recognition flow chart is as follows The table recognition flow chart is as follows
![tableocr_pipeline](../../doc/table/tableocr_pipeline_en.jpg) ![tableocr_pipeline](../docs/table/tableocr_pipeline_en.jpg)
1. The coordinates of single-line text is detected by DB model, and then sends it to the recognition model to get the recognition result. 1. The coordinates of single-line text is detected by DB model, and then sends it to the recognition model to get the recognition result.
2. The table structure and cell coordinates is predicted by RARE model. 2. The table structure and cell coordinates is predicted by RARE model.
......
#使用镜像:
#registry.baidubce.com/paddlepaddle/paddle:latest-dev-cuda10.1-cudnn7-gcc82
#编译Serving Server:
#client和app可以直接使用release版本
#server因为加入了自定义OP,需要重新编译
apt-get update
apt install -y libcurl4-openssl-dev libbz2-dev
wget https://paddle-serving.bj.bcebos.com/others/centos_ssl.tar && tar xf centos_ssl.tar && rm -rf centos_ssl.tar && mv libcrypto.so.1.0.2k /usr/lib/libcrypto.so.1.0.2k && mv libssl.so.1.0.2k /usr/lib/libssl.so.1.0.2k && ln -sf /usr/lib/libcrypto.so.1.0.2k /usr/lib/libcrypto.so.10 && ln -sf /usr/lib/libssl.so.1.0.2k /usr/lib/libssl.so.10 && ln -sf /usr/lib/libcrypto.so.10 /usr/lib/libcrypto.so && ln -sf /usr/lib/libssl.so.10 /usr/lib/libssl.so
# 安装go依赖
rm -rf /usr/local/go
wget -qO- https://paddle-ci.cdn.bcebos.com/go1.17.2.linux-amd64.tar.gz | tar -xz -C /usr/local
export GOROOT=/usr/local/go
export GOPATH=/root/gopath
export PATH=$PATH:$GOPATH/bin:$GOROOT/bin
go env -w GO111MODULE=on
go env -w GOPROXY=https://goproxy.cn,direct
go install github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway@v1.15.2
go install github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger@v1.15.2
go install github.com/golang/protobuf/protoc-gen-go@v1.4.3
go install google.golang.org/grpc@v1.33.0
go env -w GO111MODULE=auto
# 下载opencv库
wget https://paddle-qa.bj.bcebos.com/PaddleServing/opencv3.tar.gz && tar -xvf opencv3.tar.gz && rm -rf opencv3.tar.gz
export OPENCV_DIR=$PWD/opencv3
# clone Serving
git clone https://github.com/PaddlePaddle/Serving.git -b develop --depth=1
cd Serving
export Serving_repo_path=$PWD
git submodule update --init --recursive
python -m pip install -r python/requirements.txt
export PYTHON_INCLUDE_DIR=$(python -c "from distutils.sysconfig import get_python_inc; print(get_python_inc())")
export PYTHON_LIBRARIES=$(python -c "import distutils.sysconfig as sysconfig; print(sysconfig.get_config_var('LIBDIR'))")
export PYTHON_EXECUTABLE=`which python`
export CUDA_PATH='/usr/local/cuda'
export CUDNN_LIBRARY='/usr/local/cuda/lib64/'
export CUDA_CUDART_LIBRARY='/usr/local/cuda/lib64/'
export TENSORRT_LIBRARY_PATH='/usr/local/TensorRT6-cuda10.1-cudnn7/targets/x86_64-linux-gnu/'
# cp 自定义OP代码
cp -rf ../deploy/pdserving/general_detection_op.cpp ${Serving_repo_path}/core/general-server/op
# 编译Server, export SERVING_BIN
mkdir server-build-gpu-opencv && cd server-build-gpu-opencv
cmake -DPYTHON_INCLUDE_DIR=$PYTHON_INCLUDE_DIR \
-DPYTHON_LIBRARIES=$PYTHON_LIBRARIES \
-DPYTHON_EXECUTABLE=$PYTHON_EXECUTABLE \
-DCUDA_TOOLKIT_ROOT_DIR=${CUDA_PATH} \
-DCUDNN_LIBRARY=${CUDNN_LIBRARY} \
-DCUDA_CUDART_LIBRARY=${CUDA_CUDART_LIBRARY} \
-DTENSORRT_ROOT=${TENSORRT_LIBRARY_PATH} \
-DOPENCV_DIR=${OPENCV_DIR} \
-DWITH_OPENCV=ON \
-DSERVER=ON \
-DWITH_GPU=ON ..
make -j32
python -m pip install python/dist/paddle*
export SERVING_BIN=$PWD/core/general-server/serving
cd ../../
...@@ -3,7 +3,7 @@ model_name:ch_PP-OCRv2 ...@@ -3,7 +3,7 @@ model_name:ch_PP-OCRv2
use_opencv:True use_opencv:True
infer_model:./inference/ch_PP-OCRv2_det_infer/ infer_model:./inference/ch_PP-OCRv2_det_infer/
infer_quant:False infer_quant:False
inference:./deploy/cpp_infer/build/ppocr --rec_char_dict_path=./ppocr/utils/ppocr_keys_v1.txt inference:./deploy/cpp_infer/build/ppocr --rec_char_dict_path=./ppocr/utils/ppocr_keys_v1.txt --rec_img_h=32
--use_gpu:True|False --use_gpu:True|False
--enable_mkldnn:False --enable_mkldnn:False
--cpu_threads:6 --cpu_threads:6
......
...@@ -6,10 +6,10 @@ infer_export:null ...@@ -6,10 +6,10 @@ infer_export:null
infer_quant:False infer_quant:False
inference:tools/infer/predict_system.py inference:tools/infer/predict_system.py
--use_gpu:False|True --use_gpu:False|True
--enable_mkldnn:False|True --enable_mkldnn:False
--cpu_threads:1|6 --cpu_threads:6
--rec_batch_num:1 --rec_batch_num:1
--use_tensorrt:False|True --use_tensorrt:False
--precision:fp32 --precision:fp32
--det_model_dir: --det_model_dir:
--image_dir:./inference/ch_det_data_50/all-sum-510/ --image_dir:./inference/ch_det_data_50/all-sum-510/
......
...@@ -14,4 +14,4 @@ inference:tools/infer/predict_system.py --rec_image_shape="3,32,320" ...@@ -14,4 +14,4 @@ inference:tools/infer/predict_system.py --rec_image_shape="3,32,320"
--use_gpu:True|False --use_gpu:True|False
--det_model_dir: --det_model_dir:
--rec_model_dir: --rec_model_dir:
--image_dir:./inference/ch_det_data_50/all-sum-510/ --image_dir:./inference/ch_det_data_50/all-sum-510/00008790.jpg
\ No newline at end of file \ No newline at end of file
===========================serving_params===========================
model_name:ch_PP-OCRv2
python:python3.7
trans_model:-m paddle_serving_client.convert
--det_dirname:./inference/ch_PP-OCRv2_det_infer/
--model_filename:inference.pdmodel
--params_filename:inference.pdiparams
--det_serving_server:./deploy/pdserving/ppocr_det_v2_serving/
--det_serving_client:./deploy/pdserving/ppocr_det_v2_client/
--rec_dirname:./inference/ch_PP-OCRv2_rec_infer/
--rec_serving_server:./deploy/pdserving/ppocr_rec_v2_serving/
--rec_serving_client:./deploy/pdserving/ppocr_rec_v2_client/
serving_dir:./deploy/pdserving
web_service:-m paddle_serving_server.serve
--op:GeneralDetectionOp GeneralInferOp
--port:8181
--gpu_id:"0"|null
cpp_client:ocr_cpp_client.py
--image_dir:../../doc/imgs/1.jpg
===========================serving_params===========================
model_name:ch_PP-OCRv2
python:python3.7
trans_model:-m paddle_serving_client.convert
--det_dirname:./inference/ch_PP-OCRv2_det_infer/
--model_filename:inference.pdmodel
--params_filename:inference.pdiparams
--det_serving_server:./deploy/pdserving/ppocr_det_v2_serving/
--det_serving_client:./deploy/pdserving/ppocr_det_v2_client/
--rec_dirname:./inference/ch_PP-OCRv2_rec_infer/
--rec_serving_server:./deploy/pdserving/ppocr_rec_v2_serving/
--rec_serving_client:./deploy/pdserving/ppocr_rec_v2_client/
serving_dir:./deploy/pdserving
web_service:web_service.py --config=config.yml --opt op.det.concurrency="1" op.rec.concurrency="1"
op.det.local_service_conf.devices:gpu|null
op.det.local_service_conf.use_mkldnn:False
op.det.local_service_conf.thread_num:6
op.det.local_service_conf.use_trt:False
op.det.local_service_conf.precision:fp32
op.det.local_service_conf.model_config:
op.rec.local_service_conf.model_config:
pipline:pipeline_http_client.py
--image_dir:../../doc/imgs/1.jpg
===========================serving_params===========================
model_name:ch_PP-OCRv2_det
python:python3.7
trans_model:-m paddle_serving_client.convert
--det_dirname:./inference/ch_PP-OCRv2_det_infer/
--model_filename:inference.pdmodel
--params_filename:inference.pdiparams
--det_serving_server:./deploy/pdserving/ppocr_det_v2_serving/
--det_serving_client:./deploy/pdserving/ppocr_det_v2_client/
--rec_dirname:null
--rec_serving_server:null
--rec_serving_client:null
serving_dir:./deploy/pdserving
web_service:web_service_det.py --config=config.yml --opt op.det.concurrency="1"
op.det.local_service_conf.devices:gpu|null
op.det.local_service_conf.use_mkldnn:False
op.det.local_service_conf.thread_num:6
op.det.local_service_conf.use_trt:False
op.det.local_service_conf.precision:fp32
op.det.local_service_conf.model_config:
op.rec.local_service_conf.model_config:
pipline:pipeline_http_client.py
--image_dir:../../doc/imgs/1.jpg
===========================train_params===========================
model_name:ch_PP-OCRv2_det
python:python3.7
gpu_list:192.168.0.1,192.168.0.2;0,1
Global.use_gpu:True
Global.auto_cast:fp32
Global.epoch_num:lite_train_lite_infer=1|whole_train_whole_infer=50
Global.save_model_dir:./output/
Train.loader.batch_size_per_card:lite_train_lite_infer=2|whole_train_whole_infer=4
Global.pretrained_model:null
train_model_name:latest
train_infer_img_dir:./train_data/icdar2015/text_localization/ch4_test_images/
null:null
##
trainer:norm_train
norm_train:tools/train.py -c configs/det/ch_PP-OCRv2/ch_PP-OCRv2_det_cml.yml -o
pact_train:null
fpgm_train:null
distill_train:null
null:null
null:null
##
===========================eval_params===========================
eval:null
null:null
##
===========================infer_params===========================
Global.save_inference_dir:./output/
Global.checkpoints:
norm_export:tools/export_model.py -c configs/det/ch_PP-OCRv2/ch_PP-OCRv2_det_cml.yml -o
quant_export:null
fpgm_export:
distill_export:null
export1:null
export2:null
inference_dir:Student
infer_model:./inference/ch_PP-OCRv2_det_infer/
infer_export:null
infer_quant:False
inference:tools/infer/predict_det.py
--use_gpu:False
--enable_mkldnn:False
--cpu_threads:6
--rec_batch_num:1
--use_tensorrt:False
--precision:fp32
--det_model_dir:
--image_dir:./inference/ch_det_data_50/all-sum-510/
null:null
--benchmark:True
null:null
===========================infer_benchmark_params==========================
random_infer_input:[{float32,[3,640,640]}];[{float32,[3,960,960]}]
===========================train_params=========================== ===========================train_params===========================
model_name:ch_PPOCRv2_det model_name:ch_PP-OCRv2_det
python:python3.7 python:python3.7
gpu_list:0|0,1 gpu_list:0|0,1
Global.use_gpu:True|True Global.use_gpu:True|True
Global.auto_cast:amp Global.auto_cast:amp
Global.epoch_num:lite_train_lite_infer=1|whole_train_whole_infer=500 Global.epoch_num:lite_train_lite_infer=1|whole_train_whole_infer=50
Global.save_model_dir:./output/ Global.save_model_dir:./output/
Train.loader.batch_size_per_card:lite_train_lite_infer=2|whole_train_whole_infer=4 Train.loader.batch_size_per_card:lite_train_lite_infer=2|whole_train_whole_infer=4
Global.pretrained_model:null Global.pretrained_model:null
...@@ -39,11 +39,11 @@ infer_export:null ...@@ -39,11 +39,11 @@ infer_export:null
infer_quant:False infer_quant:False
inference:tools/infer/predict_det.py inference:tools/infer/predict_det.py
--use_gpu:True|False --use_gpu:True|False
--enable_mkldnn:True|False --enable_mkldnn:False
--cpu_threads:1|6 --cpu_threads:6
--rec_batch_num:1 --rec_batch_num:1
--use_tensorrt:False|True --use_tensorrt:False
--precision:fp32|fp16|int8 --precision:fp32
--det_model_dir: --det_model_dir:
--image_dir:./inference/ch_det_data_50/all-sum-510/ --image_dir:./inference/ch_det_data_50/all-sum-510/
null:null null:null
......
===========================cpp_infer_params===========================
model_name:ch_PP-OCRv2_det_KL
use_opencv:True
infer_model:./inference/ch_PP-OCRv2_det_klquant_infer
infer_quant:False
inference:./deploy/cpp_infer/build/ppocr
--use_gpu:True|False
--enable_mkldnn:False
--cpu_threads:6
--rec_batch_num:1
--use_tensorrt:False
--precision:fp32
--det_model_dir:
--image_dir:./inference/ch_det_data_50/all-sum-510/
null:null
--benchmark:True
--det:True
--rec:False
--cls:False
--use_angle_cls:False
\ No newline at end of file
===========================serving_params===========================
model_name:ch_PP-OCRv2_det_KL
python:python3.7
trans_model:-m paddle_serving_client.convert
--det_dirname:./inference/ch_PP-OCRv2_det_klquant_infer/
--model_filename:inference.pdmodel
--params_filename:inference.pdiparams
--det_serving_server:./deploy/pdserving/ppocr_det_v2_kl_serving/
--det_serving_client:./deploy/pdserving/ppocr_det_v2_kl_client/
--rec_dirname:./inference/ch_PP-OCRv2_rec_klquant_infer/
--rec_serving_server:./deploy/pdserving/ppocr_rec_v2_kl_serving/
--rec_serving_client:./deploy/pdserving/ppocr_rec_v2_kl_client/
serving_dir:./deploy/pdserving
web_service:-m paddle_serving_server.serve
--op:GeneralDetectionOp GeneralInferOp
--port:8181
--gpu_id:"0"|null
cpp_client:ocr_cpp_client.py
--image_dir:../../doc/imgs/1.jpg
===========================serving_params===========================
model_name:ch_PP-OCRv2_det_KL
python:python3.7
trans_model:-m paddle_serving_client.convert
--det_dirname:./inference/ch_PP-OCRv2_det_klquant_infer/
--model_filename:inference.pdmodel
--params_filename:inference.pdiparams
--det_serving_server:./deploy/pdserving/ppocr_det_v2_kl_serving/
--det_serving_client:./deploy/pdserving/ppocr_det_v2_kl_client/
--rec_dirname:null
--rec_serving_server:null
--rec_serving_client:null
serving_dir:./deploy/pdserving
web_service:web_service_det.py --config=config.yml --opt op.det.concurrency="1"
op.det.local_service_conf.devices:gpu|null
op.det.local_service_conf.use_mkldnn:False
op.det.local_service_conf.thread_num:6
op.det.local_service_conf.use_trt:False
op.det.local_service_conf.precision:fp32
op.det.local_service_conf.model_config:
op.rec.local_service_conf.model_config:
pipline:pipeline_http_client.py
--image_dir:../../doc/imgs/1.jpg
===========================cpp_infer_params===========================
model_name:ch_PP-OCRv2_det_PACT
use_opencv:True
infer_model:./inference/ch_PP-OCRv2_det_pact_infer
infer_quant:False
inference:./deploy/cpp_infer/build/ppocr
--use_gpu:True|False
--enable_mkldnn:False
--cpu_threads:6
--rec_batch_num:1
--use_tensorrt:False
--precision:fp32
--det_model_dir:
--image_dir:./inference/ch_det_data_50/all-sum-510/
null:null
--benchmark:True
--det:True
--rec:False
--cls:False
--use_angle_cls:False
\ No newline at end of file
===========================serving_params===========================
model_name:ch_PP-OCRv2_det_PACT
python:python3.7
trans_model:-m paddle_serving_client.convert
--det_dirname:./inference/ch_PP-OCRv2_det_pact_infer/
--model_filename:inference.pdmodel
--params_filename:inference.pdiparams
--det_serving_server:./deploy/pdserving/ppocr_det_v2_pact_serving/
--det_serving_client:./deploy/pdserving/ppocr_det_v2_pact_client/
--rec_dirname:./inference/ch_PP-OCRv2_rec_pact_infer/
--rec_serving_server:./deploy/pdserving/ppocr_rec_v2_pact_serving/
--rec_serving_client:./deploy/pdserving/ppocr_rec_v2_pact_client/
serving_dir:./deploy/pdserving
web_service:-m paddle_serving_server.serve
--op:GeneralDetectionOp GeneralInferOp
--port:8181
--gpu_id:"0"|null
cpp_client:ocr_cpp_client.py
--image_dir:../../doc/imgs/1.jpg
===========================serving_params===========================
model_name:ch_PP-OCRv2_det_PACT
python:python3.7
trans_model:-m paddle_serving_client.convert
--det_dirname:./inference/ch_PP-OCRv2_det_pact_infer/
--model_filename:inference.pdmodel
--params_filename:inference.pdiparams
--det_serving_server:./deploy/pdserving/ppocr_det_v2_pact_serving/
--det_serving_client:./deploy/pdserving/ppocr_det_v2_pact_client/
--rec_dirname:null
--rec_serving_server:null
--rec_serving_client:null
serving_dir:./deploy/pdserving
web_service:web_service_det.py --config=config.yml --opt op.det.concurrency="1"
op.det.local_service_conf.devices:gpu|null
op.det.local_service_conf.use_mkldnn:False
op.det.local_service_conf.thread_num:6
op.det.local_service_conf.use_trt:False
op.det.local_service_conf.precision:fp32
op.det.local_service_conf.model_config:
op.rec.local_service_conf.model_config:
pipline:pipeline_http_client.py
--image_dir:../../doc/imgs/1.jpg
===========================train_params=========================== ===========================train_params===========================
model_name:ch_PPOCRv2_det_PACT model_name:ch_PP-OCRv2_det_PACT
python:python3.7 python:python3.7
gpu_list:0|0,1 gpu_list:0|0,1
Global.use_gpu:True|True Global.use_gpu:True|True
Global.auto_cast:amp Global.auto_cast:amp
Global.epoch_num:lite_train_lite_infer=1|whole_train_whole_infer=500 Global.epoch_num:lite_train_lite_infer=1|whole_train_whole_infer=50
Global.save_model_dir:./output/ Global.save_model_dir:./output/
Train.loader.batch_size_per_card:lite_train_lite_infer=2|whole_train_whole_infer=4 Train.loader.batch_size_per_card:lite_train_lite_infer=2|whole_train_whole_infer=4
Global.pretrained_model:null Global.pretrained_model:null
...@@ -39,11 +39,11 @@ infer_export:null ...@@ -39,11 +39,11 @@ infer_export:null
infer_quant:False infer_quant:False
inference:tools/infer/predict_det.py inference:tools/infer/predict_det.py
--use_gpu:True|False --use_gpu:True|False
--enable_mkldnn:True|False --enable_mkldnn:False
--cpu_threads:1|6 --cpu_threads:6
--rec_batch_num:1 --rec_batch_num:1
--use_tensorrt:False|True --use_tensorrt:False
--precision:fp32|fp16|int8 --precision:fp32
--det_model_dir: --det_model_dir:
--image_dir:./inference/ch_det_data_50/all-sum-510/ --image_dir:./inference/ch_det_data_50/all-sum-510/
null:null null:null
......
...@@ -3,7 +3,7 @@ model_name:ch_PP-OCRv2_rec ...@@ -3,7 +3,7 @@ model_name:ch_PP-OCRv2_rec
use_opencv:True use_opencv:True
infer_model:./inference/ch_PP-OCRv2_rec_infer/ infer_model:./inference/ch_PP-OCRv2_rec_infer/
infer_quant:False infer_quant:False
inference:./deploy/cpp_infer/build/ppocr --rec_char_dict_path=./ppocr/utils/ppocr_keys_v1.txt inference:./deploy/cpp_infer/build/ppocr --rec_char_dict_path=./ppocr/utils/ppocr_keys_v1.txt --rec_img_h=32
--use_gpu:True|False --use_gpu:True|False
--enable_mkldnn:False --enable_mkldnn:False
--cpu_threads:6 --cpu_threads:6
......
===========================serving_params===========================
model_name:ch_PP-OCRv2_rec
python:python3.7
trans_model:-m paddle_serving_client.convert
--det_dirname:null
--model_filename:inference.pdmodel
--params_filename:inference.pdiparams
--det_serving_server:null
--det_serving_client:null
--rec_dirname:./inference/ch_PP-OCRv2_rec_infer/
--rec_serving_server:./deploy/pdserving/ppocr_rec_v2_serving/
--rec_serving_client:./deploy/pdserving/ppocr_rec_v2_client/
serving_dir:./deploy/pdserving
web_service:web_service_rec.py --config=config.yml --opt op.rec.concurrency="1"
op.det.local_service_conf.devices:gpu|null
op.det.local_service_conf.use_mkldnn:False
op.det.local_service_conf.thread_num:6
op.det.local_service_conf.use_trt:False
op.det.local_service_conf.precision:fp32
op.det.local_service_conf.model_config:
op.rec.local_service_conf.model_config:
pipline:pipeline_http_client.py --det=False
--image_dir:../../inference/rec_inference
===========================train_params===========================
model_name:ch_PP-OCRv2_rec
python:python3.7
gpu_list:192.168.0.1,192.168.0.2;0,1
Global.use_gpu:True
Global.auto_cast:fp32
Global.epoch_num:lite_train_lite_infer=3|whole_train_whole_infer=50
Global.save_model_dir:./output/
Train.loader.batch_size_per_card:lite_train_lite_infer=16|whole_train_whole_infer=128
Global.pretrained_model:null
train_model_name:latest
train_infer_img_dir:./inference/rec_inference
null:null
##
trainer:norm_train
norm_train:tools/train.py -c test_tipc/configs/ch_PP-OCRv2_rec/ch_PP-OCRv2_rec_distillation.yml -o
pact_train:null
fpgm_train:null
distill_train:null
null:null
null:null
##
===========================eval_params===========================
eval:null
null:null
##
===========================infer_params===========================
Global.save_inference_dir:./output/
Global.checkpoints:
norm_export:tools/export_model.py -c test_tipc/configs/ch_PP-OCRv2_rec/ch_PP-OCRv2_rec_distillation.yml -o
quant_export:
fpgm_export:
distill_export:null
export1:null
export2:null
inference_dir:Student
infer_model:./inference/ch_PP-OCRv2_rec_infer
infer_export:null
infer_quant:False
inference:tools/infer/predict_rec.py
--use_gpu:False
--enable_mkldnn:False
--cpu_threads:6
--rec_batch_num:1|6
--use_tensorrt:False
--precision:fp32
--rec_model_dir:
--image_dir:./inference/rec_inference
null:null
--benchmark:True
null:null
===========================infer_benchmark_params==========================
random_infer_input:[{float32,[3,32,320]}]
===========================train_params=========================== ===========================train_params===========================
model_name:PPOCRv2_ocr_rec model_name:ch_PP-OCRv2_rec
python:python3.7 python:python3.7
gpu_list:0|0,1 gpu_list:0|0,1
Global.use_gpu:True|True Global.use_gpu:True|True
Global.auto_cast:amp Global.auto_cast:amp
Global.epoch_num:lite_train_lite_infer=3|whole_train_whole_infer=300 Global.epoch_num:lite_train_lite_infer=3|whole_train_whole_infer=50
Global.save_model_dir:./output/ Global.save_model_dir:./output/
Train.loader.batch_size_per_card:lite_train_lite_infer=16|whole_train_whole_infer=128 Train.loader.batch_size_per_card:lite_train_lite_infer=16|whole_train_whole_infer=128
Global.pretrained_model:null Global.pretrained_model:null
...@@ -39,11 +39,11 @@ infer_export:null ...@@ -39,11 +39,11 @@ infer_export:null
infer_quant:False infer_quant:False
inference:tools/infer/predict_rec.py inference:tools/infer/predict_rec.py
--use_gpu:True|False --use_gpu:True|False
--enable_mkldnn:True|False --enable_mkldnn:False
--cpu_threads:1|6 --cpu_threads:6
--rec_batch_num:1|6 --rec_batch_num:1|6
--use_tensorrt:False|True --use_tensorrt:False
--precision:fp32|int8 --precision:fp32
--rec_model_dir: --rec_model_dir:
--image_dir:./inference/rec_inference --image_dir:./inference/rec_inference
null:null null:null
......
===========================cpp_infer_params===========================
model_name:ch_PP-OCRv2_rec_KL
use_opencv:True
infer_model:./inference/ch_PP-OCRv2_rec_klquant_infer
infer_quant:False
inference:./deploy/cpp_infer/build/ppocr --rec_char_dict_path=./ppocr/utils/ppocr_keys_v1.txt --rec_img_h=32
--use_gpu:True|False
--enable_mkldnn:False
--cpu_threads:6
--rec_batch_num:6
--use_tensorrt:False
--precision:fp32
--rec_model_dir:
--image_dir:./inference/rec_inference/
null:null
--benchmark:True
--det:False
--rec:True
--cls:False
--use_angle_cls:False
\ No newline at end of file
===========================serving_params===========================
model_name:ch_PP-OCRv2_rec_KL
python:python3.7
trans_model:-m paddle_serving_client.convert
--det_dirname:./inference/ch_PP-OCRv2_det_klquant_infer/
--model_filename:inference.pdmodel
--params_filename:inference.pdiparams
--det_serving_server:./deploy/pdserving/ppocr_det_v2_kl_serving/
--det_serving_client:./deploy/pdserving/ppocr_det_v2_kl_client/
--rec_dirname:./inference/ch_PP-OCRv2_rec_klquant_infer/
--rec_serving_server:./deploy/pdserving/ppocr_rec_v2_kl_serving/
--rec_serving_client:./deploy/pdserving/ppocr_rec_v2_kl_client/
serving_dir:./deploy/pdserving
web_service:-m paddle_serving_server.serve
--op:GeneralDetectionOp GeneralInferOp
--port:8181
--gpu_id:"0"|null
cpp_client:ocr_cpp_client.py
--image_dir:../../doc/imgs/1.jpg
===========================serving_params===========================
model_name:ch_PP-OCRv2_rec_KL
python:python3.7
trans_model:-m paddle_serving_client.convert
--det_dirname:null
--model_filename:inference.pdmodel
--params_filename:inference.pdiparams
--det_serving_server:null
--det_serving_client:null
--rec_dirname:./inference/ch_PP-OCRv2_rec_klquant_infer/
--rec_serving_server:./deploy/pdserving/ppocr_rec_v2_kl_serving/
--rec_serving_client:./deploy/pdserving/ppocr_rec_v2_kl_client/
serving_dir:./deploy/pdserving
web_service:web_service_rec.py --config=config.yml --opt op.rec.concurrency="1"
op.det.local_service_conf.devices:gpu|null
op.det.local_service_conf.use_mkldnn:False
op.det.local_service_conf.thread_num:6
op.det.local_service_conf.use_trt:False
op.det.local_service_conf.precision:fp32
op.det.local_service_conf.model_config:
op.rec.local_service_conf.model_config:
pipline:pipeline_http_client.py --det=False
--image_dir:../../inference/rec_inference
===========================cpp_infer_params===========================
model_name:ch_PP-OCRv2_rec_PACT
use_opencv:True
infer_model:./inference/ch_PP-OCRv2_rec_pact_infer
infer_quant:False
inference:./deploy/cpp_infer/build/ppocr --rec_char_dict_path=./ppocr/utils/ppocr_keys_v1.txt --rec_img_h=32
--use_gpu:True|False
--enable_mkldnn:False
--cpu_threads:6
--rec_batch_num:6
--use_tensorrt:False
--precision:fp32
--rec_model_dir:
--image_dir:./inference/rec_inference/
null:null
--benchmark:True
--det:False
--rec:True
--cls:False
--use_angle_cls:False
\ No newline at end of file
===========================serving_params===========================
model_name:ch_PP-OCRv2_rec_PACT
python:python3.7
trans_model:-m paddle_serving_client.convert
--det_dirname:./inference/ch_PP-OCRv2_det_pact_infer/
--model_filename:inference.pdmodel
--params_filename:inference.pdiparams
--det_serving_server:./deploy/pdserving/ppocr_det_v2_pact_serving/
--det_serving_client:./deploy/pdserving/ppocr_det_v2_pact_client/
--rec_dirname:./inference/ch_PP-OCRv2_rec_pact_infer/
--rec_serving_server:./deploy/pdserving/ppocr_rec_v2_pact_serving/
--rec_serving_client:./deploy/pdserving/ppocr_rec_v2_pact_client/
serving_dir:./deploy/pdserving
web_service:-m paddle_serving_server.serve
--op:GeneralDetectionOp GeneralInferOp
--port:8181
--gpu_id:"0"|null
cpp_client:ocr_cpp_client.py
--image_dir:../../doc/imgs/1.jpg
===========================serving_params===========================
model_name:ch_PP-OCRv2_rec_PACT
python:python3.7
trans_model:-m paddle_serving_client.convert
--det_dirname:null
--model_filename:inference.pdmodel
--params_filename:inference.pdiparams
--det_serving_server:null
--det_serving_client:null
--rec_dirname:./inference/ch_PP-OCRv2_rec_pact_infer/
--rec_serving_server:./deploy/pdserving/ppocr_rec_v2_pact_serving/
--rec_serving_client:./deploy/pdserving/ppocr_rec_v2_pact_client/
serving_dir:./deploy/pdserving
web_service:web_service_rec.py --config=config.yml --opt op.rec.concurrency="1"
op.det.local_service_conf.devices:gpu|null
op.det.local_service_conf.use_mkldnn:False
op.det.local_service_conf.thread_num:6
op.det.local_service_conf.use_trt:False
op.det.local_service_conf.precision:fp32
op.det.local_service_conf.model_config:
op.rec.local_service_conf.model_config:
pipline:pipeline_http_client.py --det=False
--image_dir:../../inference/rec_inference
===========================train_params=========================== ===========================train_params===========================
model_name:ch_PPOCRv2_rec_PACT model_name:ch_PP-OCRv2_rec_PACT
python:python3.7 python:python3.7
gpu_list:0|0,1 gpu_list:0|0,1
Global.use_gpu:True|True Global.use_gpu:True|True
Global.auto_cast:amp Global.auto_cast:amp
Global.epoch_num:lite_train_lite_infer=3|whole_train_whole_infer=300 Global.epoch_num:lite_train_lite_infer=1|whole_train_whole_infer=50
Global.save_model_dir:./output/ Global.save_model_dir:./output/
Train.loader.batch_size_per_card:lite_train_lite_infer=16|whole_train_whole_infer=128 Train.loader.batch_size_per_card:lite_train_lite_infer=16|whole_train_whole_infer=128
Global.pretrained_model:null Global.pretrained_model:pretrain_models/ch_PP-OCRv2_rec_train/best_accuracy
train_model_name:latest train_model_name:latest
train_infer_img_dir:./inference/rec_inference train_infer_img_dir:./inference/rec_inference
null:null null:null
...@@ -39,11 +39,11 @@ infer_export:null ...@@ -39,11 +39,11 @@ infer_export:null
infer_quant:True infer_quant:True
inference:tools/infer/predict_rec.py inference:tools/infer/predict_rec.py
--use_gpu:True|False --use_gpu:True|False
--enable_mkldnn:True|False --enable_mkldnn:False
--cpu_threads:1|6 --cpu_threads:6
--rec_batch_num:1|6 --rec_batch_num:1|6
--use_tensorrt:False|True --use_tensorrt:False
--precision:fp32|int8 --precision:fp32
--rec_model_dir: --rec_model_dir:
--image_dir:./inference/rec_inference --image_dir:./inference/rec_inference
null:null null:null
......
...@@ -6,10 +6,10 @@ infer_export:null ...@@ -6,10 +6,10 @@ infer_export:null
infer_quant:False infer_quant:False
inference:tools/infer/predict_system.py --rec_image_shape="3,48,320" inference:tools/infer/predict_system.py --rec_image_shape="3,48,320"
--use_gpu:False|True --use_gpu:False|True
--enable_mkldnn:False|True --enable_mkldnn:False
--cpu_threads:1|6 --cpu_threads:6
--rec_batch_num:1 --rec_batch_num:1
--use_tensorrt:False|True --use_tensorrt:False
--precision:fp32 --precision:fp32
--det_model_dir: --det_model_dir:
--image_dir:./inference/ch_det_data_50/all-sum-510/ --image_dir:./inference/ch_det_data_50/all-sum-510/
......
...@@ -14,4 +14,4 @@ inference:tools/infer/predict_system.py --rec_image_shape="3,48,320" ...@@ -14,4 +14,4 @@ inference:tools/infer/predict_system.py --rec_image_shape="3,48,320"
--use_gpu:True|False --use_gpu:True|False
--det_model_dir: --det_model_dir:
--rec_model_dir: --rec_model_dir:
--image_dir:./inference/ch_det_data_50/all-sum-510/ --image_dir:./inference/ch_det_data_50/all-sum-510/00008790.jpg
\ No newline at end of file \ No newline at end of file
===========================serving_params===========================
model_name:ch_PP-OCRv3
python:python3.7
trans_model:-m paddle_serving_client.convert
--det_dirname:./inference/ch_PP-OCRv3_det_infer/
--model_filename:inference.pdmodel
--params_filename:inference.pdiparams
--det_serving_server:./deploy/pdserving/ppocr_det_v3_serving/
--det_serving_client:./deploy/pdserving/ppocr_det_v3_client/
--rec_dirname:./inference/ch_PP-OCRv3_rec_infer/
--rec_serving_server:./deploy/pdserving/ppocr_rec_v3_serving/
--rec_serving_client:./deploy/pdserving/ppocr_rec_v3_client/
serving_dir:./deploy/pdserving
web_service:-m paddle_serving_server.serve
--op:GeneralDetectionOp GeneralInferOp
--port:8181
--gpu_id:"0"|null
cpp_client:ocr_cpp_client.py
--image_dir:../../doc/imgs/1.jpg
===========================serving_params===========================
model_name:ch_PP-OCRv3
python:python3.7
trans_model:-m paddle_serving_client.convert
--det_dirname:./inference/ch_PP-OCRv3_det_infer/
--model_filename:inference.pdmodel
--params_filename:inference.pdiparams
--det_serving_server:./deploy/pdserving/ppocr_det_v3_serving/
--det_serving_client:./deploy/pdserving/ppocr_det_v3_client/
--rec_dirname:./inference/ch_PP-OCRv3_rec_infer/
--rec_serving_server:./deploy/pdserving/ppocr_rec_v3_serving/
--rec_serving_client:./deploy/pdserving/ppocr_rec_v3_client/
serving_dir:./deploy/pdserving
web_service:web_service.py --config=config.yml --opt op.det.concurrency="1" op.rec.concurrency="1"
op.det.local_service_conf.devices:gpu|null
op.det.local_service_conf.use_mkldnn:False
op.det.local_service_conf.thread_num:6
op.det.local_service_conf.use_trt:False
op.det.local_service_conf.precision:fp32
op.det.local_service_conf.model_config:
op.rec.local_service_conf.model_config:
pipline:pipeline_http_client.py
--image_dir:../../doc/imgs/1.jpg
===========================serving_params=========================== ===========================serving_params===========================
model_name:ocr_det_v3 model_name:ch_PP-OCRv3_det
python:python3.7 python:python3.7
trans_model:-m paddle_serving_client.convert trans_model:-m paddle_serving_client.convert
--dirname:./inference/ch_PP-OCRv3_det_infer/ --det_dirname:./inference/ch_PP-OCRv3_det_infer/
--model_filename:inference.pdmodel --model_filename:inference.pdmodel
--params_filename:inference.pdiparams --params_filename:inference.pdiparams
--serving_server:./deploy/pdserving/ppocr_det_v3_serving/ --det_serving_server:./deploy/pdserving/ppocr_det_v3_serving/
--serving_client:./deploy/pdserving/ppocr_det_v3_client/ --det_serving_client:./deploy/pdserving/ppocr_det_v3_client/
--rec_dirname:null
--rec_serving_server:null
--rec_serving_client:null
serving_dir:./deploy/pdserving serving_dir:./deploy/pdserving
web_service:web_service_det.py --config=config.yml --opt op.det.concurrency="1" web_service:web_service_det.py --config=config.yml --opt op.det.concurrency="1"
op.det.local_service_conf.devices:gpu|null op.det.local_service_conf.devices:gpu|null
op.det.local_service_conf.use_mkldnn:True|False op.det.local_service_conf.use_mkldnn:False
op.det.local_service_conf.thread_num:1|6 op.det.local_service_conf.thread_num:6
op.det.local_service_conf.use_trt:False|True op.det.local_service_conf.use_trt:False
op.det.local_service_conf.precision:fp32|fp16|int8 op.det.local_service_conf.precision:fp32
pipline:pipeline_rpc_client.py|pipeline_http_client.py op.det.local_service_conf.model_config:
--image_dir:../../doc/imgs op.rec.local_service_conf.model_config:
pipline:pipeline_http_client.py
--image_dir:../../doc/imgs/1.jpg
===========================train_params===========================
model_name:ch_PP-OCRv3_det
python:python3.7
gpu_list:192.168.0.1,192.168.0.2;0,1
Global.use_gpu:True
Global.auto_cast:fp32
Global.epoch_num:lite_train_lite_infer=1|whole_train_whole_infer=50
Global.save_model_dir:./output/
Train.loader.batch_size_per_card:lite_train_lite_infer=2|whole_train_whole_infer=4
Global.pretrained_model:null
train_model_name:latest
train_infer_img_dir:./train_data/icdar2015/text_localization/ch4_test_images/
null:null
##
trainer:norm_train
norm_train:tools/train.py -c configs/det/ch_PP-OCRv3/ch_PP-OCRv3_det_cml.yml -o
pact_train:null
fpgm_train:null
distill_train:null
null:null
null:null
##
===========================eval_params===========================
eval:null
null:null
##
===========================infer_params===========================
Global.save_inference_dir:./output/
Global.checkpoints:
norm_export:tools/export_model.py -c configs/det/ch_PP-OCRv3/ch_PP-OCRv3_det_cml.yml -o
quant_export:null
fpgm_export:
distill_export:null
export1:null
export2:null
inference_dir:Student
infer_model:./inference/ch_PP-OCRv3_det_infer/
infer_export:null
infer_quant:False
inference:tools/infer/predict_det.py
--use_gpu:False
--enable_mkldnn:False
--cpu_threads:6
--rec_batch_num:1
--use_tensorrt:False
--precision:fp32
--det_model_dir:
--image_dir:./inference/ch_det_data_50/all-sum-510/
null:null
--benchmark:True
null:null
===========================infer_benchmark_params==========================
random_infer_input:[{float32,[3,640,640]}];[{float32,[3,960,960]}]
===========================train_params=========================== ===========================train_params===========================
model_name:ch_PPOCRv3_det model_name:ch_PP-OCRv3_det
python:python3.7 python:python3.7
gpu_list:0|0,1 gpu_list:0|0,1
Global.use_gpu:True|True Global.use_gpu:True|True
Global.auto_cast:amp Global.auto_cast:amp
Global.epoch_num:lite_train_lite_infer=1|whole_train_whole_infer=500 Global.epoch_num:lite_train_lite_infer=1|whole_train_whole_infer=50
Global.save_model_dir:./output/ Global.save_model_dir:./output/
Train.loader.batch_size_per_card:lite_train_lite_infer=2|whole_train_whole_infer=4 Train.loader.batch_size_per_card:lite_train_lite_infer=2|whole_train_whole_infer=4
Global.pretrained_model:null Global.pretrained_model:null
...@@ -39,11 +39,11 @@ infer_export:null ...@@ -39,11 +39,11 @@ infer_export:null
infer_quant:False infer_quant:False
inference:tools/infer/predict_det.py inference:tools/infer/predict_det.py
--use_gpu:True|False --use_gpu:True|False
--enable_mkldnn:True|False --enable_mkldnn:False
--cpu_threads:1|6 --cpu_threads:6
--rec_batch_num:1 --rec_batch_num:1
--use_tensorrt:False|True --use_tensorrt:False
--precision:fp32|fp16|int8 --precision:fp32
--det_model_dir: --det_model_dir:
--image_dir:./inference/ch_det_data_50/all-sum-510/ --image_dir:./inference/ch_det_data_50/all-sum-510/
null:null null:null
......
===========================cpp_infer_params===========================
model_name:ch_PP-OCRv3_det_KL
use_opencv:True
infer_model:./inference/ch_PP-OCRv3_det_klquant_infer
infer_quant:False
inference:./deploy/cpp_infer/build/ppocr
--use_gpu:True|False
--enable_mkldnn:False
--cpu_threads:6
--rec_batch_num:1
--use_tensorrt:False
--precision:fp32
--det_model_dir:
--image_dir:./inference/ch_det_data_50/all-sum-510/
null:null
--benchmark:True
--det:True
--rec:False
--cls:False
--use_angle_cls:False
\ No newline at end of file
===========================serving_params===========================
model_name:ch_PP-OCRv3_det_KL
python:python3.7
trans_model:-m paddle_serving_client.convert
--det_dirname:./inference/ch_PP-OCRv3_det_klquant_infer/
--model_filename:inference.pdmodel
--params_filename:inference.pdiparams
--det_serving_server:./deploy/pdserving/ppocr_det_v3_kl_serving/
--det_serving_client:./deploy/pdserving/ppocr_det_v3_kl_client/
--rec_dirname:./inference/ch_PP-OCRv3_rec_klquant_infer/
--rec_serving_server:./deploy/pdserving/ppocr_rec_v3_kl_serving/
--rec_serving_client:./deploy/pdserving/ppocr_rec_v3_kl_client/
serving_dir:./deploy/pdserving
web_service:-m paddle_serving_server.serve
--op:GeneralDetectionOp GeneralInferOp
--port:8181
--gpu_id:"0"|null
cpp_client:ocr_cpp_client.py
--image_dir:../../doc/imgs/1.jpg
===========================serving_params===========================
model_name:ch_PP-OCRv3_det_KL
python:python3.7
trans_model:-m paddle_serving_client.convert
--det_dirname:./inference/ch_PP-OCRv3_det_klquant_infer/
--model_filename:inference.pdmodel
--params_filename:inference.pdiparams
--det_serving_server:./deploy/pdserving/ppocr_det_v3_kl_serving/
--det_serving_client:./deploy/pdserving/ppocr_det_v3_kl_client/
--rec_dirname:null
--rec_serving_server:null
--rec_serving_client:null
serving_dir:./deploy/pdserving
web_service:web_service_det.py --config=config.yml --opt op.det.concurrency="1"
op.det.local_service_conf.devices:gpu|null
op.det.local_service_conf.use_mkldnn:False
op.det.local_service_conf.thread_num:6
op.det.local_service_conf.use_trt:False
op.det.local_service_conf.precision:fp32
op.det.local_service_conf.model_config:
op.rec.local_service_conf.model_config:
pipline:pipeline_http_client.py
--image_dir:../../doc/imgs/1.jpg
===========================cpp_infer_params===========================
model_name:ch_PP-OCRv3_det_PACT
use_opencv:True
infer_model:./inference/ch_PP-OCRv3_det_pact_infer
infer_quant:False
inference:./deploy/cpp_infer/build/ppocr
--use_gpu:True|False
--enable_mkldnn:False
--cpu_threads:6
--rec_batch_num:1
--use_tensorrt:False
--precision:fp32
--det_model_dir:
--image_dir:./inference/ch_det_data_50/all-sum-510/
null:null
--benchmark:True
--det:True
--rec:False
--cls:False
--use_angle_cls:False
\ No newline at end of file
===========================serving_params===========================
model_name:ch_PP-OCRv3_det_PACT
python:python3.7
trans_model:-m paddle_serving_client.convert
--det_dirname:./inference/ch_PP-OCRv3_det_pact_infer/
--model_filename:inference.pdmodel
--params_filename:inference.pdiparams
--det_serving_server:./deploy/pdserving/ppocr_det_v3_pact_serving/
--det_serving_client:./deploy/pdserving/ppocr_det_v3_pact_client/
--rec_dirname:./inference/ch_PP-OCRv3_rec_pact_infer/
--rec_serving_server:./deploy/pdserving/ppocr_rec_v3_pact_serving/
--rec_serving_client:./deploy/pdserving/ppocr_rec_v3_pact_client/
serving_dir:./deploy/pdserving
web_service:-m paddle_serving_server.serve
--op:GeneralDetectionOp GeneralInferOp
--port:8181
--gpu_id:"0"|null
cpp_client:ocr_cpp_client.py
--image_dir:../../doc/imgs/1.jpg
===========================serving_params===========================
model_name:ch_PP-OCRv3_det_PACT
python:python3.7
trans_model:-m paddle_serving_client.convert
--det_dirname:./inference/ch_PP-OCRv3_det_pact_infer/
--model_filename:inference.pdmodel
--params_filename:inference.pdiparams
--det_serving_server:./deploy/pdserving/ppocr_det_v3_pact_serving/
--det_serving_client:./deploy/pdserving/ppocr_det_v3_pact_client/
--rec_dirname:null
--rec_serving_server:null
--rec_serving_client:null
serving_dir:./deploy/pdserving
web_service:web_service_det.py --config=config.yml --opt op.det.concurrency="1"
op.det.local_service_conf.devices:gpu|null
op.det.local_service_conf.use_mkldnn:False
op.det.local_service_conf.thread_num:6
op.det.local_service_conf.use_trt:False
op.det.local_service_conf.precision:fp32
op.det.local_service_conf.model_config:
op.rec.local_service_conf.model_config:
pipline:pipeline_http_client.py
--image_dir:../../doc/imgs/1.jpg
===========================train_params=========================== ===========================train_params===========================
model_name:ch_PPOCRv3_det_PACT model_name:ch_PP-OCRv3_det_PACT
python:python3.7 python:python3.7
gpu_list:0|0,1 gpu_list:0|0,1
Global.use_gpu:True|True Global.use_gpu:True|True
Global.auto_cast:amp Global.auto_cast:amp
Global.epoch_num:lite_train_lite_infer=1|whole_train_whole_infer=500 Global.epoch_num:lite_train_lite_infer=1|whole_train_whole_infer=50
Global.save_model_dir:./output/ Global.save_model_dir:./output/
Train.loader.batch_size_per_card:lite_train_lite_infer=2|whole_train_whole_infer=4 Train.loader.batch_size_per_card:lite_train_lite_infer=2|whole_train_whole_infer=4
Global.pretrained_model:null Global.pretrained_model:null
...@@ -39,11 +39,11 @@ infer_export:null ...@@ -39,11 +39,11 @@ infer_export:null
infer_quant:False infer_quant:False
inference:tools/infer/predict_det.py inference:tools/infer/predict_det.py
--use_gpu:True|False --use_gpu:True|False
--enable_mkldnn:True|False --enable_mkldnn:False
--cpu_threads:1|6 --cpu_threads:6
--rec_batch_num:1 --rec_batch_num:1
--use_tensorrt:False|True --use_tensorrt:False
--precision:fp32|fp16|int8 --precision:fp32
--det_model_dir: --det_model_dir:
--image_dir:./inference/ch_det_data_50/all-sum-510/ --image_dir:./inference/ch_det_data_50/all-sum-510/
null:null null:null
......
...@@ -153,7 +153,7 @@ Train: ...@@ -153,7 +153,7 @@ Train:
data_dir: ./train_data/ic15_data/ data_dir: ./train_data/ic15_data/
ext_op_transform_idx: 1 ext_op_transform_idx: 1
label_file_list: label_file_list:
- ./train_data/ic15_data/rec_gt_train.txt - ./train_data/ic15_data/rec_gt_train_lite.txt
transforms: transforms:
- DecodeImage: - DecodeImage:
img_mode: BGR img_mode: BGR
...@@ -183,7 +183,7 @@ Eval: ...@@ -183,7 +183,7 @@ Eval:
name: SimpleDataSet name: SimpleDataSet
data_dir: ./train_data/ic15_data data_dir: ./train_data/ic15_data
label_file_list: label_file_list:
- ./train_data/ic15_data/rec_gt_test.txt - ./train_data/ic15_data/rec_gt_test_lite.txt
transforms: transforms:
- DecodeImage: - DecodeImage:
img_mode: BGR img_mode: BGR
......
===========================serving_params=========================== ===========================serving_params===========================
model_name:ocr_rec_v3 model_name:ch_PP-OCRv3_rec
python:python3.7 python:python3.7
trans_model:-m paddle_serving_client.convert trans_model:-m paddle_serving_client.convert
--dirname:./inference/ch_PP-OCRv3_rec_infer/ --det_dirname:null
--model_filename:inference.pdmodel --model_filename:inference.pdmodel
--params_filename:inference.pdiparams --params_filename:inference.pdiparams
--serving_server:./deploy/pdserving/ppocr_rec_v3_serving/ --det_serving_server:null
--serving_client:./deploy/pdserving/ppocr_rec_v3_client/ --det_serving_client:null
--rec_dirname:./inference/ch_PP-OCRv3_rec_infer/
--rec_serving_server:./deploy/pdserving/ppocr_rec_v3_serving/
--rec_serving_client:./deploy/pdserving/ppocr_rec_v3_client/
serving_dir:./deploy/pdserving serving_dir:./deploy/pdserving
web_service:web_service_rec.py --config=config.yml --opt op.rec.concurrency="1" web_service:web_service_rec.py --config=config.yml --opt op.rec.concurrency="1"
op.rec.local_service_conf.devices:gpu|null op.det.local_service_conf.devices:gpu|null
op.rec.local_service_conf.use_mkldnn:False op.det.local_service_conf.use_mkldnn:False
op.rec.local_service_conf.thread_num:1|6 op.det.local_service_conf.thread_num:6
op.rec.local_service_conf.use_trt:False|True op.det.local_service_conf.use_trt:False
op.rec.local_service_conf.precision:fp32|fp16|int8 op.det.local_service_conf.precision:fp32
pipline:pipeline_rpc_client.py|pipeline_http_client.py op.det.local_service_conf.model_config:
op.rec.local_service_conf.model_config:
pipline:pipeline_http_client.py --det=False
--image_dir:../../inference/rec_inference --image_dir:../../inference/rec_inference
===========================train_params===========================
model_name:ch_PP-OCRv3_rec
python:python3.7
gpu_list:192.168.0.1,192.168.0.2;0,1
Global.use_gpu:True
Global.auto_cast:fp32
Global.epoch_num:lite_train_lite_infer=3|whole_train_whole_infer=50
Global.save_model_dir:./output/
Train.loader.batch_size_per_card:lite_train_lite_infer=16|whole_train_whole_infer=64
Global.pretrained_model:null
train_model_name:latest
train_infer_img_dir:./inference/rec_inference
null:null
##
trainer:norm_train
norm_train:tools/train.py -c test_tipc/configs/ch_PP-OCRv3_rec/ch_PP-OCRv3_rec_distillation.yml -o
pact_train:null
fpgm_train:null
distill_train:null
null:null
null:null
##
===========================eval_params===========================
eval:null
null:null
##
===========================infer_params===========================
Global.save_inference_dir:./output/
Global.checkpoints:
norm_export:tools/export_model.py -c test_tipc/configs/ch_PP-OCRv3_rec/ch_PP-OCRv3_rec_distillation.yml -o
quant_export:
fpgm_export:
distill_export:null
export1:null
export2:null
inference_dir:Student
infer_model:./inference/ch_PP-OCRv3_rec_infer
infer_export:null
infer_quant:False
inference:tools/infer/predict_rec.py --rec_image_shape="3,48,320"
--use_gpu:False
--enable_mkldnn:False
--cpu_threads:6
--rec_batch_num:1|6
--use_tensorrt:False
--precision:fp32
--rec_model_dir:
--image_dir:./inference/rec_inference
null:null
--benchmark:True
null:null
===========================infer_benchmark_params==========================
random_infer_input:[{float32,[3,48,320]}]
===========================train_params=========================== ===========================train_params===========================
model_name:PPOCRv3_ocr_rec model_name:ch_PP-OCRv3_rec
python:python3.7 python:python3.7
gpu_list:0|0,1 gpu_list:0|0,1
Global.use_gpu:True|True Global.use_gpu:True|True
Global.auto_cast:amp Global.auto_cast:amp
Global.epoch_num:lite_train_lite_infer=3|whole_train_whole_infer=300 Global.epoch_num:lite_train_lite_infer=1|whole_train_whole_infer=50
Global.save_model_dir:./output/ Global.save_model_dir:./output/
Train.loader.batch_size_per_card:lite_train_lite_infer=16|whole_train_whole_infer=128 Train.loader.batch_size_per_card:lite_train_lite_infer=16|whole_train_whole_infer=128
Global.pretrained_model:null Global.pretrained_model:null
...@@ -39,11 +39,11 @@ infer_export:null ...@@ -39,11 +39,11 @@ infer_export:null
infer_quant:False infer_quant:False
inference:tools/infer/predict_rec.py --rec_image_shape="3,48,320" inference:tools/infer/predict_rec.py --rec_image_shape="3,48,320"
--use_gpu:True|False --use_gpu:True|False
--enable_mkldnn:True|False --enable_mkldnn:False
--cpu_threads:1|6 --cpu_threads:6
--rec_batch_num:1|6 --rec_batch_num:6
--use_tensorrt:False|True --use_tensorrt:False
--precision:fp32|int8 --precision:fp32
--rec_model_dir: --rec_model_dir:
--image_dir:./inference/rec_inference --image_dir:./inference/rec_inference
null:null null:null
......
===========================cpp_infer_params===========================
model_name:ch_PP-OCRv3_rec_KL
use_opencv:True
infer_model:./inference/ch_PP-OCRv3_rec_klquant_infer
infer_quant:False
inference:./deploy/cpp_infer/build/ppocr --rec_img_h=48 --rec_char_dict_path=./ppocr/utils/ppocr_keys_v1.txt
--use_gpu:True|False
--enable_mkldnn:False
--cpu_threads:6
--rec_batch_num:6
--use_tensorrt:False
--precision:fp32
--rec_model_dir:
--image_dir:./inference/rec_inference/
null:null
--benchmark:True
--det:False
--rec:True
--cls:False
--use_angle_cls:False
\ No newline at end of file
===========================serving_params===========================
model_name:ch_PP-OCRv3_rec_KL
python:python3.7
trans_model:-m paddle_serving_client.convert
--det_dirname:./inference/ch_PP-OCRv3_det_klquant_infer/
--model_filename:inference.pdmodel
--params_filename:inference.pdiparams
--det_serving_server:./deploy/pdserving/ppocr_det_v3_kl_serving/
--det_serving_client:./deploy/pdserving/ppocr_det_v3_kl_client/
--rec_dirname:./inference/ch_PP-OCRv3_rec_klquant_infer/
--rec_serving_server:./deploy/pdserving/ppocr_rec_v3_kl_serving/
--rec_serving_client:./deploy/pdserving/ppocr_rec_v3_kl_client/
serving_dir:./deploy/pdserving
web_service:-m paddle_serving_server.serve
--op:GeneralDetectionOp GeneralInferOp
--port:8181
--gpu_id:"0"|null
cpp_client:ocr_cpp_client.py
--image_dir:../../doc/imgs/1.jpg
===========================serving_params===========================
model_name:ch_PP-OCRv3_rec_KL
python:python3.7
trans_model:-m paddle_serving_client.convert
--det_dirname:null
--model_filename:inference.pdmodel
--params_filename:inference.pdiparams
--det_serving_server:null
--det_serving_client:null
--rec_dirname:./inference/ch_PP-OCRv3_rec_klquant_infer/
--rec_serving_server:./deploy/pdserving/ppocr_rec_v3_kl_serving/
--rec_serving_client:./deploy/pdserving/ppocr_rec_v3_kl_client/
serving_dir:./deploy/pdserving
web_service:web_service_rec.py --config=config.yml --opt op.rec.concurrency="1"
op.det.local_service_conf.devices:gpu|null
op.det.local_service_conf.use_mkldnn:False
op.det.local_service_conf.thread_num:6
op.det.local_service_conf.use_trt:False
op.det.local_service_conf.precision:fp32
op.det.local_service_conf.model_config:
op.rec.local_service_conf.model_config:
pipline:pipeline_http_client.py --det=False
--image_dir:../../inference/rec_inference
===========================cpp_infer_params===========================
model_name:ch_PP-OCRv3_rec_PACT
use_opencv:True
infer_model:./inference/ch_PP-OCRv3_rec_pact_infer
infer_quant:False
inference:./deploy/cpp_infer/build/ppocr --rec_img_h=48 --rec_char_dict_path=./ppocr/utils/ppocr_keys_v1.txt
--use_gpu:True|False
--enable_mkldnn:False
--cpu_threads:6
--rec_batch_num:6
--use_tensorrt:False
--precision:fp32
--rec_model_dir:
--image_dir:./inference/rec_inference/
null:null
--benchmark:True
--det:False
--rec:True
--cls:False
--use_angle_cls:False
\ No newline at end of file
===========================serving_params===========================
model_name:ch_PP-OCRv3_rec_PACT
python:python3.7
trans_model:-m paddle_serving_client.convert
--det_dirname:./inference/ch_PP-OCRv3_det_pact_infer/
--model_filename:inference.pdmodel
--params_filename:inference.pdiparams
--det_serving_server:./deploy/pdserving/ppocr_det_v3_pact_serving/
--det_serving_client:./deploy/pdserving/ppocr_det_v3_pact_client/
--rec_dirname:./inference/ch_PP-OCRv3_rec_pact_infer/
--rec_serving_server:./deploy/pdserving/ppocr_rec_v3_pact_serving/
--rec_serving_client:./deploy/pdserving/ppocr_rec_v3_pact_client/
serving_dir:./deploy/pdserving
web_service:-m paddle_serving_server.serve
--op:GeneralDetectionOp GeneralInferOp
--port:8181
--gpu_id:"0"|null
cpp_client:ocr_cpp_client.py
--image_dir:../../doc/imgs/1.jpg
===========================serving_params===========================
model_name:ch_PP-OCRv3_rec_PACT
python:python3.7
trans_model:-m paddle_serving_client.convert
--det_dirname:null
--model_filename:inference.pdmodel
--params_filename:inference.pdiparams
--det_serving_server:null
--det_serving_client:null
--rec_dirname:./inference/ch_PP-OCRv3_rec_pact_infer/
--rec_serving_server:./deploy/pdserving/ppocr_rec_v3_pact_serving/
--rec_serving_client:./deploy/pdserving/ppocr_rec_v3_pact_client/
serving_dir:./deploy/pdserving
web_service:web_service_rec.py --config=config.yml --opt op.rec.concurrency="1"
op.det.local_service_conf.devices:gpu|null
op.det.local_service_conf.use_mkldnn:False
op.det.local_service_conf.thread_num:6
op.det.local_service_conf.use_trt:False
op.det.local_service_conf.precision:fp32
op.det.local_service_conf.model_config:
op.rec.local_service_conf.model_config:
pipline:pipeline_http_client.py --det=False
--image_dir:../../inference/rec_inference
===========================train_params=========================== ===========================train_params===========================
model_name:ch_PPOCRv3_rec_PACT model_name:ch_PP-OCRv3_rec_PACT
python:python3.7 python:python3.7
gpu_list:0|0,1 gpu_list:0|0,1
Global.use_gpu:True|True Global.use_gpu:True|True
Global.auto_cast:amp Global.auto_cast:amp
Global.epoch_num:lite_train_lite_infer=3|whole_train_whole_infer=300 Global.epoch_num:lite_train_lite_infer=1|whole_train_whole_infer=50
Global.save_model_dir:./output/ Global.save_model_dir:./output/
Train.loader.batch_size_per_card:lite_train_lite_infer=16|whole_train_whole_infer=128 Train.loader.batch_size_per_card:lite_train_lite_infer=16|whole_train_whole_infer=128
Global.pretrained_model:null Global.pretrained_model:pretrain_models/ch_PP-OCRv3_rec_train/best_accuracy
train_model_name:latest train_model_name:latest
train_infer_img_dir:./inference/rec_inference train_infer_img_dir:./inference/rec_inference
null:null null:null
...@@ -39,11 +39,11 @@ infer_export:null ...@@ -39,11 +39,11 @@ infer_export:null
infer_quant:True infer_quant:True
inference:tools/infer/predict_rec.py --rec_image_shape="3,48,320" inference:tools/infer/predict_rec.py --rec_image_shape="3,48,320"
--use_gpu:True|False --use_gpu:True|False
--enable_mkldnn:True|False --enable_mkldnn:False
--cpu_threads:1|6 --cpu_threads:6
--rec_batch_num:1|6 --rec_batch_num:6
--use_tensorrt:False|True --use_tensorrt:False
--precision:fp32|int8 --precision:fp32
--rec_model_dir: --rec_model_dir:
--image_dir:./inference/rec_inference --image_dir:./inference/rec_inference
null:null null:null
......
...@@ -3,7 +3,7 @@ model_name:ch_ppocr_mobile_v2.0 ...@@ -3,7 +3,7 @@ model_name:ch_ppocr_mobile_v2.0
use_opencv:True use_opencv:True
infer_model:./inference/ch_ppocr_mobile_v2.0_det_infer/ infer_model:./inference/ch_ppocr_mobile_v2.0_det_infer/
infer_quant:False infer_quant:False
inference:./deploy/cpp_infer/build/ppocr --rec_char_dict_path=./ppocr/utils/ppocr_keys_v1.txt inference:./deploy/cpp_infer/build/ppocr --rec_char_dict_path=./ppocr/utils/ppocr_keys_v1.txt --rec_img_h=32
--use_gpu:True|False --use_gpu:True|False
--enable_mkldnn:False --enable_mkldnn:False
--cpu_threads:6 --cpu_threads:6
......
...@@ -6,10 +6,10 @@ infer_export:null ...@@ -6,10 +6,10 @@ infer_export:null
infer_quant:False infer_quant:False
inference:tools/infer/predict_system.py inference:tools/infer/predict_system.py
--use_gpu:False|True --use_gpu:False|True
--enable_mkldnn:False|True --enable_mkldnn:False
--cpu_threads:1|6 --cpu_threads:6
--rec_batch_num:1 --rec_batch_num:1
--use_tensorrt:False|True --use_tensorrt:False
--precision:fp32 --precision:fp32
--det_model_dir: --det_model_dir:
--image_dir:./inference/ch_det_data_50/all-sum-510/ --image_dir:./inference/ch_det_data_50/all-sum-510/
......
===========================serving_params===========================
model_name:ch_ppocr_mobile_v2.0
python:python3.7
trans_model:-m paddle_serving_client.convert
--det_dirname:./inference/ch_ppocr_mobile_v2.0_det_infer/
--model_filename:inference.pdmodel
--params_filename:inference.pdiparams
--det_serving_server:./deploy/pdserving/ppocr_det_mobile_serving/
--det_serving_client:./deploy/pdserving/ppocr_det_mobile_client/
--rec_dirname:./inference/ch_ppocr_mobile_v2.0_rec_infer/
--rec_serving_server:./deploy/pdserving/ppocr_rec_mobile_serving/
--rec_serving_client:./deploy/pdserving/ppocr_rec_mobile_client/
serving_dir:./deploy/pdserving
web_service:-m paddle_serving_server.serve
--op:GeneralDetectionOp GeneralInferOp
--port:8181
--gpu_id:"0"|null
cpp_client:ocr_cpp_client.py
--image_dir:../../doc/imgs/1.jpg
===========================serving_params===========================
model_name:ch_ppocr_mobile_v2.0
python:python3.7
trans_model:-m paddle_serving_client.convert
--det_dirname:./inference/ch_ppocr_mobile_v2.0_det_infer/
--model_filename:inference.pdmodel
--params_filename:inference.pdiparams
--det_serving_server:./deploy/pdserving/ppocr_det_mobile_serving/
--det_serving_client:./deploy/pdserving/ppocr_det_mobile_client/
--rec_dirname:./inference/ch_ppocr_mobile_v2.0_rec_infer/
--rec_serving_server:./deploy/pdserving/ppocr_rec_mobile_serving/
--rec_serving_client:./deploy/pdserving/ppocr_rec_mobile_client/
serving_dir:./deploy/pdserving
web_service:web_service.py --config=config.yml --opt op.det.concurrency="1" op.rec.concurrency="1"
op.det.local_service_conf.devices:gpu|null
op.det.local_service_conf.use_mkldnn:False
op.det.local_service_conf.thread_num:6
op.det.local_service_conf.use_trt:False
op.det.local_service_conf.precision:fp32
op.det.local_service_conf.model_config:
op.rec.local_service_conf.model_config:
pipline:pipeline_http_client.py
--image_dir:../../doc/imgs/1.jpg
===========================infer_params=========================== ===========================infer_params===========================
model_name:ocr_det model_name:ch_ppocr_mobile_v2.0_det
python:python python:python
infer_model:./inference/ch_ppocr_mobile_v2.0_det_infer infer_model:./inference/ch_ppocr_mobile_v2.0_det_infer
infer_export:null infer_export:null
...@@ -7,10 +7,10 @@ infer_quant:False ...@@ -7,10 +7,10 @@ infer_quant:False
inference:tools/infer/predict_det.py inference:tools/infer/predict_det.py
--use_gpu:True|False --use_gpu:True|False
--enable_mkldnn:False --enable_mkldnn:False
--cpu_threads:1|6 --cpu_threads:6
--rec_batch_num:1 --rec_batch_num:1
--use_tensorrt:False|True --use_tensorrt:False
--precision:fp16|fp32 --precision:fp32
--det_model_dir: --det_model_dir:
--image_dir:./inference/ch_det_data_50/all-sum-510/ --image_dir:./inference/ch_det_data_50/all-sum-510/
null:null null:null
......
===========================serving_params=========================== ===========================serving_params===========================
model_name:ocr_det_mobile model_name:ch_ppocr_mobile_v2.0_det
python:python3.7|cpp python:python3.7
trans_model:-m paddle_serving_client.convert trans_model:-m paddle_serving_client.convert
--dirname:./inference/ch_ppocr_mobile_v2.0_det_infer/ --det_dirname:./inference/ch_ppocr_mobile_v2.0_det_infer/
--model_filename:inference.pdmodel --model_filename:inference.pdmodel
--params_filename:inference.pdiparams --params_filename:inference.pdiparams
--serving_server:./deploy/pdserving/ppocr_det_mobile_2.0_serving/ --det_serving_server:./deploy/pdserving/ppocr_det_mobile_serving/
--serving_client:./deploy/pdserving/ppocr_det_mobile_2.0_client/ --det_serving_client:./deploy/pdserving/ppocr_det_mobile_client/
--rec_dirname:null
--rec_serving_server:null
--rec_serving_client:null
serving_dir:./deploy/pdserving serving_dir:./deploy/pdserving
web_service:web_service_det.py --config=config.yml --opt op.det.concurrency="1" web_service:web_service_det.py --config=config.yml --opt op.det.concurrency="1"
op.det.local_service_conf.devices:gpu|null op.det.local_service_conf.devices:gpu|null
op.det.local_service_conf.use_mkldnn:True|False op.det.local_service_conf.use_mkldnn:False
op.det.local_service_conf.thread_num:1|6 op.det.local_service_conf.thread_num:6
op.det.local_service_conf.use_trt:False|True op.det.local_service_conf.use_trt:False
op.det.local_service_conf.precision:fp32|fp16|int8 op.det.local_service_conf.precision:fp32
pipline:pipeline_rpc_client.py|pipeline_http_client.py op.det.local_service_conf.model_config:
--image_dir:../../doc/imgs op.rec.local_service_conf.model_config:
pipline:pipeline_http_client.py
--image_dir:../../doc/imgs/1.jpg
===========================train_params=========================== ===========================train_params===========================
model_name:ocr_det model_name:ch_ppocr_mobile_v2.0_det
python:python3.7 python:python3.7
gpu_list:xx.xx.xx.xx,yy.yy.yy.yy;0,1 gpu_list:192.168.0.1,192.168.0.2;0,1
Global.use_gpu:True Global.use_gpu:True
Global.auto_cast:fp32|amp Global.auto_cast:null
Global.epoch_num:lite_train_lite_infer=1|whole_train_whole_infer=300 Global.epoch_num:lite_train_lite_infer=100|whole_train_whole_infer=50
Global.save_model_dir:./output/ Global.save_model_dir:./output/
Train.loader.batch_size_per_card:lite_train_lite_infer=2|whole_train_whole_infer=4 Train.loader.batch_size_per_card:lite_train_lite_infer=2|whole_train_whole_infer=4
Global.pretrained_model:null Global.pretrained_model:null
...@@ -12,10 +12,10 @@ train_model_name:latest ...@@ -12,10 +12,10 @@ train_model_name:latest
train_infer_img_dir:./train_data/icdar2015/text_localization/ch4_test_images/ train_infer_img_dir:./train_data/icdar2015/text_localization/ch4_test_images/
null:null null:null
## ##
trainer:norm_train|pact_train|fpgm_train trainer:norm_train
norm_train:tools/train.py -c test_tipc/configs/ppocr_det_mobile/det_mv3_db.yml -o Global.pretrained_model=./pretrain_models/MobileNetV3_large_x0_5_pretrained norm_train:tools/train.py -c configs/det/ch_ppocr_v2.0/ch_det_mv3_db_v2.0.yml -o Global.pretrained_model=./pretrain_models/MobileNetV3_large_x0_5_pretrained
pact_train:deploy/slim/quantization/quant.py -c test_tipc/configs/ppocr_det_mobile/det_mv3_db.yml -o pact_train:null
fpgm_train:deploy/slim/prune/sensitivity_anal.py -c test_tipc/configs/ppocr_det_mobile/det_mv3_db.yml -o Global.pretrained_model=./pretrain_models/det_mv3_db_v2.0_train/best_accuracy fpgm_train:null
distill_train:null distill_train:null
null:null null:null
null:null null:null
...@@ -26,10 +26,10 @@ null:null ...@@ -26,10 +26,10 @@ null:null
## ##
===========================infer_params=========================== ===========================infer_params===========================
Global.save_inference_dir:./output/ Global.save_inference_dir:./output/
Global.pretrained_model: Global.checkpoints:
norm_export:tools/export_model.py -c test_tipc/configs/ppocr_det_mobile/det_mv3_db.yml -o norm_export:tools/export_model.py -c configs/det/ch_ppocr_v2.0/ch_det_mv3_db_v2.0.yml -o
quant_export:deploy/slim/quantization/export_model.py -c test_tipc/configs/ppocr_det_mobile/det_mv3_db.yml -o quant_export:null
fpgm_export:deploy/slim/prune/export_prune_model.py -c test_tipc/configs/ppocr_det_mobile/det_mv3_db.yml -o fpgm_export:null
distill_export:null distill_export:null
export1:null export1:null
export2:null export2:null
...@@ -38,14 +38,16 @@ train_model:./inference/ch_ppocr_mobile_v2.0_det_train/best_accuracy ...@@ -38,14 +38,16 @@ train_model:./inference/ch_ppocr_mobile_v2.0_det_train/best_accuracy
infer_export:tools/export_model.py -c configs/det/ch_ppocr_v2.0/ch_det_mv3_db_v2.0.yml -o infer_export:tools/export_model.py -c configs/det/ch_ppocr_v2.0/ch_det_mv3_db_v2.0.yml -o
infer_quant:False infer_quant:False
inference:tools/infer/predict_det.py inference:tools/infer/predict_det.py
--use_gpu:True|False --use_gpu:False
--enable_mkldnn:True|False --enable_mkldnn:False
--cpu_threads:1|6 --cpu_threads:6
--rec_batch_num:1 --rec_batch_num:1
--use_tensorrt:False|True --use_tensorrt:False
--precision:fp32|fp16|int8 --precision:fp32
--det_model_dir: --det_model_dir:
--image_dir:./inference/ch_det_data_50/all-sum-510/ --image_dir:./inference/ch_det_data_50/all-sum-510/
null:null null:null
--benchmark:True --benchmark:True
null:null null:null
===========================infer_benchmark_params==========================
random_infer_input:[{float32,[3,640,640]}];[{float32,[3,960,960]}]
\ No newline at end of file
...@@ -4,7 +4,7 @@ python:python3.7 ...@@ -4,7 +4,7 @@ python:python3.7
gpu_list:0|0,1 gpu_list:0|0,1
Global.use_gpu:True|True Global.use_gpu:True|True
Global.auto_cast:amp Global.auto_cast:amp
Global.epoch_num:lite_train_lite_infer=100|whole_train_whole_infer=300 Global.epoch_num:lite_train_lite_infer=100|whole_train_whole_infer=50
Global.save_model_dir:./output/ Global.save_model_dir:./output/
Train.loader.batch_size_per_card:lite_train_lite_infer=2|whole_train_whole_infer=4 Train.loader.batch_size_per_card:lite_train_lite_infer=2|whole_train_whole_infer=4
Global.pretrained_model:null Global.pretrained_model:null
...@@ -39,11 +39,11 @@ infer_export:tools/export_model.py -c configs/det/ch_ppocr_v2.0/ch_det_mv3_db_v2 ...@@ -39,11 +39,11 @@ infer_export:tools/export_model.py -c configs/det/ch_ppocr_v2.0/ch_det_mv3_db_v2
infer_quant:False infer_quant:False
inference:tools/infer/predict_det.py inference:tools/infer/predict_det.py
--use_gpu:True|False --use_gpu:True|False
--enable_mkldnn:True|False --enable_mkldnn:False
--cpu_threads:1|6 --cpu_threads:6
--rec_batch_num:1 --rec_batch_num:1
--use_tensorrt:False|True --use_tensorrt:False
--precision:fp32|fp16|int8 --precision:fp32
--det_model_dir: --det_model_dir:
--image_dir:./inference/ch_det_data_50/all-sum-510/ --image_dir:./inference/ch_det_data_50/all-sum-510/
null:null null:null
......
...@@ -4,7 +4,7 @@ python:python ...@@ -4,7 +4,7 @@ python:python
gpu_list:-1 gpu_list:-1
Global.use_gpu:False Global.use_gpu:False
Global.auto_cast:null Global.auto_cast:null
Global.epoch_num:lite_train_lite_infer=5|whole_train_whole_infer=300 Global.epoch_num:lite_train_lite_infer=5|whole_train_whole_infer=50
Global.save_model_dir:./output/ Global.save_model_dir:./output/
Train.loader.batch_size_per_card:lite_train_lite_infer=2|whole_train_whole_infer=4 Train.loader.batch_size_per_card:lite_train_lite_infer=2|whole_train_whole_infer=4
Global.pretrained_model:null Global.pretrained_model:null
......
...@@ -4,7 +4,7 @@ python:python ...@@ -4,7 +4,7 @@ python:python
gpu_list:0 gpu_list:0
Global.use_gpu:True Global.use_gpu:True
Global.auto_cast:fp32|amp Global.auto_cast:fp32|amp
Global.epoch_num:lite_train_lite_infer=5|whole_train_whole_infer=300 Global.epoch_num:lite_train_lite_infer=5|whole_train_whole_infer=50
Global.save_model_dir:./output/ Global.save_model_dir:./output/
Train.loader.batch_size_per_card:lite_train_lite_infer=2|whole_train_whole_infer=4 Train.loader.batch_size_per_card:lite_train_lite_infer=2|whole_train_whole_infer=4
Global.pretrained_model:null Global.pretrained_model:null
...@@ -39,10 +39,10 @@ infer_export:tools/export_model.py -c configs/det/ch_ppocr_v2.0/ch_det_mv3_db_v2 ...@@ -39,10 +39,10 @@ infer_export:tools/export_model.py -c configs/det/ch_ppocr_v2.0/ch_det_mv3_db_v2
infer_quant:False infer_quant:False
inference:tools/infer/predict_det.py inference:tools/infer/predict_det.py
--use_gpu:True|False --use_gpu:True|False
--enable_mkldnn:True|False --enable_mkldnn:False
--cpu_threads:1|6 --cpu_threads:1|6
--rec_batch_num:1 --rec_batch_num:1
--use_tensorrt:False|True --use_tensorrt:False
--precision:fp32|fp16|int8 --precision:fp32|fp16|int8
--det_model_dir: --det_model_dir:
--image_dir:./inference/ch_det_data_50/all-sum-510/ --image_dir:./inference/ch_det_data_50/all-sum-510/
......
...@@ -4,7 +4,7 @@ python:python3.7 ...@@ -4,7 +4,7 @@ python:python3.7
gpu_list:0|0,1 gpu_list:0|0,1
Global.use_gpu:True|True Global.use_gpu:True|True
Global.auto_cast:amp Global.auto_cast:amp
Global.epoch_num:lite_train_lite_infer=5|whole_train_whole_infer=300 Global.epoch_num:lite_train_lite_infer=5|whole_train_whole_infer=50
Global.save_model_dir:./output/ Global.save_model_dir:./output/
Train.loader.batch_size_per_card:lite_train_lite_infer=2|whole_train_whole_infer=4 Train.loader.batch_size_per_card:lite_train_lite_infer=2|whole_train_whole_infer=4
Global.pretrained_model:null Global.pretrained_model:null
...@@ -39,11 +39,11 @@ infer_export:null ...@@ -39,11 +39,11 @@ infer_export:null
infer_quant:False infer_quant:False
inference:tools/infer/predict_det.py inference:tools/infer/predict_det.py
--use_gpu:True|False --use_gpu:True|False
--enable_mkldnn:True|False --enable_mkldnn:False
--cpu_threads:1|6 --cpu_threads:6
--rec_batch_num:1 --rec_batch_num:1
--use_tensorrt:False|True --use_tensorrt:False
--precision:fp32|fp16|int8 --precision:fp32
--det_model_dir: --det_model_dir:
--image_dir:./inference/ch_det_data_50/all-sum-510/ --image_dir:./inference/ch_det_data_50/all-sum-510/
null:null null:null
......
===========================cpp_infer_params===========================
model_name:ch_ppocr_mobile_v2.0_det_KL
use_opencv:True
infer_model:./inference/ch_ppocr_mobile_v2.0_det_klquant_infer
infer_quant:False
inference:./deploy/cpp_infer/build/ppocr
--use_gpu:True|False
--enable_mkldnn:False
--cpu_threads:6
--rec_batch_num:1
--use_tensorrt:False
--precision:fp32
--det_model_dir:
--image_dir:./inference/ch_det_data_50/all-sum-510/
null:null
--benchmark:True
--det:True
--rec:False
--cls:False
--use_angle_cls:False
\ No newline at end of file
===========================serving_params===========================
model_name:ch_ppocr_mobile_v2.0_det_KL
python:python3.7
trans_model:-m paddle_serving_client.convert
--det_dirname:./inference/ch_ppocr_mobile_v2.0_det_klquant_infer/
--model_filename:inference.pdmodel
--params_filename:inference.pdiparams
--det_serving_server:./deploy/pdserving/ppocr_det_mobile_kl_serving/
--det_serving_client:./deploy/pdserving/ppocr_det_mobile_kl_client/
--rec_dirname:./inference/ch_ppocr_mobile_v2.0_rec_klquant_infer/
--rec_serving_server:./deploy/pdserving/ppocr_rec_mobile_kl_serving/
--rec_serving_client:./deploy/pdserving/ppocr_rec_mobile_kl_client/
serving_dir:./deploy/pdserving
web_service:-m paddle_serving_server.serve
--op:GeneralDetectionOp GeneralInferOp
--port:8181
--gpu_id:"0"|null
cpp_client:ocr_cpp_client.py
--image_dir:../../doc/imgs/1.jpg
===========================serving_params===========================
model_name:ch_ppocr_mobile_v2.0_det_KL
python:python3.7
trans_model:-m paddle_serving_client.convert
--det_dirname:./inference/ch_ppocr_mobile_v2.0_det_klquant_infer/
--model_filename:inference.pdmodel
--params_filename:inference.pdiparams
--det_serving_server:./deploy/pdserving/ppocr_det_mobile_kl_serving/
--det_serving_client:./deploy/pdserving/ppocr_det_mobile_kl_client/
--rec_dirname:null
--rec_serving_server:null
--rec_serving_client:null
serving_dir:./deploy/pdserving
web_service:web_service_det.py --config=config.yml --opt op.det.concurrency="1"
op.det.local_service_conf.devices:gpu|null
op.det.local_service_conf.use_mkldnn:False
op.det.local_service_conf.thread_num:6
op.det.local_service_conf.use_trt:False
op.det.local_service_conf.precision:fp32
op.det.local_service_conf.model_config:
op.rec.local_service_conf.model_config:
pipline:pipeline_http_client.py
--image_dir:../../doc/imgs/1.jpg
===========================cpp_infer_params===========================
model_name:ch_ppocr_mobile_v2.0_det_PACT
use_opencv:True
infer_model:./inference/ch_ppocr_mobile_v2.0_det_pact_infer
infer_quant:False
inference:./deploy/cpp_infer/build/ppocr
--use_gpu:True|False
--enable_mkldnn:False
--cpu_threads:6
--rec_batch_num:1
--use_tensorrt:False
--precision:fp32
--det_model_dir:
--image_dir:./inference/ch_det_data_50/all-sum-510/
null:null
--benchmark:True
--det:True
--rec:False
--cls:False
--use_angle_cls:False
\ No newline at end of file
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册