Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
聚火科技码农
PaddleOCR
提交
e4a939cb
P
PaddleOCR
项目概览
聚火科技码农
/
PaddleOCR
与 Fork 源项目一致
Fork自
PaddlePaddle / PaddleOCR
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleOCR
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
e4a939cb
编写于
7月 06, 2021
作者:
L
LDOUBLEV
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update test_ci to v6
上级
b10f12a2
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
95 addition
and
79 deletion
+95
-79
test/ocr_det_params.txt
test/ocr_det_params.txt
+8
-8
test/prepare.sh
test/prepare.sh
+8
-6
test/test.sh
test/test.sh
+79
-65
未找到文件。
test/ocr_det_params.txt
浏览文件 @
e4a939cb
model_name:ocr_det
python:python3.7
gpu_list:0|0,1
Global.auto_cast:
False
Global.auto_cast:
null
Global.epoch_num:10
Global.save_model_dir:./output/
Global.save_inference_dir:./output/
Train.loader.batch_size_per_card:
Global.use_gpu
Global.pretrained_model
Global.use_gpu
:
Global.pretrained_model
:null
trainer:norm|pact
norm_train:tools/train.py -c configs/det/det_mv3_db.yml -o Global.pretrained_model=./pretrain_models/MobileNetV3_large_x0_5_pretrained
...
...
@@ -17,6 +16,8 @@ distill_train:null
eval:tools/eval.py -c configs/det/det_mv3_db.yml -o
Global.save_inference_dir:./output/
Global.checkpoints:
norm_export:tools/export_model.py -c configs/det/det_mv3_db.yml -o
quant_export:deploy/slim/quantization/export_model.py -c configs/det/det_mv3_db.yml -o
fpgm_export:deploy/slim/prune/export_prune_model.py
...
...
@@ -29,7 +30,6 @@ inference:tools/infer/predict_det.py
--rec_batch_num:1
--use_tensorrt:True|False
--precision:fp32|fp16|int8
--det_model_dir
--image_dir
--save_log_path
--det_model_dir:./inference/ch_ppocr_mobile_v2.0_det_infer/
--image_dir:./inference/ch_det_data_50/all-sum-510/
--save_log_path:./test/output/
test/prepare.sh
浏览文件 @
e4a939cb
...
...
@@ -26,8 +26,10 @@ IFS=$'\n'
# The training params
model_name
=
$(
func_parser_value
"
${
lines
[0]
}
"
)
train_model_list
=
$(
func_parser_value
"
${
lines
[0]
}
"
)
trainer_list
=
$(
func_parser_value
"
${
lines
[10]
}
"
)
# MODE be one of ['lite_train_infer' 'whole_infer' 'whole_train_infer']
MODE
=
$2
# prepare pretrained weights and dataset
...
...
@@ -62,8 +64,8 @@ else
rm
-rf
./train_data/icdar2015
wget
-nc
-P
./train_data https://paddleocr.bj.bcebos.com/dygraph_v2.0/test/ch_det_data_50.tar
if
[
${
model_name
}
=
"ocr_det"
]
;
then
eval_model_name
=
"ch_ppocr_mobile_v2.0_det_
train
"
wget
-nc
-P
./inference https://paddleocr.bj.bcebos.com/dygraph_v2.0/ch/ch_ppocr_mobile_v2.0_det_
train
.tar
eval_model_name
=
"ch_ppocr_mobile_v2.0_det_
infer
"
wget
-nc
-P
./inference https://paddleocr.bj.bcebos.com/dygraph_v2.0/ch/ch_ppocr_mobile_v2.0_det_
infer
.tar
cd
./inference
&&
tar
xf
${
eval_model_name
}
.tar
&&
cd
../
else
eval_model_name
=
"ch_ppocr_mobile_v2.0_rec_train"
...
...
@@ -94,7 +96,7 @@ for train_model in ${train_model_list[*]}; do
# eval
for
slim_trainer
in
${
trainer_list
[*]
}
;
do
if
[
${
slim_trainer
}
=
"norm"
]
;
then
if
[
${
model_name
}
=
"
ocr_
det"
]
;
then
if
[
${
model_name
}
=
"det"
]
;
then
eval_model_name
=
"ch_ppocr_mobile_v2.0_det_train"
wget
-nc
-P
./inference https://paddleocr.bj.bcebos.com/dygraph_v2.0/ch/ch_ppocr_mobile_v2.0_det_train.tar
cd
./inference
&&
tar
xf
${
eval_model_name
}
.tar
&&
cd
../
...
...
@@ -104,7 +106,7 @@ for train_model in ${train_model_list[*]}; do
cd
./inference
&&
tar
xf
${
eval_model_name
}
.tar
&&
cd
../
fi
elif
[
${
slim_trainer
}
=
"pact"
]
;
then
if
[
${
model_name
}
=
"
ocr_
det"
]
;
then
if
[
${
model_name
}
=
"det"
]
;
then
eval_model_name
=
"ch_ppocr_mobile_v2.0_det_quant_train"
wget
-nc
-P
./inference https://paddleocr.bj.bcebos.com/dygraph_v2.0/slim/ch_ppocr_mobile_v2.0_det_quant_train.tar
cd
./inference
&&
tar
xf
${
eval_model_name
}
.tar
&&
cd
../
...
...
@@ -114,7 +116,7 @@ for train_model in ${train_model_list[*]}; do
cd
./inference
&&
tar
xf
${
eval_model_name
}
.tar
&&
cd
../
fi
elif
[
${
slim_trainer
}
=
"distill"
]
;
then
if
[
${
model_name
}
=
"
ocr_
det"
]
;
then
if
[
${
model_name
}
=
"det"
]
;
then
eval_model_name
=
"ch_ppocr_mobile_v2.0_det_distill_train"
wget
-nc
-P
./inference https://paddleocr.bj.bcebos.com/dygraph_v2.0/slim/ch_ppocr_mobile_v2.0_det_distill_train.tar
cd
./inference
&&
tar
xf
${
eval_model_name
}
.tar
&&
cd
../
...
...
@@ -124,7 +126,7 @@ for train_model in ${train_model_list[*]}; do
cd
./inference
&&
tar
xf
${
eval_model_name
}
.tar
&&
cd
../
fi
elif
[
${
slim_trainer
}
=
"fpgm"
]
;
then
if
[
${
model_name
}
=
"
ocr_
det"
]
;
then
if
[
${
model_name
}
=
"det"
]
;
then
eval_model_name
=
"ch_ppocr_mobile_v2.0_det_prune_train"
wget
-nc
-P
./inference https://paddleocr.bj.bcebos.com/dygraph_v2.0/slim/ch_ppocr_mobile_v2.0_det_prune_train.tar
cd
./inference
&&
tar
xf
${
eval_model_name
}
.tar
&&
cd
../
...
...
test/test.sh
浏览文件 @
e4a939cb
...
...
@@ -41,59 +41,51 @@ gpu_list=$(func_parser_value "${lines[2]}")
autocast_list
=
$(
func_parser_value
"
${
lines
[3]
}
"
)
autocast_key
=
$(
func_parser_key
"
${
lines
[3]
}
"
)
epoch_key
=
$(
func_parser_key
"
${
lines
[4]
}
"
)
epoch_num
=
$(
func_parser_value
"
${
lines
[4]
}
"
)
save_model_key
=
$(
func_parser_key
"
${
lines
[5]
}
"
)
save_infer_key
=
$(
func_parser_key
"
${
lines
[6]
}
"
)
train_batch_key
=
$(
func_parser_key
"
${
lines
[7]
}
"
)
train_use_gpu_key
=
$(
func_parser_key
"
${
lines
[8]
}
"
)
pretrain_model_key
=
$(
func_parser_key
"
${
lines
[9]
}
"
)
trainer_list
=
$(
func_parser_value
"
${
lines
[10]
}
"
)
norm_trainer
=
$(
func_parser_value
"
${
lines
[11]
}
"
)
pact_trainer
=
$(
func_parser_value
"
${
lines
[12]
}
"
)
fpgm_trainer
=
$(
func_parser_value
"
${
lines
[13]
}
"
)
distill_trainer
=
$(
func_parser_value
"
${
lines
[14]
}
"
)
eval_py
=
$(
func_parser_value
"
${
lines
[15]
}
"
)
norm_export
=
$(
func_parser_value
"
${
lines
[16]
}
"
)
pact_export
=
$(
func_parser_value
"
${
lines
[17]
}
"
)
fpgm_export
=
$(
func_parser_value
"
${
lines
[18]
}
"
)
distill_export
=
$(
func_parser_value
"
${
lines
[19]
}
"
)
inference_py
=
$(
func_parser_value
"
${
lines
[20]
}
"
)
use_gpu_key
=
$(
func_parser_key
"
${
lines
[21]
}
"
)
use_gpu_list
=
$(
func_parser_value
"
${
lines
[21]
}
"
)
use_mkldnn_key
=
$(
func_parser_key
"
${
lines
[22]
}
"
)
use_mkldnn_list
=
$(
func_parser_value
"
${
lines
[22]
}
"
)
cpu_threads_key
=
$(
func_parser_key
"
${
lines
[23]
}
"
)
cpu_threads_list
=
$(
func_parser_value
"
${
lines
[23]
}
"
)
batch_size_key
=
$(
func_parser_key
"
${
lines
[24]
}
"
)
batch_size_list
=
$(
func_parser_value
"
${
lines
[24]
}
"
)
use_trt_key
=
$(
func_parser_key
"
${
lines
[25]
}
"
)
use_trt_list
=
$(
func_parser_value
"
${
lines
[25]
}
"
)
precision_key
=
$(
func_parser_key
"
${
lines
[26]
}
"
)
precision_list
=
$(
func_parser_value
"
${
lines
[26]
}
"
)
model_dir_key
=
$(
func_parser_key
"
${
lines
[27]
}
"
)
image_dir_key
=
$(
func_parser_key
"
${
lines
[28]
}
"
)
save_log_key
=
$(
func_parser_key
"
${
lines
[29]
}
"
)
train_batch_key
=
$(
func_parser_key
"
${
lines
[6]
}
"
)
train_use_gpu_key
=
$(
func_parser_key
"
${
lines
[7]
}
"
)
pretrain_model_key
=
$(
func_parser_key
"
${
lines
[8]
}
"
)
pretrain_model_value
=
$(
func_parser_value
"
${
lines
[8]
}
"
)
trainer_list
=
$(
func_parser_value
"
${
lines
[9]
}
"
)
norm_trainer
=
$(
func_parser_value
"
${
lines
[10]
}
"
)
pact_trainer
=
$(
func_parser_value
"
${
lines
[11]
}
"
)
fpgm_trainer
=
$(
func_parser_value
"
${
lines
[12]
}
"
)
distill_trainer
=
$(
func_parser_value
"
${
lines
[13]
}
"
)
eval_py
=
$(
func_parser_value
"
${
lines
[14]
}
"
)
save_infer_key
=
$(
func_parser_key
"
${
lines
[15]
}
"
)
export_weight
=
$(
func_parser_key
"
${
lines
[16]
}
"
)
norm_export
=
$(
func_parser_value
"
${
lines
[17]
}
"
)
pact_export
=
$(
func_parser_value
"
${
lines
[18]
}
"
)
fpgm_export
=
$(
func_parser_value
"
${
lines
[19]
}
"
)
distill_export
=
$(
func_parser_value
"
${
lines
[20]
}
"
)
inference_py
=
$(
func_parser_value
"
${
lines
[21]
}
"
)
use_gpu_key
=
$(
func_parser_key
"
${
lines
[22]
}
"
)
use_gpu_list
=
$(
func_parser_value
"
${
lines
[22]
}
"
)
use_mkldnn_key
=
$(
func_parser_key
"
${
lines
[23]
}
"
)
use_mkldnn_list
=
$(
func_parser_value
"
${
lines
[23]
}
"
)
cpu_threads_key
=
$(
func_parser_key
"
${
lines
[24]
}
"
)
cpu_threads_list
=
$(
func_parser_value
"
${
lines
[24]
}
"
)
batch_size_key
=
$(
func_parser_key
"
${
lines
[25]
}
"
)
batch_size_list
=
$(
func_parser_value
"
${
lines
[25]
}
"
)
use_trt_key
=
$(
func_parser_key
"
${
lines
[26]
}
"
)
use_trt_list
=
$(
func_parser_value
"
${
lines
[26]
}
"
)
precision_key
=
$(
func_parser_key
"
${
lines
[27]
}
"
)
precision_list
=
$(
func_parser_value
"
${
lines
[27]
}
"
)
infer_model_key
=
$(
func_parser_key
"
${
lines
[28]
}
"
)
infer_model
=
$(
func_parser_value
"
${
lines
[28]
}
"
)
image_dir_key
=
$(
func_parser_key
"
${
lines
[29]
}
"
)
infer_img_dir
=
$(
func_parser_value
"
${
lines
[29]
}
"
)
save_log_key
=
$(
func_parser_key
"
${
lines
[30]
}
"
)
LOG_PATH
=
"./test/output"
mkdir
-p
${
LOG_PATH
}
status_log
=
"
${
LOG_PATH
}
/results.log"
if
[
${
MODE
}
=
"lite_train_infer"
]
;
then
export
infer_img_dir
=
"./train_data/icdar2015/text_localization/ch4_test_images/"
export
epoch_num
=
10
elif
[
${
MODE
}
=
"whole_infer"
]
;
then
export
infer_img_dir
=
"./train_data/icdar2015/text_localization/ch4_test_images/"
export
epoch_num
=
10
elif
[
${
MODE
}
=
"whole_train_infer"
]
;
then
export
infer_img_dir
=
"./train_data/icdar2015/text_localization/ch4_test_images/"
export
epoch_num
=
300
else
export
infer_img_dir
=
"./inference/ch_det_data_50/all-sum-510"
export
infer_model_dir
=
"./inference/ch_ppocr_mobile_v2.0_det_train/best_accuracy"
fi
function
func_inference
(){
IFS
=
'|'
...
...
@@ -110,7 +102,7 @@ function func_inference(){
for
threads
in
${
cpu_threads_list
[*]
}
;
do
for
batch_size
in
${
batch_size_list
[*]
}
;
do
_save_log_path
=
"
${
_log_path
}
/infer_cpu_usemkldnn_
${
use_mkldnn
}
_threads_
${
threads
}
_batchsize_
${
batch_size
}
"
command
=
"
${
_python
}
${
_script
}
${
use_gpu_key
}
=
${
use_gpu
}
${
use_mkldnn_key
}
=
${
use_mkldnn
}
${
cpu_threads_key
}
=
${
threads
}
${
model_dir
_key
}
=
${
_model_dir
}
${
batch_size_key
}
=
${
batch_size
}
${
image_dir_key
}
=
${
_img_dir
}
${
save_log_key
}
=
${
_save_log_path
}
--benchmark=True"
command
=
"
${
_python
}
${
_script
}
${
use_gpu_key
}
=
${
use_gpu
}
${
use_mkldnn_key
}
=
${
use_mkldnn
}
${
cpu_threads_key
}
=
${
threads
}
${
infer_model
_key
}
=
${
_model_dir
}
${
batch_size_key
}
=
${
batch_size
}
${
image_dir_key
}
=
${
_img_dir
}
${
save_log_key
}
=
${
_save_log_path
}
--benchmark=True"
eval
$command
status_check
$?
"
${
command
}
"
"
${
status_log
}
"
done
...
...
@@ -124,7 +116,7 @@ function func_inference(){
fi
for
batch_size
in
${
batch_size_list
[*]
}
;
do
_save_log_path
=
"
${
_log_path
}
/infer_gpu_usetrt_
${
use_trt
}
_precision_
${
precision
}
_batchsize_
${
batch_size
}
"
command
=
"
${
_python
}
${
_script
}
${
use_gpu_key
}
=
${
use_gpu
}
${
use_trt_key
}
=
${
use_trt
}
${
precision_key
}
=
${
precision
}
${
model_dir_key
}
=
${
_model_dir
}
${
batch_size_key
}
=
${
batch_size
}
${
image_dir_key
}
=
${
_img_dir
}
${
save_log_key
}
=
${
_save_log_path
}
--benchmark=True"
command
=
"
${
_python
}
${
_script
}
${
use_gpu_key
}
=
${
use_gpu
}
${
use_trt_key
}
=
${
use_trt
}
${
precision_key
}
=
${
precision
}
${
infer_model_key
}
=
${
_model_dir
}
${
batch_size_key
}
=
${
batch_size
}
${
image_dir_key
}
=
${
_img_dir
}
${
save_log_key
}
=
${
_save_log_path
}
--benchmark=True"
eval
$command
status_check
$?
"
${
command
}
"
"
${
status_log
}
"
done
...
...
@@ -138,9 +130,9 @@ if [ ${MODE} != "infer" ]; then
IFS
=
"|"
for
gpu
in
${
gpu_list
[*]
}
;
do
train_
use_gpu
=
True
use_gpu
=
True
if
[
${
gpu
}
=
"-1"
]
;
then
train_
use_gpu
=
False
use_gpu
=
False
env
=
""
elif
[
${#
gpu
}
-le
1
]
;
then
env
=
"export CUDA_VISIBLE_DEVICES=
${
gpu
}
"
...
...
@@ -155,6 +147,7 @@ for gpu in ${gpu_list[*]}; do
ips
=
${
array
[0]
}
gpu
=
${
array
[1]
}
IFS
=
"|"
env
=
" "
fi
for
autocast
in
${
autocast_list
[*]
}
;
do
for
trainer
in
${
trainer_list
[*]
}
;
do
...
...
@@ -179,13 +172,32 @@ for gpu in ${gpu_list[*]}; do
continue
fi
save_log
=
"
${
LOG_PATH
}
/
${
trainer
}
_gpus_
${
gpu
}
_autocast_
${
autocast
}
"
if
[
${#
gpu
}
-le
2
]
;
then
# epoch_num #TODO
cmd
=
"
${
python
}
${
run_train
}
${
train_use_gpu_key
}
=
${
train_use_gpu
}
${
autocast_key
}
=
${
autocast
}
${
epoch_key
}
=
${
epoch_num
}
${
save_model_key
}
=
${
save_log
}
"
elif
[
${#
gpu
}
-le
15
]
;
then
cmd
=
"
${
python
}
-m paddle.distributed.launch --gpus=
${
gpu
}
${
run_train
}
${
autocast_key
}
=
${
autocast
}
${
epoch_key
}
=
${
epoch_num
}
${
save_model_key
}
=
${
save_log
}
"
# not set autocast when autocast is null
if
[
${
autocast
}
=
"null"
]
;
then
set_autocast
=
" "
else
set_autocast
=
"
${
autocast_key
}
=
${
autocast
}
"
fi
# not set epoch when whole_train_infer
if
[
${
MODE
}
!=
"whole_train_infer"
]
;
then
set_epoch
=
"
${
epoch_key
}
=
${
epoch_num
}
"
else
set_epoch
=
" "
fi
# set pretrain
if
[
${
pretrain_model_value
}
!=
"null"
]
;
then
set_pretrain
=
"
${
pretrain_model_key
}
=
${
pretrain_model_value
}
"
else
cmd
=
"
${
python
}
-m paddle.distributed.launch --ips=
${
ips
}
--gpus=
${
gpu
}
${
run_train
}
${
autocast_key
}
=
${
autocast
}
${
epoch_key
}
=
${
epoch_num
}
${
save_model_key
}
=
${
save_log
}
"
set_pretrain
=
" "
fi
save_log
=
"
${
LOG_PATH
}
/
${
trainer
}
_gpus_
${
gpu
}
_autocast_
${
autocast
}
"
if
[
${#
gpu
}
-le
2
]
;
then
# train with cpu or single gpu
cmd
=
"
${
python
}
${
run_train
}
${
train_use_gpu_key
}
=
${
use_gpu
}
${
save_model_key
}
=
${
save_log
}
${
set_epoch
}
${
set_pretrain
}
${
set_autocast
}
"
elif
[
${#
gpu
}
-le
15
]
;
then
# train with multi-gpu
cmd
=
"
${
python
}
-m paddle.distributed.launch --gpus=
${
gpu
}
${
run_train
}
${
save_model_key
}
=
${
save_log
}
${
set_epoch
}
${
set_pretrain
}
${
set_autocast
}
"
else
# train with multi-machine
cmd
=
"
${
python
}
-m paddle.distributed.launch --ips=
${
ips
}
--gpus=
${
gpu
}
${
run_train
}
${
save_model_key
}
=
${
save_log
}
${
set_pretrain
}
${
set_epoch
}
${
set_autocast
}
"
fi
# run train
eval
$cmd
...
...
@@ -198,11 +210,12 @@ for gpu in ${gpu_list[*]}; do
# run export model
save_infer_path
=
"
${
save_log
}
"
export_cmd
=
"
${
python
}
${
run_export
}
${
save_model_key
}
=
${
save_log
}
${
pretrain_model_key
}
=
${
save_log
}
/latest
${
save_infer_key
}
=
${
save_infer_path
}
"
export_cmd
=
"
${
python
}
${
run_export
}
${
save_model_key
}
=
${
save_log
}
${
export_weight
}
=
${
save_log
}
/latest
${
save_infer_key
}
=
${
save_infer_path
}
"
eval
$export_cmd
status_check
$?
"
${
export_cmd
}
"
"
${
status_log
}
"
#run inference
echo
$env
save_infer_path
=
"
${
save_log
}
"
func_inference
"
${
python
}
"
"
${
inference_py
}
"
"
${
save_infer_path
}
"
"
${
LOG_PATH
}
"
"
${
infer_img_dir
}
"
done
...
...
@@ -210,12 +223,13 @@ for gpu in ${gpu_list[*]}; do
done
else
save_infer_path
=
"
${
LOG_PATH
}
/
${
MODE
}
"
run_export
=
${
norm_export
}
export_cmd
=
"
${
python
}
${
run_export
}
${
save_model_key
}
=
${
save_infer_path
}
${
pretrain_model_key
}
=
${
infer_model_dir
}
${
save_infer_key
}
=
${
save_infer_path
}
"
eval
$export_cmd
status_check
$?
"
${
export_cmd
}
"
"
${
status_log
}
"
GPUID
=
$3
if
[
${#
GPUID
}
-le
0
]
;
then
env
=
" "
else
env
=
"export CUDA_VISIBLE_DEVICES=
${
GPUID
}
"
fi
echo
$env
#run inference
func_inference
"
${
python
}
"
"
${
inference_py
}
"
"
${
save_infer_path
}
"
"
${
LOG_PATH
}
"
"
${
infer_img_dir
}
"
func_inference
"
${
python
}
"
"
${
inference_py
}
"
"
${
infer_model
}
"
"
${
LOG_PATH
}
"
"
${
infer_img_dir
}
"
fi
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录