未验证 提交 abfa9e3c 编写于 作者: S shangliang Xu 提交者: GitHub

[dev] add new ce test (#3951)

* [ce tests] alter ce scripts

* alter  pretrain_model_key

* alter infer mode
上级 d1c6c1e1
#!/bin/bash
FILENAME=$1
# MODE be one of ['lite_train_infer' 'whole_infer' 'whole_train_infer']
MODE=$2
# prepare dataset
if [ ${MODE} = "lite_train_infer" ];then
# pretrain lite train data
cd dataset/coco
wget https://paddledet.bj.bcebos.com/data/coco_ce.tar
tar -xvf coco_ce.tar
mv coco_ce/* .
rm -rf coco_ce*
else
# pretrain lite train data
cd dataset/coco
wget https://paddledet.bj.bcebos.com/data/coco_ce.tar
tar -xvf coco_ce.tar
mv coco_ce/* .
rm -rf coco_ce*
fi
# 全链条CI/CE脚本详细说明
```
├── tests
│ ├── ppdet_params
│ │ ├── ppyolo_mbv3_large_coco_params.txt
│ │ ├── ppyolo_r50vd_dcn_1x_coco_params.txt
│ │ ├── ppyolov2_r50vd_dcn_365e_coco_params.txt
│ │ ├── yolov3_darknet53_270e_coco_params.txt
│ │ ├── ...
│ ├── prepare.sh
│ ├── README.md
│ ├── requirements.txt
│ ├── test.sh
```
## 脚本说明
### test.sh
主要运行脚本,以 `ppdet_params/xxx_params.txt` 作为参数配置,可完成相关测试方案
### prepare.sh
相关数据准备脚本,以 `ppdet_params/xxx_params.txt` 作为参数配置,完成数据、预训练模型、预测模型的自动下载
## test.sh使用方法
`yolov3_darknet53_270e_coco_params.txt` 为例,进入到PaddleDetection目录下
### 模式1: 少量数据训练,少量数据预测(lite_train_infer)
```bash
bash ./tests/prepare.sh ./tests/ppdet_params/yolov3_darknet53_270e_coco_params.txt lite_train_infer
bash ./tests/test.sh ./tests/ppdet_params/yolov3_darknet53_270e_coco_params.txt lite_train_infer
```
### 模式2: 少量数据训练,全量数据预测(whole_infer)
```bash
bash ./tests/prepare.sh ./tests/ppdet_params/yolov3_darknet53_270e_coco_params.txt whole_infer
bash ./tests/test.sh ./tests/ppdet_params/yolov3_darknet53_270e_coco_params.txt whole_infer
```
### 模式3: 全量数据训练,全量数据预测(whole_train_infer)
```bash
bash ./tests/prepare.sh ./tests/ppdet_params/yolov3_darknet53_270e_coco_params.txt whole_train_infer
bash ./tests/test.sh ./tests/ppdet_params/yolov3_darknet53_270e_coco_params.txt whole_train_infer
```
### 模式4: 不训练,全量数据预测(infer)
```bash
bash ./tests/prepare.sh ./tests/ppdet_params/yolov3_darknet53_270e_coco_params.txt infer
bash ./tests/test.sh ./tests/ppdet_params/yolov3_darknet53_270e_coco_params.txt infer
```
**注:**
运行`prepare.sh`时,会清空`dataset/coco/`下所有文件
===========================train_params===========================
model_name:ppyolo_mbv3_large_coco
python:python3.7
gpu_list:0
use_gpu:True
auto_cast:null
epoch:lite_train_infer=1|whole_train_infer=405
save_dir:./output/
TrainReader.batch_size:lite_train_infer=2|whole_train_infer=24
pretrain_weights:null
train_model_name:ppyolo_mbv3_large_coco/model_final.pdparams
train_infer_img_dir:./tests/demo/
filename:ppyolo_mbv3_large_coco
##
trainer:norm_train|pact_train|fpgm_train
norm_train:tools/train.py -c configs/ppyolo/ppyolo_mbv3_large_coco.yml -o
pact_train:tools/train.py -c configs/ppyolo/ppyolo_mbv3_large_coco.yml --slim_config configs/slim/quant/ppyolo_mbv3_large_qat.yml -o
fpgm_train:tools/train.py -c configs/ppyolo/ppyolo_mbv3_large_coco.yml --slim_config configs/slim/prune/ppyolo_mbv3_large_prune_fpgm.yml -o
distill_train:null
null:null
null:null
##
===========================eval_params===========================
eval:tools/eval.py -c configs/ppyolo/ppyolo_mbv3_large_coco.yml -o
null:null
##
===========================infer_params===========================
--output_dir:null
weights:
norm_export:tools/export_model.py -c configs/ppyolo/ppyolo_mbv3_large_coco.yml -o
quant_export:tools/export_model.py -c configs/ppyolo/ppyolo_mbv3_large_coco.yml --slim_config configs/slim/quant/ppyolo_mbv3_large_qat.yml -o
fpgm_export:tools/export_model.py -c configs/ppyolo/ppyolo_mbv3_large_coco.yml --slim_config configs/slim/prune/ppyolo_mbv3_large_prune_fpgm.yml -o
distill_export:null
export1:null
export2:null
##
infer_model:ppyolo_mbv3_large_coco.pdparams|ppyolo_mbv3_large_qat.pdparams|ppyolo_mbv3_large_prune_fpgm.pdparams
infer_export:./tests/weights|./tests/weights|./tests/weights
infer_quant:False|True|False
inference:deploy/python/infer.py
--device:gpu|cpu
--enable_mkldnn:False|True
--cpu_threads:1|4
--batch_size:1|2
--use_tensorrt:null
--run_mode:fluid
--model_dir:
--image_dir:./dataset/coco/val2017/
--save_log_path:null
--run_benchmark:True
null:null
===========================train_params===========================
model_name:ppyolo_r50vd_dcn_1x_coco
python:python3.7
gpu_list:0
use_gpu:True
auto_cast:null
epoch:lite_train_infer=1|whole_train_infer=405
save_dir:./output/
TrainReader.batch_size:lite_train_infer=2|whole_train_infer=24
pretrain_weights:null
train_model_name:ppyolo_r50vd_dcn_1x_coco/model_final.pdparams
train_infer_img_dir:./tests/demo/
filename:ppyolo_r50vd_dcn_1x_coco
##
trainer:norm_train|pact_train|fpgm_train
norm_train:tools/train.py -c configs/ppyolo/ppyolo_r50vd_dcn_1x_coco.yml -o
pact_train:tools/train.py -c configs/ppyolo/ppyolo_r50vd_dcn_1x_coco.yml --slim_config configs/slim/quant/ppyolo_r50vd_qat_pact.yml -o
fpgm_train:tools/train.py -c configs/ppyolo/ppyolo_r50vd_dcn_1x_coco.yml --slim_config configs/slim/prune/ppyolo_r50vd_prune_fpgm.yml -o
distill_train:null
null:null
null:null
##
===========================eval_params===========================
eval:tools/eval.py -c configs/ppyolo/ppyolo_r50vd_dcn_1x_coco.yml -o
null:null
##
===========================infer_params===========================
--output_dir:null
weights:
norm_export:tools/export_model.py -c configs/ppyolo/ppyolo_r50vd_dcn_1x_coco.yml -o
quant_export:tools/export_model.py -c configs/ppyolo/ppyolo_r50vd_dcn_1x_coco.yml --slim_config configs/slim/quant/ppyolo_r50vd_qat_pact.yml -o
fpgm_export:tools/export_model.py -c configs/ppyolo/ppyolo_r50vd_dcn_1x_coco.yml --slim_config configs/slim/prune/ppyolo_r50vd_prune_fpgm.yml -o
distill_export:null
export1:null
export2:null
##
infer_model:ppyolo_r50vd_dcn_1x_coco.pdparams|ppyolo_r50vd_qat_pact.pdparams|ppyolo_r50vd_prune_fpgm.pdparams
infer_export:./tests/weights|./tests/weights|./tests/weights
infer_quant:False|True|False
inference:deploy/python/infer.py
--device:gpu|cpu
--enable_mkldnn:False|True
--cpu_threads:1|4
--batch_size:1|2
--use_tensorrt:null
--run_mode:fluid
--model_dir:
--image_dir:./dataset/coco/val2017/
--save_log_path:null
--run_benchmark:True
null:null
===========================train_params===========================
model_name:ppyolov2_r50vd_dcn_365e_coco
python:python3.7
gpu_list:0
use_gpu:True
auto_cast:null
epoch:lite_train_infer=1|whole_train_infer=365
save_dir:./output/
TrainReader.batch_size:lite_train_infer=2|whole_train_infer=12
pretrain_weights:./tests/weights/ppyolov2_r50vd_dcn_365e_coco.pdparams
train_model_name:ppyolov2_r50vd_dcn_365e_coco/model_final.pdparams
train_infer_img_dir:./tests/demo/
filename:ppyolov2_r50vd_dcn_365e_coco
##
trainer:norm_train
norm_train:tools/train.py -c configs/ppyolo/ppyolov2_r50vd_dcn_365e_coco.yml -o
pact_train:tools/train.py -c configs/ppyolo/ppyolov2_r50vd_dcn_365e_coco.yml --slim_config configs/slim/quant/ppyolov2_r50vd_dcn_qat.yml -o
fpgm_train:tools/train.py -c configs/ppyolo/ppyolov2_r50vd_dcn_365e_coco.yml --slim_config configs/slim/prune/ppyolov2_r50vd_dcn_prune_fpgm.yml -o
distill_train:null
null:null
null:null
##
===========================eval_params===========================
eval:tools/eval.py -c configs/ppyolo/ppyolov2_r50vd_dcn_365e_coco.yml -o
null:null
##
===========================infer_params===========================
--output_dir:null
weights:
norm_export:tools/export_model.py -c configs/ppyolo/ppyolov2_r50vd_dcn_365e_coco.yml -o
quant_export:tools/export_model.py -c configs/ppyolo/ppyolov2_r50vd_dcn_365e_coco.yml --slim_config configs/slim/quant/ppyolov2_r50vd_dcn_qat.yml -o
fpgm_export:tools/export_model.py -c configs/ppyolo/ppyolov2_r50vd_dcn_365e_coco.yml --slim_config configs/slim/prune/ppyolov2_r50vd_dcn_prune_fpgm.yml -o
distill_export:null
export1:null
export2:null
##
infer_model:./tests/weights/ppyolov2_r50vd_dcn_365e_coco.pdparams
infer_export:True
infer_quant:False
inference:deploy/python/infer.py
--device:gpu|cpu
--enable_mkldnn:False|True
--cpu_threads:1|4
--batch_size:1|2
--use_tensorrt:null
--run_mode:fluid|trt_fp32|trt_fp16|trt_int8
--model_dir:
--image_dir:./dataset/coco/val2017/
--save_log_path:null
--run_benchmark:True
null:null
......@@ -4,15 +4,15 @@ python:python3.7
gpu_list:0
use_gpu:True
auto_cast:null
epoch:lite_train_infer=1|whole_train_infer=12
epoch:lite_train_infer=1|whole_train_infer=270
save_dir:./output/
TrainReader.batch_size:lite_train_infer=2|whole_train_infer=4
weights:null
TrainReader.batch_size:lite_train_infer=2|whole_train_infer=8
pretrain_weights:null
train_model_name:yolov3_darknet53_270e_coco/model_final.pdparams
train_infer_img_dir:./demo1/
null:null
train_infer_img_dir:./tests/demo/
filename:yolov3_darknet53_270e_coco
##
trainer:norm_train|fpgm_train|pact_train
trainer:norm_train|pact_train|fpgm_train
norm_train:tools/train.py -c configs/yolov3/yolov3_darknet53_270e_coco.yml -o
pact_train:tools/train.py -c configs/yolov3/yolov3_darknet53_270e_coco.yml --slim_config configs/slim/quant/yolov3_darknet_qat.yml -o
fpgm_train:tools/train.py -c configs/yolov3/yolov3_darknet53_270e_coco.yml --slim_config configs/slim/prune/yolov3_darknet_prune_fpgm.yml -o
......@@ -25,24 +25,27 @@ eval:tools/eval.py -c configs/yolov3/yolov3_darknet53_270e_coco.yml -o
null:null
##
===========================infer_params===========================
--output_dir:./output/
--output_dir:null
weights:
norm_export:tools/export_model.py -c configs/yolov3/yolov3_darknet53_270e_coco.yml -o
quant_export:deploy/slim/quantization/export_model.py -c configs/yolov3/yolov3_darknet53_270e_coco.yml -o
fpgm_export:deploy/slim/prune/export_prune_model.py
quant_export:tools/export_model.py -c configs/yolov3/yolov3_darknet53_270e_coco.yml --slim_config configs/slim/quant/yolov3_darknet_qat.yml -o
fpgm_export:tools/export_model.py -c configs/yolov3/yolov3_darknet53_270e_coco.yml --slim_config configs/slim/prune/yolov3_darknet_prune_fpgm.yml -o
distill_export:null
null:null
null:null
export1:null
export2:null
##
infer_model:yolov3_darknet53_270e_coco.pdparams|yolov3_darknet_coco_qat.pdparams|yolov3_darknet_prune_fpgm.pdparams
infer_export:./tests/weights|./tests/weights|./tests/weights
infer_quant:False|True|False
inference:deploy/python/infer.py
--device:gpu
--device:gpu|cpu
--enable_mkldnn:False|True
--cpu_threads:1|4
--batch_size:1|2
--use_tensorrt:null
--run_mode:fluid
--model_dir:tests/output/norm_train_gpus_0_autocast_null/yolov3_darknet53_270e_coco/
--image_dir:./demo1/
--run_mode:fluid|trt_fp32|trt_fp16|trt_int8
--model_dir:
--image_dir:./dataset/coco/val2017/
--save_log_path:null
--run_benchmark:True
null:null
#!/bin/bash
FILENAME=$1
# MODE be one of ['lite_train_infer' 'whole_infer' 'whole_train_infer', 'infer']
MODE=$2
dataline=$(cat ${FILENAME})
# parser params
IFS=$'\n'
lines=(${dataline})
function func_parser_key(){
strs=$1
IFS=":"
array=(${strs})
tmp=${array[0]}
echo ${tmp}
}
function func_parser_value(){
strs=$1
IFS=":"
array=(${strs})
tmp=${array[1]}
echo ${tmp}
}
IFS=$'\n'
# The training params
model_name=$(func_parser_value "${lines[1]}")
python=$(func_parser_value "${lines[2]}")
trainer_list=$(func_parser_value "${lines[14]}")
# MODE be one of ['lite_train_infer' 'whole_infer' 'whole_train_infer']
MODE=$2
if [ ${MODE} = "lite_train_infer" ];then
mv ./dataset/coco/download_coco.py . && rm -rf ./dataset/coco/* && mv ./download_coco.py ./dataset/coco/
# prepare lite train data
wget -nc -P ./dataset/coco/ https://paddledet.bj.bcebos.com/data/coco_ce.tar
cd ./dataset/coco/ && tar -xvf coco_ce.tar && mv -u coco_ce/* .
rm -rf coco_ce/
# prepare lite train infer_img_dir
cd ../../ && mkdir -p ./tests/demo/
cp -u ./demo/road554.png ./demo/orange_71.jpg ./tests/demo/
if [[ ${model_name} = "ppyolov2_r50vd_dcn_365e_coco" ]]; then
wget -nc -P ./tests/weights/ https://paddledet.bj.bcebos.com/models/ppyolov2_r50vd_dcn_365e_coco.pdparams
fi
elif [ ${MODE} = "whole_train_infer" ];then
mv ./dataset/coco/download_coco.py . && rm -rf ./dataset/coco/* && mv ./download_coco.py ./dataset/coco/
# prepare whole train data
eval "${python} ./dataset/coco/download_coco.py"
# prepare whole train infer_img_dir
mkdir -p ./tests/demo/
cp -u dataset/coco/val2017/* ./tests/demo/
elif [ ${MODE} = "whole_infer" ];then
mv ./dataset/coco/download_coco.py . && rm -rf ./dataset/coco/* && mv ./download_coco.py ./dataset/coco/
# prepare whole infer data
wget -nc -P ./dataset/coco/ https://paddledet.bj.bcebos.com/data/coco_ce.tar
cd ./dataset/coco/ && tar -xvf coco_ce.tar && mv -u coco_ce/* .
rm -rf coco_ce/
# prepare whole infer infer_img_dir
cd ../../ && mkdir -p ./tests/demo/
cp -u dataset/coco/val2017/* ./tests/demo/
else
# prepare infer data
wget -nc -P ./dataset/coco/ https://paddledet.bj.bcebos.com/data/coco_ce.tar
cd ./dataset/coco/ && tar -xvf coco_ce.tar && mv -u coco_ce/* .
rm -rf coco_ce/ && cd ../../
if [[ ${model_name} = "yolov3_darknet53_270e_coco" ]]; then
wget -nc -P ./tests/weights/ https://paddledet.bj.bcebos.com/models/yolov3_darknet53_270e_coco.pdparams
wget -nc -P ./tests/weights/ https://paddledet.bj.bcebos.com/models/slim/yolov3_darknet_coco_qat.pdparams
wget -nc -P ./tests/weights/ https://paddledet.bj.bcebos.com/models/slim/yolov3_darknet_prune_fpgm.pdparams
elif [[ ${model_name} = "ppyolo_r50vd_dcn_1x_coco" ]]; then
wget -nc -P ./tests/weights/ https://paddledet.bj.bcebos.com/models/ppyolo_r50vd_dcn_1x_coco.pdparams
wget -nc -P ./tests/weights/ https://paddledet.bj.bcebos.com/models/slim/ppyolo_r50vd_qat_pact.pdparams
wget -nc -P ./tests/weights/ https://paddledet.bj.bcebos.com/models/slim/ppyolo_r50vd_prune_fpgm.pdparams
elif [[ ${model_name} = "ppyolo_mbv3_large_coco" ]]; then
wget -nc -P ./tests/weights/ https://paddledet.bj.bcebos.com/models/ppyolo_mbv3_large_coco.pdparams
wget -nc -P ./tests/weights/ https://paddledet.bj.bcebos.com/models/slim/ppyolo_mbv3_large_qat.pdparams
wget -nc -P ./tests/weights/ https://paddledet.bj.bcebos.com/models/slim/ppyolo_mbv3_large_prune_fpgm.pdparams
elif [[ ${model_name} = "ppyolov2_r50vd_dcn_365e_coco" ]]; then
wget -nc -P ./tests/weights/ https://paddledet.bj.bcebos.com/models/ppyolov2_r50vd_dcn_365e_coco.pdparams
elif [[ ${model_name} = "mask_rcnn_r50_fpn_1x_coco" ]]; then
wget -nc -P ./tests/weights/ https://paddledet.bj.bcebos.com/models/mask_rcnn_r50_fpn_1x_coco.pdparams
elif [[ ${model_name} = "solov2_r50_fpn_1x_coco" ]]; then
wget -nc -P ./tests/weights/ https://paddledet.bj.bcebos.com/models/solov2_r50_fpn_1x_coco.pdparams
else
sleep 2
fi
fi
pynvml
psutil
GPUtil
paddleslim
......@@ -118,28 +118,32 @@ export_value1=$(func_parser_value "${lines[33]}")
export_key2=$(func_parser_key "${lines[34]}")
export_value2=$(func_parser_value "${lines[34]}")
inference_py=$(func_parser_value "${lines[36]}")
use_gpu_key=$(func_parser_key "${lines[37]}")
use_gpu_list=$(func_parser_value "${lines[37]}")
use_mkldnn_key=$(func_parser_key "${lines[38]}")
use_mkldnn_list=$(func_parser_value "${lines[38]}")
cpu_threads_key=$(func_parser_key "${lines[39]}")
cpu_threads_list=$(func_parser_value "${lines[39]}")
batch_size_key=$(func_parser_key "${lines[40]}")
batch_size_list=$(func_parser_value "${lines[40]}")
use_trt_key=$(func_parser_key "${lines[41]}")
use_trt_list=$(func_parser_value "${lines[41]}")
precision_key=$(func_parser_key "${lines[42]}")
precision_list=$(func_parser_value "${lines[42]}")
infer_model_key=$(func_parser_key "${lines[43]}")
infer_model=$(func_parser_value "${lines[43]}")
image_dir_key=$(func_parser_key "${lines[44]}")
infer_img_dir=$(func_parser_value "${lines[44]}")
save_log_key=$(func_parser_key "${lines[45]}")
benchmark_key=$(func_parser_key "${lines[46]}")
benchmark_value=$(func_parser_value "${lines[46]}")
infer_key1=$(func_parser_key "${lines[47]}")
infer_value1=$(func_parser_value "${lines[47]}")
# parser inference model
infer_model_dir_list=$(func_parser_value "${lines[36]}")
infer_export_list=$(func_parser_value "${lines[37]}")
infer_is_quant=$(func_parser_value "${lines[38]}")
# parser inference
inference_py=$(func_parser_value "${lines[39]}")
use_gpu_key=$(func_parser_key "${lines[40]}")
use_gpu_list=$(func_parser_value "${lines[40]}")
use_mkldnn_key=$(func_parser_key "${lines[41]}")
use_mkldnn_list=$(func_parser_value "${lines[41]}")
cpu_threads_key=$(func_parser_key "${lines[42]}")
cpu_threads_list=$(func_parser_value "${lines[42]}")
batch_size_key=$(func_parser_key "${lines[43]}")
batch_size_list=$(func_parser_value "${lines[43]}")
use_trt_key=$(func_parser_key "${lines[44]}")
use_trt_list=$(func_parser_value "${lines[44]}")
precision_key=$(func_parser_key "${lines[45]}")
precision_list=$(func_parser_value "${lines[45]}")
infer_model_key=$(func_parser_key "${lines[46]}")
image_dir_key=$(func_parser_key "${lines[47]}")
infer_img_dir=$(func_parser_value "${lines[47]}")
save_log_key=$(func_parser_key "${lines[48]}")
benchmark_key=$(func_parser_key "${lines[49]}")
benchmark_value=$(func_parser_value "${lines[49]}")
infer_key1=$(func_parser_key "${lines[50]}")
infer_value1=$(func_parser_value "${lines[50]}")
LOG_PATH="./tests/output"
mkdir -p ${LOG_PATH}
......@@ -170,21 +174,24 @@ function func_inference(){
set_cpu_threads=$(func_set_params "${cpu_threads_key}" "${threads}")
set_model_dir=$(func_set_params "${infer_model_key}" "${_model_dir}")
set_infer_params1=$(func_set_params "${infer_key1}" "${infer_value1}")
#command="${_python} ${_script} ${use_gpu_key}=${use_gpu} ${use_mkldnn_key}=${use_mkldnn} ${set_cpu_threads} ${set_model_dir} ${set_batchsize} ${set_infer_data} ${set_benchmark} ${set_infer_params1} 2>&1 | tee ${_save_log_path} "
command="${_python} ${_script} ${use_gpu_key}=${use_gpu} ${use_mkldnn_key}=${use_mkldnn} ${set_cpu_threads} ${set_model_dir} ${set_batchsize} ${set_infer_data} ${set_benchmark} ${set_infer_params1} > ${_save_log_path} "
echo $command
command="${_python} ${_script} ${use_gpu_key}=${use_gpu} ${use_mkldnn_key}=${use_mkldnn} ${set_cpu_threads} ${set_model_dir} ${set_batchsize} ${set_infer_data} ${set_benchmark} ${set_infer_params1} > ${_save_log_path} 2>&1 "
eval $command
#status_check $? "${command}" "${status_log}"
last_status=${PIPESTATUS[0]}
eval "cat ${_save_log_path}"
status_check $last_status "${command}" "${status_log}"
done
done
done
elif [ ${use_gpu} = "True" ] || [ ${use_gpu} = "gpu" ]; then
for use_trt in ${use_trt_list[*]}; do
for precision in ${precision_list[*]}; do
if [ ${use_trt} = "False" ] && [ ${precision} != "fp32" ]; then
if [[ ${_flag_quant} = "False" ]] && [[ ${precision} =~ "int8" ]]; then
continue
fi
if [[ ${use_trt} = "False" || ${precision} != "int8" ]] && [ ${_flag_quant} = "True" ]; then
if [[ ${precision} =~ "fp16" || ${precision} =~ "int8" ]] && [ ${use_trt} = "False" ]; then
continue
fi
if [[ ${use_trt} = "False" || ${precision} =~ "int8" ]] && [ ${_flag_quant} = "True" ]; then
continue
fi
for batch_size in ${batch_size_list[*]}; do
......@@ -195,15 +202,18 @@ function func_inference(){
set_tensorrt=$(func_set_params "${use_trt_key}" "${use_trt}")
set_precision=$(func_set_params "${precision_key}" "${precision}")
set_model_dir=$(func_set_params "${infer_model_key}" "${_model_dir}")
#command="${_python} ${_script} ${use_gpu_key}=${use_gpu} ${set_tensorrt} ${set_precision} ${set_model_dir} ${set_batchsize} ${set_infer_data} ${set_benchmark} 2>&1 | tee ${_save_log_path}"
command="${_python} ${_script} ${use_gpu_key}=${use_gpu} ${set_tensorrt} ${set_precision} ${set_model_dir} ${set_batchsize} ${set_infer_data} ${set_benchmark} > ${_save_log_path}"
set_infer_params1=$(func_set_params "${infer_key1}" "${infer_value1}")
command="${_python} ${_script} ${use_gpu_key}=${use_gpu} ${set_tensorrt} ${set_precision} ${set_model_dir} ${set_batchsize} ${set_infer_data} ${set_benchmark} ${set_infer_params1} > ${_save_log_path} 2>&1 "
eval $command
status_check $? "${command}" "${status_log}"
last_status=${PIPESTATUS[0]}
eval "cat ${_save_log_path}"
status_check $last_status "${command}" "${status_log}"
done
done
done
else
echo "Currently does not support hardware other than CPU and GPU"
echo "Does not support hardware other than CPU and GPU Currently!"
fi
done
}
......@@ -215,9 +225,31 @@ if [ ${MODE} = "infer" ]; then
else
env="export CUDA_VISIBLE_DEVICES=${GPUID}"
fi
echo $env
# set CUDA_VISIBLE_DEVICES
eval $env
export Count=0
IFS="|"
infer_run_exports=(${infer_export_list})
infer_quant_flag=(${infer_is_quant})
set_train_params1=$(func_set_params "${train_param_key1}" "${train_param_value1}")
for infer_model in ${infer_model_dir_list[*]}; do
# run export
if [ ${infer_run_exports[Count]} != "null" ];then
set_export_weight=$(func_set_params "${export_weight}" "${infer_run_exports[Count]}/${infer_model}")
set_save_infer_key=$(func_set_params "${save_infer_key}" "${infer_run_exports[Count]}")
export_cmd="${python} ${norm_export} ${set_export_weight} ${set_train_params1} ${set_save_infer_key}"
eval $export_cmd
status_export=$?
if [ ${status_export} = 0 ];then
status_check $status_export "${export_cmd}" "${status_log}"
fi
fi
#run inference
func_inference "${python}" "${inference_py}" "${infer_model}" "${LOG_PATH}" "${infer_img_dir}" "False"
is_quant=${infer_quant_flag[Count]}
infer_model="${infer_run_exports[Count]}/${train_param_value1}"
func_inference "${python}" "${inference_py}" "${infer_model}" "${LOG_PATH}" "${infer_img_dir}" ${is_quant}
Count=$(($Count + 1))
done
else
IFS="|"
......@@ -282,7 +314,7 @@ else
# load pretrain from norm training if current trainer is pact or fpgm trainer
if [ ${trainer} = ${pact_key} ] || [ ${trainer} = ${fpgm_key} ]; then
set_pretrain="${load_norm_train_model}"
set_pretrain=$(func_set_params "${pretrain_model_key}" "${save_log}/${train_model_name}")
fi
set_save_model=$(func_set_params "${save_model_key}" "${save_log}")
......@@ -295,19 +327,14 @@ else
fi
# run train
eval "unset CUDA_VISIBLE_DEVICES"
echo $cmd
eval $cmd
status_check $? "${cmd}" "${status_log}"
set_eval_pretrain=$(func_set_params "${pretrain_model_key}" "${save_log}/${train_model_name}")
# save norm trained models to set pretrain for pact training and fpgm training
if [ ${trainer} = ${trainer_norm} ]; then
load_norm_train_model=${set_eval_pretrain}
fi
set_eval_trained_weight=$(func_set_params "weights" "${save_log}/${train_model_name}")
# run eval
if [ ${eval_py} != "null" ]; then
set_eval_params1=$(func_set_params "${eval_key1}" "${eval_value1}")
eval_cmd="${python} ${eval_py} ${set_eval_pretrain} ${set_use_gpu} ${set_eval_params1}"
eval_cmd="${python} ${eval_py} ${set_eval_trained_weight} ${set_use_gpu} ${set_eval_params1}"
eval $eval_cmd
status_check $? "${eval_cmd}" "${status_log}"
fi
......@@ -315,18 +342,16 @@ else
if [ ${run_export} != "null" ]; then
# run export model
save_infer_path="${save_log}"
export_cmd="${python} ${run_export} ${export_weight}=${save_log}/${train_model_name} ${save_infer_key}=${save_infer_path}"
echo $export_cmd
sleep 2
set_export_weight=$(func_set_params "${export_weight}" "${save_log}/${train_model_name}")
set_save_infer_key=$(func_set_params "${save_infer_key}" "${save_infer_path}")
export_cmd="${python} ${run_export} ${set_export_weight} ${set_train_params1} ${set_save_infer_key}"
eval $export_cmd
status_check $? "${export_cmd}" "${status_log}"
#run inference
eval $env
save_infer_path="${save_log}"
echo "start infer"
#sleep 1000
func_inference "${python}" "${inference_py}" "${infer_model}" "${LOG_PATH}" "${train_infer_img_dir}" "${flag_quant}"
save_infer_path="${save_log}/${train_param_value1}"
func_inference "${python}" "${inference_py}" "${save_infer_path}" "${LOG_PATH}" "${train_infer_img_dir}" "${flag_quant}"
eval "unset CUDA_VISIBLE_DEVICES"
fi
done # done with: for trainer in ${trainer_list[*]}; do
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册