提交 e4a939cb 编写于 作者: L LDOUBLEV

update test_ci to v6

上级 b10f12a2
model_name:ocr_det model_name:ocr_det
python:python3.7 python:python3.7
gpu_list:0|0,1 gpu_list:0|0,1
Global.auto_cast:False Global.auto_cast:null
Global.epoch_num:10 Global.epoch_num:10
Global.save_model_dir:./output/ Global.save_model_dir:./output/
Global.save_inference_dir:./output/
Train.loader.batch_size_per_card: Train.loader.batch_size_per_card:
Global.use_gpu Global.use_gpu:
Global.pretrained_model Global.pretrained_model:null
trainer:norm|pact 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 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 ...@@ -17,6 +16,8 @@ distill_train:null
eval:tools/eval.py -c configs/det/det_mv3_db.yml -o 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 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 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 fpgm_export:deploy/slim/prune/export_prune_model.py
...@@ -29,7 +30,6 @@ inference:tools/infer/predict_det.py ...@@ -29,7 +30,6 @@ inference:tools/infer/predict_det.py
--rec_batch_num:1 --rec_batch_num:1
--use_tensorrt:True|False --use_tensorrt:True|False
--precision:fp32|fp16|int8 --precision:fp32|fp16|int8
--det_model_dir --det_model_dir:./inference/ch_ppocr_mobile_v2.0_det_infer/
--image_dir --image_dir:./inference/ch_det_data_50/all-sum-510/
--save_log_path --save_log_path:./test/output/
...@@ -26,8 +26,10 @@ IFS=$'\n' ...@@ -26,8 +26,10 @@ IFS=$'\n'
# The training params # The training params
model_name=$(func_parser_value "${lines[0]}") model_name=$(func_parser_value "${lines[0]}")
train_model_list=$(func_parser_value "${lines[0]}") train_model_list=$(func_parser_value "${lines[0]}")
trainer_list=$(func_parser_value "${lines[10]}") trainer_list=$(func_parser_value "${lines[10]}")
# MODE be one of ['lite_train_infer' 'whole_infer' 'whole_train_infer'] # MODE be one of ['lite_train_infer' 'whole_infer' 'whole_train_infer']
MODE=$2 MODE=$2
# prepare pretrained weights and dataset # prepare pretrained weights and dataset
...@@ -62,8 +64,8 @@ else ...@@ -62,8 +64,8 @@ else
rm -rf ./train_data/icdar2015 rm -rf ./train_data/icdar2015
wget -nc -P ./train_data https://paddleocr.bj.bcebos.com/dygraph_v2.0/test/ch_det_data_50.tar 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 if [ ${model_name} = "ocr_det" ]; then
eval_model_name="ch_ppocr_mobile_v2.0_det_train" 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_train.tar 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 ../ cd ./inference && tar xf ${eval_model_name}.tar && cd ../
else else
eval_model_name="ch_ppocr_mobile_v2.0_rec_train" eval_model_name="ch_ppocr_mobile_v2.0_rec_train"
...@@ -94,7 +96,7 @@ for train_model in ${train_model_list[*]}; do ...@@ -94,7 +96,7 @@ for train_model in ${train_model_list[*]}; do
# eval # eval
for slim_trainer in ${trainer_list[*]}; do for slim_trainer in ${trainer_list[*]}; do
if [ ${slim_trainer} = "norm" ]; then 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" 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 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 ../ cd ./inference && tar xf ${eval_model_name}.tar && cd ../
...@@ -104,7 +106,7 @@ for train_model in ${train_model_list[*]}; do ...@@ -104,7 +106,7 @@ for train_model in ${train_model_list[*]}; do
cd ./inference && tar xf ${eval_model_name}.tar && cd ../ cd ./inference && tar xf ${eval_model_name}.tar && cd ../
fi fi
elif [ ${slim_trainer} = "pact" ]; then 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" 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 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 ../ cd ./inference && tar xf ${eval_model_name}.tar && cd ../
...@@ -114,7 +116,7 @@ for train_model in ${train_model_list[*]}; do ...@@ -114,7 +116,7 @@ for train_model in ${train_model_list[*]}; do
cd ./inference && tar xf ${eval_model_name}.tar && cd ../ cd ./inference && tar xf ${eval_model_name}.tar && cd ../
fi fi
elif [ ${slim_trainer} = "distill" ]; then 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" 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 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 ../ cd ./inference && tar xf ${eval_model_name}.tar && cd ../
...@@ -124,7 +126,7 @@ for train_model in ${train_model_list[*]}; do ...@@ -124,7 +126,7 @@ for train_model in ${train_model_list[*]}; do
cd ./inference && tar xf ${eval_model_name}.tar && cd ../ cd ./inference && tar xf ${eval_model_name}.tar && cd ../
fi fi
elif [ ${slim_trainer} = "fpgm" ]; then 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" 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 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 ../ cd ./inference && tar xf ${eval_model_name}.tar && cd ../
......
...@@ -41,59 +41,51 @@ gpu_list=$(func_parser_value "${lines[2]}") ...@@ -41,59 +41,51 @@ gpu_list=$(func_parser_value "${lines[2]}")
autocast_list=$(func_parser_value "${lines[3]}") autocast_list=$(func_parser_value "${lines[3]}")
autocast_key=$(func_parser_key "${lines[3]}") autocast_key=$(func_parser_key "${lines[3]}")
epoch_key=$(func_parser_key "${lines[4]}") epoch_key=$(func_parser_key "${lines[4]}")
epoch_num=$(func_parser_value "${lines[4]}")
save_model_key=$(func_parser_key "${lines[5]}") save_model_key=$(func_parser_key "${lines[5]}")
save_infer_key=$(func_parser_key "${lines[6]}") train_batch_key=$(func_parser_key "${lines[6]}")
train_batch_key=$(func_parser_key "${lines[7]}") train_use_gpu_key=$(func_parser_key "${lines[7]}")
train_use_gpu_key=$(func_parser_key "${lines[8]}") pretrain_model_key=$(func_parser_key "${lines[8]}")
pretrain_model_key=$(func_parser_key "${lines[9]}") pretrain_model_value=$(func_parser_value "${lines[8]}")
trainer_list=$(func_parser_value "${lines[10]}") trainer_list=$(func_parser_value "${lines[9]}")
norm_trainer=$(func_parser_value "${lines[11]}") norm_trainer=$(func_parser_value "${lines[10]}")
pact_trainer=$(func_parser_value "${lines[12]}") pact_trainer=$(func_parser_value "${lines[11]}")
fpgm_trainer=$(func_parser_value "${lines[13]}") fpgm_trainer=$(func_parser_value "${lines[12]}")
distill_trainer=$(func_parser_value "${lines[14]}") distill_trainer=$(func_parser_value "${lines[13]}")
eval_py=$(func_parser_value "${lines[15]}") eval_py=$(func_parser_value "${lines[14]}")
norm_export=$(func_parser_value "${lines[16]}")
pact_export=$(func_parser_value "${lines[17]}") save_infer_key=$(func_parser_key "${lines[15]}")
fpgm_export=$(func_parser_value "${lines[18]}") export_weight=$(func_parser_key "${lines[16]}")
distill_export=$(func_parser_value "${lines[19]}") norm_export=$(func_parser_value "${lines[17]}")
pact_export=$(func_parser_value "${lines[18]}")
inference_py=$(func_parser_value "${lines[20]}") fpgm_export=$(func_parser_value "${lines[19]}")
use_gpu_key=$(func_parser_key "${lines[21]}") distill_export=$(func_parser_value "${lines[20]}")
use_gpu_list=$(func_parser_value "${lines[21]}")
use_mkldnn_key=$(func_parser_key "${lines[22]}") inference_py=$(func_parser_value "${lines[21]}")
use_mkldnn_list=$(func_parser_value "${lines[22]}") use_gpu_key=$(func_parser_key "${lines[22]}")
cpu_threads_key=$(func_parser_key "${lines[23]}") use_gpu_list=$(func_parser_value "${lines[22]}")
cpu_threads_list=$(func_parser_value "${lines[23]}") use_mkldnn_key=$(func_parser_key "${lines[23]}")
batch_size_key=$(func_parser_key "${lines[24]}") use_mkldnn_list=$(func_parser_value "${lines[23]}")
batch_size_list=$(func_parser_value "${lines[24]}") cpu_threads_key=$(func_parser_key "${lines[24]}")
use_trt_key=$(func_parser_key "${lines[25]}") cpu_threads_list=$(func_parser_value "${lines[24]}")
use_trt_list=$(func_parser_value "${lines[25]}") batch_size_key=$(func_parser_key "${lines[25]}")
precision_key=$(func_parser_key "${lines[26]}") batch_size_list=$(func_parser_value "${lines[25]}")
precision_list=$(func_parser_value "${lines[26]}") use_trt_key=$(func_parser_key "${lines[26]}")
model_dir_key=$(func_parser_key "${lines[27]}") use_trt_list=$(func_parser_value "${lines[26]}")
image_dir_key=$(func_parser_key "${lines[28]}") precision_key=$(func_parser_key "${lines[27]}")
save_log_key=$(func_parser_key "${lines[29]}") 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" LOG_PATH="./test/output"
mkdir -p ${LOG_PATH} mkdir -p ${LOG_PATH}
status_log="${LOG_PATH}/results.log" 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(){ function func_inference(){
IFS='|' IFS='|'
...@@ -110,7 +102,7 @@ function func_inference(){ ...@@ -110,7 +102,7 @@ function func_inference(){
for threads in ${cpu_threads_list[*]}; do for threads in ${cpu_threads_list[*]}; do
for batch_size in ${batch_size_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}" _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 eval $command
status_check $? "${command}" "${status_log}" status_check $? "${command}" "${status_log}"
done done
...@@ -124,7 +116,7 @@ function func_inference(){ ...@@ -124,7 +116,7 @@ function func_inference(){
fi fi
for batch_size in ${batch_size_list[*]}; do for batch_size in ${batch_size_list[*]}; do
_save_log_path="${_log_path}/infer_gpu_usetrt_${use_trt}_precision_${precision}_batchsize_${batch_size}" _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 eval $command
status_check $? "${command}" "${status_log}" status_check $? "${command}" "${status_log}"
done done
...@@ -138,9 +130,9 @@ if [ ${MODE} != "infer" ]; then ...@@ -138,9 +130,9 @@ if [ ${MODE} != "infer" ]; then
IFS="|" IFS="|"
for gpu in ${gpu_list[*]}; do for gpu in ${gpu_list[*]}; do
train_use_gpu=True use_gpu=True
if [ ${gpu} = "-1" ];then if [ ${gpu} = "-1" ];then
train_use_gpu=False use_gpu=False
env="" env=""
elif [ ${#gpu} -le 1 ];then elif [ ${#gpu} -le 1 ];then
env="export CUDA_VISIBLE_DEVICES=${gpu}" env="export CUDA_VISIBLE_DEVICES=${gpu}"
...@@ -155,6 +147,7 @@ for gpu in ${gpu_list[*]}; do ...@@ -155,6 +147,7 @@ for gpu in ${gpu_list[*]}; do
ips=${array[0]} ips=${array[0]}
gpu=${array[1]} gpu=${array[1]}
IFS="|" IFS="|"
env=" "
fi fi
for autocast in ${autocast_list[*]}; do for autocast in ${autocast_list[*]}; do
for trainer in ${trainer_list[*]}; do for trainer in ${trainer_list[*]}; do
...@@ -179,13 +172,32 @@ for gpu in ${gpu_list[*]}; do ...@@ -179,13 +172,32 @@ for gpu in ${gpu_list[*]}; do
continue continue
fi fi
save_log="${LOG_PATH}/${trainer}_gpus_${gpu}_autocast_${autocast}" # not set autocast when autocast is null
if [ ${#gpu} -le 2 ];then # epoch_num #TODO if [ ${autocast} = "null" ]; then
cmd="${python} ${run_train} ${train_use_gpu_key}=${train_use_gpu} ${autocast_key}=${autocast} ${epoch_key}=${epoch_num} ${save_model_key}=${save_log} " set_autocast=" "
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}"
else 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_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
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 fi
# run train # run train
eval $cmd eval $cmd
...@@ -198,11 +210,12 @@ for gpu in ${gpu_list[*]}; do ...@@ -198,11 +210,12 @@ for gpu in ${gpu_list[*]}; do
# run export model # run export model
save_infer_path="${save_log}" 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 eval $export_cmd
status_check $? "${export_cmd}" "${status_log}" status_check $? "${export_cmd}" "${status_log}"
#run inference #run inference
echo $env
save_infer_path="${save_log}" save_infer_path="${save_log}"
func_inference "${python}" "${inference_py}" "${save_infer_path}" "${LOG_PATH}" "${infer_img_dir}" func_inference "${python}" "${inference_py}" "${save_infer_path}" "${LOG_PATH}" "${infer_img_dir}"
done done
...@@ -210,12 +223,13 @@ for gpu in ${gpu_list[*]}; do ...@@ -210,12 +223,13 @@ for gpu in ${gpu_list[*]}; do
done done
else else
save_infer_path="${LOG_PATH}/${MODE}" GPUID=$3
run_export=${norm_export} if [ ${#GPUID} -le 0 ];then
export_cmd="${python} ${run_export} ${save_model_key}=${save_infer_path} ${pretrain_model_key}=${infer_model_dir} ${save_infer_key}=${save_infer_path}" env=" "
eval $export_cmd else
status_check $? "${export_cmd}" "${status_log}" env="export CUDA_VISIBLE_DEVICES=${GPUID}"
fi
echo $env
#run inference #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 fi
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册