未验证 提交 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 ...@@ -4,15 +4,15 @@ python:python3.7
gpu_list:0 gpu_list:0
use_gpu:True use_gpu:True
auto_cast:null auto_cast:null
epoch:lite_train_infer=1|whole_train_infer=12 epoch:lite_train_infer=1|whole_train_infer=270
save_dir:./output/ save_dir:./output/
TrainReader.batch_size:lite_train_infer=2|whole_train_infer=4 TrainReader.batch_size:lite_train_infer=2|whole_train_infer=8
weights:null pretrain_weights:null
train_model_name:yolov3_darknet53_270e_coco/model_final.pdparams train_model_name:yolov3_darknet53_270e_coco/model_final.pdparams
train_infer_img_dir:./demo1/ train_infer_img_dir:./tests/demo/
null:null 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 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 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 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 ...@@ -25,24 +25,27 @@ eval:tools/eval.py -c configs/yolov3/yolov3_darknet53_270e_coco.yml -o
null:null null:null
## ##
===========================infer_params=========================== ===========================infer_params===========================
--output_dir:./output/ --output_dir:null
weights: weights:
norm_export:tools/export_model.py -c configs/yolov3/yolov3_darknet53_270e_coco.yml -o 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 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:deploy/slim/prune/export_prune_model.py 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 distill_export:null
null:null export1:null
null: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 inference:deploy/python/infer.py
--device:gpu --device:gpu|cpu
--enable_mkldnn:False|True --enable_mkldnn:False|True
--cpu_threads:1|4 --cpu_threads:1|4
--batch_size:1|2 --batch_size:1|2
--use_tensorrt:null --use_tensorrt:null
--run_mode:fluid --run_mode:fluid|trt_fp32|trt_fp16|trt_int8
--model_dir:tests/output/norm_train_gpus_0_autocast_null/yolov3_darknet53_270e_coco/ --model_dir:
--image_dir:./demo1/ --image_dir:./dataset/coco/val2017/
--save_log_path:null --save_log_path:null
--run_benchmark:True --run_benchmark:True
null:null 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]}") ...@@ -118,28 +118,32 @@ export_value1=$(func_parser_value "${lines[33]}")
export_key2=$(func_parser_key "${lines[34]}") export_key2=$(func_parser_key "${lines[34]}")
export_value2=$(func_parser_value "${lines[34]}") export_value2=$(func_parser_value "${lines[34]}")
inference_py=$(func_parser_value "${lines[36]}") # parser inference model
use_gpu_key=$(func_parser_key "${lines[37]}") infer_model_dir_list=$(func_parser_value "${lines[36]}")
use_gpu_list=$(func_parser_value "${lines[37]}") infer_export_list=$(func_parser_value "${lines[37]}")
use_mkldnn_key=$(func_parser_key "${lines[38]}") infer_is_quant=$(func_parser_value "${lines[38]}")
use_mkldnn_list=$(func_parser_value "${lines[38]}") # parser inference
cpu_threads_key=$(func_parser_key "${lines[39]}") inference_py=$(func_parser_value "${lines[39]}")
cpu_threads_list=$(func_parser_value "${lines[39]}") use_gpu_key=$(func_parser_key "${lines[40]}")
batch_size_key=$(func_parser_key "${lines[40]}") use_gpu_list=$(func_parser_value "${lines[40]}")
batch_size_list=$(func_parser_value "${lines[40]}") use_mkldnn_key=$(func_parser_key "${lines[41]}")
use_trt_key=$(func_parser_key "${lines[41]}") use_mkldnn_list=$(func_parser_value "${lines[41]}")
use_trt_list=$(func_parser_value "${lines[41]}") cpu_threads_key=$(func_parser_key "${lines[42]}")
precision_key=$(func_parser_key "${lines[42]}") cpu_threads_list=$(func_parser_value "${lines[42]}")
precision_list=$(func_parser_value "${lines[42]}") batch_size_key=$(func_parser_key "${lines[43]}")
infer_model_key=$(func_parser_key "${lines[43]}") batch_size_list=$(func_parser_value "${lines[43]}")
infer_model=$(func_parser_value "${lines[43]}") use_trt_key=$(func_parser_key "${lines[44]}")
image_dir_key=$(func_parser_key "${lines[44]}") use_trt_list=$(func_parser_value "${lines[44]}")
infer_img_dir=$(func_parser_value "${lines[44]}") precision_key=$(func_parser_key "${lines[45]}")
save_log_key=$(func_parser_key "${lines[45]}") precision_list=$(func_parser_value "${lines[45]}")
benchmark_key=$(func_parser_key "${lines[46]}") infer_model_key=$(func_parser_key "${lines[46]}")
benchmark_value=$(func_parser_value "${lines[46]}") image_dir_key=$(func_parser_key "${lines[47]}")
infer_key1=$(func_parser_key "${lines[47]}") infer_img_dir=$(func_parser_value "${lines[47]}")
infer_value1=$(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" LOG_PATH="./tests/output"
mkdir -p ${LOG_PATH} mkdir -p ${LOG_PATH}
...@@ -170,21 +174,24 @@ function func_inference(){ ...@@ -170,21 +174,24 @@ function func_inference(){
set_cpu_threads=$(func_set_params "${cpu_threads_key}" "${threads}") set_cpu_threads=$(func_set_params "${cpu_threads_key}" "${threads}")
set_model_dir=$(func_set_params "${infer_model_key}" "${_model_dir}") set_model_dir=$(func_set_params "${infer_model_key}" "${_model_dir}")
set_infer_params1=$(func_set_params "${infer_key1}" "${infer_value1}") 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} 2>&1 "
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
eval $command 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 done
done done
elif [ ${use_gpu} = "True" ] || [ ${use_gpu} = "gpu" ]; then elif [ ${use_gpu} = "True" ] || [ ${use_gpu} = "gpu" ]; then
for use_trt in ${use_trt_list[*]}; do for use_trt in ${use_trt_list[*]}; do
for precision in ${precision_list[*]}; do for precision in ${precision_list[*]}; do
if [ ${use_trt} = "False" ] && [ ${precision} != "fp32" ]; then if [[ ${_flag_quant} = "False" ]] && [[ ${precision} =~ "int8" ]]; then
continue continue
fi 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 continue
fi fi
for batch_size in ${batch_size_list[*]}; do for batch_size in ${batch_size_list[*]}; do
...@@ -195,15 +202,18 @@ function func_inference(){ ...@@ -195,15 +202,18 @@ function func_inference(){
set_tensorrt=$(func_set_params "${use_trt_key}" "${use_trt}") set_tensorrt=$(func_set_params "${use_trt_key}" "${use_trt}")
set_precision=$(func_set_params "${precision_key}" "${precision}") set_precision=$(func_set_params "${precision_key}" "${precision}")
set_model_dir=$(func_set_params "${infer_model_key}" "${_model_dir}") 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}" 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} > ${_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} ${set_infer_params1} > ${_save_log_path} 2>&1 "
eval $command 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 done
done done
else else
echo "Currently does not support hardware other than CPU and GPU" echo "Does not support hardware other than CPU and GPU Currently!"
fi fi
done done
} }
...@@ -215,9 +225,31 @@ if [ ${MODE} = "infer" ]; then ...@@ -215,9 +225,31 @@ if [ ${MODE} = "infer" ]; then
else else
env="export CUDA_VISIBLE_DEVICES=${GPUID}" env="export CUDA_VISIBLE_DEVICES=${GPUID}"
fi 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 #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 else
IFS="|" IFS="|"
...@@ -282,7 +314,7 @@ else ...@@ -282,7 +314,7 @@ else
# load pretrain from norm training if current trainer is pact or fpgm trainer # load pretrain from norm training if current trainer is pact or fpgm trainer
if [ ${trainer} = ${pact_key} ] || [ ${trainer} = ${fpgm_key} ]; then 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 fi
set_save_model=$(func_set_params "${save_model_key}" "${save_log}") set_save_model=$(func_set_params "${save_model_key}" "${save_log}")
...@@ -295,19 +327,14 @@ else ...@@ -295,19 +327,14 @@ else
fi fi
# run train # run train
eval "unset CUDA_VISIBLE_DEVICES" eval "unset CUDA_VISIBLE_DEVICES"
echo $cmd
eval $cmd eval $cmd
status_check $? "${cmd}" "${status_log}" status_check $? "${cmd}" "${status_log}"
set_eval_pretrain=$(func_set_params "${pretrain_model_key}" "${save_log}/${train_model_name}") set_eval_trained_weight=$(func_set_params "weights" "${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
# run eval # run eval
if [ ${eval_py} != "null" ]; then if [ ${eval_py} != "null" ]; then
set_eval_params1=$(func_set_params "${eval_key1}" "${eval_value1}") 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 eval $eval_cmd
status_check $? "${eval_cmd}" "${status_log}" status_check $? "${eval_cmd}" "${status_log}"
fi fi
...@@ -315,18 +342,16 @@ else ...@@ -315,18 +342,16 @@ else
if [ ${run_export} != "null" ]; then if [ ${run_export} != "null" ]; then
# run export model # run export model
save_infer_path="${save_log}" save_infer_path="${save_log}"
export_cmd="${python} ${run_export} ${export_weight}=${save_log}/${train_model_name} ${save_infer_key}=${save_infer_path}" set_export_weight=$(func_set_params "${export_weight}" "${save_log}/${train_model_name}")
echo $export_cmd set_save_infer_key=$(func_set_params "${save_infer_key}" "${save_infer_path}")
sleep 2 export_cmd="${python} ${run_export} ${set_export_weight} ${set_train_params1} ${set_save_infer_key}"
eval $export_cmd eval $export_cmd
status_check $? "${export_cmd}" "${status_log}" status_check $? "${export_cmd}" "${status_log}"
#run inference #run inference
eval $env eval $env
save_infer_path="${save_log}" save_infer_path="${save_log}/${train_param_value1}"
echo "start infer" func_inference "${python}" "${inference_py}" "${save_infer_path}" "${LOG_PATH}" "${train_infer_img_dir}" "${flag_quant}"
#sleep 1000
func_inference "${python}" "${inference_py}" "${infer_model}" "${LOG_PATH}" "${train_infer_img_dir}" "${flag_quant}"
eval "unset CUDA_VISIBLE_DEVICES" eval "unset CUDA_VISIBLE_DEVICES"
fi fi
done # done with: for trainer in ${trainer_list[*]}; do 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.
先完成此消息的编辑!
想要评论请 注册