mirror of
https://github.com/PaddlePaddle/PaddleOCR.git
synced 2025-06-03 21:53:39 +08:00
refine status check
This commit is contained in:
parent
f7a554c2af
commit
58437e6448
@ -28,6 +28,19 @@ gpu_trt_list=$(func_parser "${lines[10]}")
|
|||||||
gpu_precision_list=$(func_parser "${lines[11]}")
|
gpu_precision_list=$(func_parser "${lines[11]}")
|
||||||
|
|
||||||
|
|
||||||
|
function status_check(){
|
||||||
|
last_status=$1 # 上个阶段的退出码
|
||||||
|
run_model=$2
|
||||||
|
run_command=$3
|
||||||
|
save_log=$4
|
||||||
|
echo ${case3}
|
||||||
|
if [ $last_status -eq 0 ]; then
|
||||||
|
echo -e "\033[33m $run_model successfully with command - ${run_command}! \033[0m" | tee -a ${save_log}
|
||||||
|
else
|
||||||
|
echo -e "\033[33m $case failed with command - ${run_command}! \033[0m" | tee -a ${save_log}
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
for train_model in ${train_model_list[*]}; do
|
for train_model in ${train_model_list[*]}; do
|
||||||
if [ ${train_model} = "det" ];then
|
if [ ${train_model} = "det" ];then
|
||||||
model_name="det"
|
model_name="det"
|
||||||
@ -42,7 +55,7 @@ for train_model in ${train_model_list[*]}; do
|
|||||||
# eval
|
# eval
|
||||||
for slim_trainer in ${slim_trainer_list[*]}; do
|
for slim_trainer in ${slim_trainer_list[*]}; do
|
||||||
if [ ${slim_trainer} = "norm" ]; then
|
if [ ${slim_trainer} = "norm" ]; then
|
||||||
if [ ${model_name} = "model_name" ]; then
|
if [ ${model_name} = "det" ]; then
|
||||||
eval_model_name="ch_ppocr_mobile_v2.0_det_infer"
|
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_train.tar
|
||||||
else
|
else
|
||||||
@ -50,7 +63,7 @@ for train_model in ${train_model_list[*]}; do
|
|||||||
wget -nc -P ./inference https://paddleocr.bj.bcebos.com/dygraph_v2.0/ch/ch_ppocr_mobile_v2.0_rec_train.tar
|
wget -nc -P ./inference https://paddleocr.bj.bcebos.com/dygraph_v2.0/ch/ch_ppocr_mobile_v2.0_rec_train.tar
|
||||||
fi
|
fi
|
||||||
elif [ ${slim_trainer} = "quant" ]; then
|
elif [ ${slim_trainer} = "quant" ]; then
|
||||||
if [ ${model_name} = "model_name" ]; then
|
if [ ${model_name} = "det" ]; then
|
||||||
eval_model_name="ch_ppocr_mobile_v2.0_det_quant_infer"
|
eval_model_name="ch_ppocr_mobile_v2.0_det_quant_infer"
|
||||||
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
|
||||||
else
|
else
|
||||||
@ -58,7 +71,7 @@ for train_model in ${train_model_list[*]}; do
|
|||||||
wget -nc -P ./inference https://paddleocr.bj.bcebos.com/dygraph_v2.0/slim/ch_ppocr_mobile_v2.0_rec_quant_train.tar
|
wget -nc -P ./inference https://paddleocr.bj.bcebos.com/dygraph_v2.0/slim/ch_ppocr_mobile_v2.0_rec_quant_train.tar
|
||||||
fi
|
fi
|
||||||
elif [ ${slim_trainer} = "distill" ]; then
|
elif [ ${slim_trainer} = "distill" ]; then
|
||||||
if [ ${model_name} = "model_name" ]; then
|
if [ ${model_name} = "det" ]; then
|
||||||
eval_model_name="ch_ppocr_mobile_v2.0_det_distill_infer"
|
eval_model_name="ch_ppocr_mobile_v2.0_det_distill_infer"
|
||||||
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
|
||||||
else
|
else
|
||||||
@ -66,7 +79,7 @@ for train_model in ${train_model_list[*]}; do
|
|||||||
wget -nc -P ./inference https://paddleocr.bj.bcebos.com/dygraph_v2.0/slim/ch_ppocr_mobile_v2.0_rec_distill_train.tar
|
wget -nc -P ./inference https://paddleocr.bj.bcebos.com/dygraph_v2.0/slim/ch_ppocr_mobile_v2.0_rec_distill_train.tar
|
||||||
fi
|
fi
|
||||||
elif [ ${slim_trainer} = "prune" ]; then
|
elif [ ${slim_trainer} = "prune" ]; then
|
||||||
if [ ${model_name} = "model_name" ]; 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
|
||||||
else
|
else
|
||||||
@ -74,9 +87,15 @@ for train_model in ${train_model_list[*]}; do
|
|||||||
wget -nc -P ./inference https://paddleocr.bj.bcebos.com/dygraph_v2.0/slim/ch_ppocr_mobile_v2.0_rec_prune_train.tar
|
wget -nc -P ./inference https://paddleocr.bj.bcebos.com/dygraph_v2.0/slim/ch_ppocr_mobile_v2.0_rec_prune_train.tar
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
save_log_path="${log_path}/${eval_model_name}"
|
||||||
|
command="${python} tools/eval.py -c ${yml_file} -o Global.pretrained_model=${eval_model_name} Global.save_model_dir=${save_log_path}"
|
||||||
|
${python} tools/eval.py -c ${yml_file} -o Global.pretrained_model=${eval_model_name} Global.save_model_dir=${save_log_path}
|
||||||
|
status_check $? "${trainer}" "${command}" "${save_log_path}/train.log"
|
||||||
|
|
||||||
|
command="${python} tools/export_model.py -c ${yml_file} -o Global.pretrained_model=${eval_model_name} Global.save_inference_dir=${log_path}/${eval_model_name}_infer Global.save_model_dir=${save_log_path}"
|
||||||
|
${python} tools/export_model.py -c ${yml_file} -o Global.pretrained_model=${eval_model_name} Global.save_inference_dir=${log_path}/${eval_model_name}_infer Global.save_model_dir=${save_log_path}
|
||||||
|
status_check $? "${trainer}" "${command}" "${save_log_path}/train.log"
|
||||||
|
|
||||||
echo ${python} tools/eval.py -c ${yml_file} -o Global.pretrained_model=${eval_model_name} Global.save_model_dir=${log_path}/${model_name}
|
|
||||||
echo ${python} tools/export_model.py -c ${yml_file} -o Global.pretrained_model=${eval_model_name} Global.save_inference_dir=${log_path}/${eval_model_name}_infer
|
|
||||||
if [ $? -eq 0 ]; then
|
if [ $? -eq 0 ]; then
|
||||||
echo -e "\033[33m training of $model_name successfully!\033[0m" | tee -a ${save_log}/train.log
|
echo -e "\033[33m training of $model_name successfully!\033[0m" | tee -a ${save_log}/train.log
|
||||||
else
|
else
|
||||||
@ -99,8 +118,10 @@ for train_model in ${train_model_list[*]}; do
|
|||||||
for use_mkldnn in ${use_mkldnn_list[*]}; do
|
for use_mkldnn in ${use_mkldnn_list[*]}; do
|
||||||
for threads in ${cpu_threads_list[*]}; do
|
for threads in ${cpu_threads_list[*]}; do
|
||||||
for rec_batch_size in ${rec_batch_size_list[*]}; do
|
for rec_batch_size in ${rec_batch_size_list[*]}; do
|
||||||
echo ${python} ${inference} --enable_mkldnn=${use_mkldnn} --use_gpu=False --cpu_threads=${threads} --benchmark=True --det_model_dir=${det_model_dir} --rec_batch_num=${rec_batch_size} --rec_model_dir=${rec_model_dir} --image_dir=${img_dir} --save_log_path=${log_path}/${model_name}_${slim_trainer}_cpu_usemkldnn_${use_mkldnn}_cputhreads_${threads}_recbatchnum_${rec_batch_size}_infer.log
|
save_log_path="${log_path}/${model_name}_${slim_trainer}_cpu_usemkldnn_${use_mkldnn}_cputhreads_${threads}_recbatchnum_${rec_batch_size}_infer.log"
|
||||||
# ${python} ${inference} --enable_mkldnn=${use_mkldnn} --use_gpu=False --cpu_threads=${threads} --benchmark=True --det_model_dir=${save_log}/export_inference/ --rec_batch_num=${rec_batch_size} --rec_model_dir=${rec_model_dir} --image_dir=${img_dir} 2>&1 | tee ${log_path}/${model_name}_${slim_trainer}_cpu_usemkldnn_${use_mkldnn}_cputhreads_${threads}_recbatchnum_${rec_batch_size}_infer.log
|
command="${python} ${inference} --enable_mkldnn=${use_mkldnn} --use_gpu=False --cpu_threads=${threads} --benchmark=True --det_model_dir=${det_model_dir} --rec_batch_num=${rec_batch_size} --rec_model_dir=${rec_model_dir} --image_dir=${img_dir} --save_log_path=${save_log_path}"
|
||||||
|
${python} ${inference} --enable_mkldnn=${use_mkldnn} --use_gpu=False --cpu_threads=${threads} --benchmark=True --det_model_dir=${det_model_dir} --rec_batch_num=${rec_batch_size} --rec_model_dir=${rec_model_dir} --image_dir=${img_dir} --save_log_path=${save_log_path}
|
||||||
|
status_check $? "${trainer}" "${command}" "${save_log_path}"
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
@ -111,8 +132,10 @@ for train_model in ${train_model_list[*]}; do
|
|||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
for rec_batch_size in ${rec_batch_size_list[*]}; do
|
for rec_batch_size in ${rec_batch_size_list[*]}; do
|
||||||
# echo "${model_name} ${det_model_dir} ${rec_model_dir}, use_trt: ${use_trt} use_fp16: ${use_fp16}"
|
save_log_path="${log_path}/${model_name}_${slim_trainer}_gpu_usetensorrt_${use_trt}_usefp16_${precision}_recbatchnum_${rec_batch_size}_infer.log"
|
||||||
echo ${python} ${inference} --use_gpu=True --use_tensorrt=${use_trt} --precision=${precision} --benchmark=True --det_model_dir=${log_path}/${eval_model_name}_infer --rec_batch_num=${rec_batch_size} --rec_model_dir=${rec_model_dir} --image_dir=${img_dir} --save_log_path=${log_path}/${model_name}_${slim_trainer}_gpu_usetensorrt_${use_trt}_usefp16_${precision}_recbatchnum_${rec_batch_size}_infer.log
|
command="${python} ${inference} --use_gpu=True --use_tensorrt=${use_trt} --precision=${precision} --benchmark=True --det_model_dir=${log_path}/${eval_model_name}_infer --rec_batch_num=${rec_batch_size} --rec_model_dir=${rec_model_dir} --image_dir=${img_dir} --save_log_path=${save_log_path}"
|
||||||
|
${python} ${inference} --use_gpu=True --use_tensorrt=${use_trt} --precision=${precision} --benchmark=True --det_model_dir=${log_path}/${eval_model_name}_infer --rec_batch_num=${rec_batch_size} --rec_model_dir=${rec_model_dir} --image_dir=${img_dir} --save_log_path=${save_log_path}
|
||||||
|
status_check $? "${trainer}" "${command}" "${save_log_path}"
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
|
49
test/test.sh
49
test/test.sh
@ -21,7 +21,7 @@ elif [ ${MODE} = "whole_train_infer" ];then
|
|||||||
rm -rf ./train_data/icdar2015
|
rm -rf ./train_data/icdar2015
|
||||||
wget -nc -P ./train_data/ https://paddleocr.bj.bcebos.com/dygraph_v2.0/test/icdar2015.tar
|
wget -nc -P ./train_data/ https://paddleocr.bj.bcebos.com/dygraph_v2.0/test/icdar2015.tar
|
||||||
cd ./train_data/ && tar xf icdar2015.tar && cd ../
|
cd ./train_data/ && tar xf icdar2015.tar && cd ../
|
||||||
epoch=300
|
epoch=500
|
||||||
eval_batch_step=200
|
eval_batch_step=200
|
||||||
else
|
else
|
||||||
echo "Do Nothing"
|
echo "Do Nothing"
|
||||||
@ -55,9 +55,19 @@ rec_batch_size_list=$(func_parser "${lines[9]}")
|
|||||||
gpu_trt_list=$(func_parser "${lines[10]}")
|
gpu_trt_list=$(func_parser "${lines[10]}")
|
||||||
gpu_precision_list=$(func_parser "${lines[11]}")
|
gpu_precision_list=$(func_parser "${lines[11]}")
|
||||||
img_dir="./train_data/icdar2015/text_localization/ch4_test_images/"
|
img_dir="./train_data/icdar2015/text_localization/ch4_test_images/"
|
||||||
# train superparameters
|
|
||||||
#epoch=$(func_parser "${lines[12]}")
|
function status_check(){
|
||||||
#checkpoints=$(func_parser "${lines[13]}")
|
last_status=$1 # 上个阶段的退出码
|
||||||
|
run_model=$2
|
||||||
|
run_command=$3
|
||||||
|
save_log=$4
|
||||||
|
echo ${case3}
|
||||||
|
if [ $last_status -eq 0 ]; then
|
||||||
|
echo -e "\033[33m $run_model successfully with command - ${run_command}! \033[0m" | tee -a ${save_log}
|
||||||
|
else
|
||||||
|
echo -e "\033[33m $case failed with command - ${run_command}! \033[0m" | tee -a ${save_log}
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
for train_model in ${train_model_list[*]}; do
|
for train_model in ${train_model_list[*]}; do
|
||||||
@ -101,17 +111,14 @@ for train_model in ${train_model_list[*]}; do
|
|||||||
trainer="tools/train.py"
|
trainer="tools/train.py"
|
||||||
export_model="tools/export_model.py"
|
export_model="tools/export_model.py"
|
||||||
fi
|
fi
|
||||||
# dataset="Train.dataset.data_dir=${train_dir} Train.dataset.label_file_list=${train_label_file} Eval.dataset.data_dir=${eval_dir} Eval.dataset.label_file_list=${eval_label_file}"
|
|
||||||
save_log=${log_path}/${model_name}_${slim_trainer}_autocast_${auto_cast}_gpuid_${gpu}
|
save_log=${log_path}/${model_name}_${slim_trainer}_autocast_${auto_cast}_gpuid_${gpu}
|
||||||
|
command="${python} ${launch} ${trainer} -c ${yml_file} -o Global.epoch_num=${epoch} Global.eval_batch_step=${eval_batch_step} Global.auto_cast=${auto_cast} Global.save_model_dir=${save_log} Global.use_gpu=${use_gpu}"
|
||||||
${python} ${launch} ${trainer} -c ${yml_file} -o Global.epoch_num=${epoch} Global.eval_batch_step=${eval_batch_step} Global.auto_cast=${auto_cast} Global.save_model_dir=${save_log} Global.use_gpu=${use_gpu}
|
${python} ${launch} ${trainer} -c ${yml_file} -o Global.epoch_num=${epoch} Global.eval_batch_step=${eval_batch_step} Global.auto_cast=${auto_cast} Global.save_model_dir=${save_log} Global.use_gpu=${use_gpu}
|
||||||
|
status_check $? "${trainer}" "${command}" "${save_log}/train.log"
|
||||||
|
|
||||||
|
command="${python} ${export_model} -c ${yml_file} -o Global.pretrained_model=${save_log}/best_accuracy Global.save_inference_dir=${save_log}/export_inference/ Global.save_model_dir=${save_log}"
|
||||||
${python} ${export_model} -c ${yml_file} -o Global.pretrained_model=${save_log}/best_accuracy Global.save_inference_dir=${save_log}/export_inference/ Global.save_model_dir=${save_log}
|
${python} ${export_model} -c ${yml_file} -o Global.pretrained_model=${save_log}/best_accuracy Global.save_inference_dir=${save_log}/export_inference/ Global.save_model_dir=${save_log}
|
||||||
if [ $? -eq 0 ]; then
|
status_check $? "${trainer}" "${command}" "${save_log}/train.log"
|
||||||
echo -e "\033[33m training of $model_name successfully!\033[0m" | tee -a ${save_log}/train.log
|
|
||||||
else
|
|
||||||
cat ${save_log}/train.log
|
|
||||||
echo -e "\033[33m training of $model_name failed!\033[0m" | tee -a ${save_log}/train.log
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "${model_name}" = "det" ]; then
|
if [ "${model_name}" = "det" ]; then
|
||||||
export rec_batch_size_list=( "1" )
|
export rec_batch_size_list=( "1" )
|
||||||
@ -129,15 +136,10 @@ for train_model in ${train_model_list[*]}; do
|
|||||||
for use_mkldnn in ${use_mkldnn_list[*]}; do
|
for use_mkldnn in ${use_mkldnn_list[*]}; do
|
||||||
for threads in ${cpu_threads_list[*]}; do
|
for threads in ${cpu_threads_list[*]}; do
|
||||||
for rec_batch_size in ${rec_batch_size_list[*]}; do
|
for rec_batch_size in ${rec_batch_size_list[*]}; do
|
||||||
echo ${python} ${inference} --enable_mkldnn=${use_mkldnn} --use_gpu=False --cpu_threads=${threads} --benchmark=True --det_model_dir=${save_log}/export_inference/ --rec_batch_num=${rec_batch_size} --rec_model_dir=${rec_model_dir} --image_dir=${img_dir} --save_log_path=${log_path}/${model_name}_${slim_trainer}_cpu_usemkldnn_${use_mkldnn}_cputhreads_${threads}_recbatchnum_${rec_batch_size}_infer.log
|
save_log_path="${log_path}/${model_name}_${slim_trainer}_cpu_usemkldnn_${use_mkldnn}_cputhreads_${threads}_recbatchnum_${rec_batch_size}_infer.log"
|
||||||
${python} ${inference} --enable_mkldnn=${use_mkldnn} --use_gpu=False --cpu_threads=${threads} --benchmark=True --det_model_dir=${save_log}/export_inference/ --rec_batch_num=${rec_batch_size} --rec_model_dir=${rec_model_dir} --image_dir=${img_dir} --save_log_path=${log_path}/${model_name}_${slim_trainer}_cpu_usemkldnn_${use_mkldnn}_cputhreads_${threads}_recbatchnum_${rec_batch_size}_infer.log
|
command="${python} ${inference} --enable_mkldnn=${use_mkldnn} --use_gpu=False --cpu_threads=${threads} --benchmark=True --det_model_dir=${save_log}/export_inference/ --rec_batch_num=${rec_batch_size} --rec_model_dir=${rec_model_dir} --image_dir=${img_dir} --save_log_path=${save_log_path}"
|
||||||
if [ $? -eq 0 ]; then
|
${python} ${inference} --enable_mkldnn=${use_mkldnn} --use_gpu=False --cpu_threads=${threads} --benchmark=True --det_model_dir=${save_log}/export_inference/ --rec_batch_num=${rec_batch_size} --rec_model_dir=${rec_model_dir} --image_dir=${img_dir} --save_log_path=${save_log_path}
|
||||||
echo -e "\033[33m training of $model_name successfully!\033[0m" | tee -a ${log_path}${model_name}_${slim_trainer}_cpu_usemkldnn_${use_mkldnn}_cputhreads_${threads}_recbatchnum_${rec_batch_size}_infer.log
|
status_check $? "${inference}" "${command}" "${save_log}"
|
||||||
else
|
|
||||||
cat ${log_path}${model_name}_${slim_trainer}_cpu_usemkldnn_${use_mkldnn}_cputhreads_${threads}_recbatchnum_${rec_batch_size}_infer.log
|
|
||||||
echo -e "\033[33m training of $model_name failed!\033[0m" | tee -a ${log_path}${model_name}_${slim_trainer}_cpu_usemkldnn_${use_mkldnn}_cputhreads_${threads}_recbatchnum_${rec_batch_size}_infer.log
|
|
||||||
fi
|
|
||||||
|
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
@ -148,8 +150,9 @@ for train_model in ${train_model_list[*]}; do
|
|||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
for rec_batch_size in ${rec_batch_size_list[*]}; do
|
for rec_batch_size in ${rec_batch_size_list[*]}; do
|
||||||
# echo "${model_name} ${det_model_dir} ${rec_model_dir}, use_trt: ${use_trt} use_fp16: ${use_fp16}"
|
save_log_path="${log_path}/${model_name}_${slim_trainer}_gpu_usetensorrt_${use_trt}_usefp16_${precision}_recbatchnum_${rec_batch_size}_infer.log"
|
||||||
${python} ${inference} --use_gpu=True --use_tensorrt=${use_trt} --precision=${precision} --benchmark=True --det_model_dir=${save_log}/export_inference/ --rec_batch_num=${rec_batch_size} --rec_model_dir=${rec_model_dir} --image_dir=${img_dir} --save_log_path=${log_path}/${model_name}_${slim_trainer}_gpu_usetensorrt_${use_trt}_usefp16_${precision}_recbatchnum_${rec_batch_size}_infer.log
|
${python} ${inference} --use_gpu=True --use_tensorrt=${use_trt} --precision=${precision} --benchmark=True --det_model_dir=${save_log}/export_inference/ --rec_batch_num=${rec_batch_size} --rec_model_dir=${rec_model_dir} --image_dir=${img_dir} --save_log_path=${save_log_path}
|
||||||
|
status_check $? "${inference}" "${command}" "${save_log}"
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
|
Loading…
x
Reference in New Issue
Block a user