Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleDetection
提交
4ea5b435
P
PaddleDetection
项目概览
PaddlePaddle
/
PaddleDetection
大约 1 年 前同步成功
通知
695
Star
11112
Fork
2696
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
184
列表
看板
标记
里程碑
合并请求
40
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleDetection
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
184
Issue
184
列表
看板
标记
里程碑
合并请求
40
合并请求
40
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
4ea5b435
编写于
7月 27, 2021
作者:
C
cnn
提交者:
GitHub
7月 27, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add ce script, and add coco_ce dataset (#3755)
上级
fceab308
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
381 addition
and
1 deletion
+381
-1
ppdet/utils/download.py
ppdet/utils/download.py
+4
-1
test/ppdet_params.txt
test/ppdet_params.txt
+48
-0
test/test.sh
test/test.sh
+329
-0
未找到文件。
ppdet/utils/download.py
浏览文件 @
4ea5b435
...
...
@@ -97,7 +97,10 @@ DATASETS = {
'https://paddledet.bj.bcebos.com/data/spine_coco.tar'
,
'7ed69ae73f842cd2a8cf4f58dc3c5535'
,
),
],
[
'annotations'
,
'images'
]),
'mot'
:
(),
'objects365'
:
()
'objects365'
:
(),
'coco_ce'
:
([(
'https://paddledet.bj.bcebos.com/data/coco_ce.tar'
,
'eadd1b79bc2f069f2744b1dd4e0c0329'
,
),
],
[])
}
DOWNLOAD_RETRY_LIMIT
=
3
...
...
test/ppdet_params.txt
0 → 100644
浏览文件 @
4ea5b435
===========================train_params===========================
model_name:yolov3_darknet53_270e_coco
python:python3.7
gpu_list:0|0,1
Global.use_gpu:True|True
Global.auto_cast:False
Global.epoch_num:lite_train_infer=2|whole_train_infer=300
Global.save_model_dir:./output/
Train.loader.batch_size_per_card:lite_train_infer=2|whole_train_infer=4
Global.pretrained_model:null
train_model_name:latest
train_infer_img_dir:./dataset/coco_ce/
null:null
##
trainer:norm_train|pact_train
norm_train:tools/train.py -c configs/yolov3/yolov3_darknet53_270e_coco.yml -o
pact_train:null
fpgm_train:null
distill_train:null
null:null
null:null
##
===========================eval_params===========================
eval:tools/eval.py -c configs/yolov3/yolov3_darknet53_270e_coco.yml -o
null:null
##
===========================infer_params===========================
Global.save_inference_dir:./output/
Global.pretrained_model:
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
distill_export:null
null:null
null:null
##
inference:deploy/python/infer.py
--device:cpu|gpu
--enable_mkldnn:False|True
--cpu_threads:1|4
--batch_size:1|2
--use_tensorrt:null
--run_mode:fluid
--model_dir:./output_inference/yolov3_darknet53_270e_coco/
--image_dir:./demo1/
--save_log_path:null
--run_benchmark:True
null:null
test/test.sh
0 → 100644
浏览文件 @
4ea5b435
#!/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
}
}
function
func_set_params
(){
key
=
$1
value
=
$2
if
[
${
key
}
=
"null"
]
;
then
echo
" "
elif
[[
${
value
}
=
"null"
]]
||
[[
${
value
}
=
" "
]]
||
[
${#
value
}
-le
0
]
;
then
echo
" "
else
echo
"
${
key
}
=
${
value
}
"
fi
}
function
func_parser_params
(){
strs
=
$1
IFS
=
":"
array
=(
${
strs
}
)
key
=
${
array
[0]
}
tmp
=
${
array
[1]
}
IFS
=
"|"
res
=
""
for
_params
in
${
tmp
[*]
}
;
do
IFS
=
"="
array
=(
${
_params
}
)
mode
=
${
array
[0]
}
value
=
${
array
[1]
}
if
[[
${
mode
}
=
${
MODE
}
]]
;
then
IFS
=
"|"
#echo $(func_set_params "${mode}" "${value}")
echo
$value
break
fi
IFS
=
"|"
done
echo
${
res
}
}
function
status_check
(){
last_status
=
$1
# the exit code
run_command
=
$2
run_log
=
$3
if
[
$last_status
-eq
0
]
;
then
echo
-e
"
\0
33[33m Run successfully with command -
${
run_command
}
!
\0
33[0m"
|
tee
-a
${
run_log
}
else
echo
-e
"
\0
33[33m Run failed with command -
${
run_command
}
!
\0
33[0m"
|
tee
-a
${
run_log
}
fi
}
IFS
=
$'
\n
'
# The training params
model_name
=
$(
func_parser_value
"
${
lines
[1]
}
"
)
python
=
$(
func_parser_value
"
${
lines
[2]
}
"
)
gpu_list
=
$(
func_parser_value
"
${
lines
[3]
}
"
)
train_use_gpu_key
=
$(
func_parser_key
"
${
lines
[4]
}
"
)
train_use_gpu_value
=
$(
func_parser_value
"
${
lines
[4]
}
"
)
autocast_list
=
$(
func_parser_value
"
${
lines
[5]
}
"
)
autocast_key
=
$(
func_parser_key
"
${
lines
[5]
}
"
)
epoch_key
=
$(
func_parser_key
"
${
lines
[6]
}
"
)
epoch_num
=
$(
func_parser_params
"
${
lines
[6]
}
"
)
save_model_key
=
$(
func_parser_key
"
${
lines
[7]
}
"
)
train_batch_key
=
$(
func_parser_key
"
${
lines
[8]
}
"
)
train_batch_value
=
$(
func_parser_params
"
${
lines
[8]
}
"
)
pretrain_model_key
=
$(
func_parser_key
"
${
lines
[9]
}
"
)
pretrain_model_value
=
$(
func_parser_value
"
${
lines
[9]
}
"
)
train_model_name
=
$(
func_parser_value
"
${
lines
[10]
}
"
)
train_infer_img_dir
=
$(
func_parser_value
"
${
lines
[11]
}
"
)
train_param_key1
=
$(
func_parser_key
"
${
lines
[12]
}
"
)
train_param_value1
=
$(
func_parser_value
"
${
lines
[12]
}
"
)
trainer_list
=
$(
func_parser_value
"
${
lines
[14]
}
"
)
trainer_norm
=
$(
func_parser_key
"
${
lines
[15]
}
"
)
norm_trainer
=
$(
func_parser_value
"
${
lines
[15]
}
"
)
pact_key
=
$(
func_parser_key
"
${
lines
[16]
}
"
)
pact_trainer
=
$(
func_parser_value
"
${
lines
[16]
}
"
)
fpgm_key
=
$(
func_parser_key
"
${
lines
[17]
}
"
)
fpgm_trainer
=
$(
func_parser_value
"
${
lines
[17]
}
"
)
distill_key
=
$(
func_parser_key
"
${
lines
[18]
}
"
)
distill_trainer
=
$(
func_parser_value
"
${
lines
[18]
}
"
)
trainer_key1
=
$(
func_parser_key
"
${
lines
[19]
}
"
)
trainer_value1
=
$(
func_parser_value
"
${
lines
[19]
}
"
)
trainer_key2
=
$(
func_parser_key
"
${
lines
[20]
}
"
)
trainer_value2
=
$(
func_parser_value
"
${
lines
[20]
}
"
)
eval_py
=
$(
func_parser_value
"
${
lines
[23]
}
"
)
eval_key1
=
$(
func_parser_key
"
${
lines
[24]
}
"
)
eval_value1
=
$(
func_parser_value
"
${
lines
[24]
}
"
)
save_infer_key
=
$(
func_parser_key
"
${
lines
[27]
}
"
)
export_weight
=
$(
func_parser_key
"
${
lines
[28]
}
"
)
norm_export
=
$(
func_parser_value
"
${
lines
[29]
}
"
)
pact_export
=
$(
func_parser_value
"
${
lines
[30]
}
"
)
fpgm_export
=
$(
func_parser_value
"
${
lines
[31]
}
"
)
distill_export
=
$(
func_parser_value
"
${
lines
[32]
}
"
)
export_key1
=
$(
func_parser_key
"
${
lines
[33]
}
"
)
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]
}
"
)
LOG_PATH
=
"./tests/output"
mkdir
-p
${
LOG_PATH
}
status_log
=
"
${
LOG_PATH
}
/results.log"
function
func_inference
(){
IFS
=
'|'
_python
=
$1
_script
=
$2
_model_dir
=
$3
_log_path
=
$4
_img_dir
=
$5
_flag_quant
=
$6
# inference
for
use_gpu
in
${
use_gpu_list
[*]
}
;
do
if
[
${
use_gpu
}
=
"False"
]
||
[
${
use_gpu
}
=
"cpu"
]
;
then
for
use_mkldnn
in
${
use_mkldnn_list
[*]
}
;
do
if
[
${
use_mkldnn
}
=
"False"
]
&&
[
${
_flag_quant
}
=
"True"
]
;
then
continue
fi
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
}
.log"
set_infer_data
=
$(
func_set_params
"
${
image_dir_key
}
"
"
${
_img_dir
}
"
)
set_benchmark
=
$(
func_set_params
"
${
benchmark_key
}
"
"
${
benchmark_value
}
"
)
set_batchsize
=
$(
func_set_params
"
${
batch_size_key
}
"
"
${
batch_size
}
"
)
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
}
"
echo
$command
#eval $command
#status_check $? "${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
continue
fi
if
[[
${
use_trt
}
=
"False"
||
${
precision
}
!=
"int8"
]]
&&
[
${
_flag_quant
}
=
"True"
]
;
then
continue
fi
for
batch_size
in
${
batch_size_list
[*]
}
;
do
_save_log_path
=
"
${
_log_path
}
/infer_gpu_usetrt_
${
use_trt
}
_precision_
${
precision
}
_batchsize_
${
batch_size
}
.log"
set_infer_data
=
$(
func_set_params
"
${
image_dir_key
}
"
"
${
_img_dir
}
"
)
set_benchmark
=
$(
func_set_params
"
${
benchmark_key
}
"
"
${
benchmark_value
}
"
)
set_batchsize
=
$(
func_set_params
"
${
batch_size_key
}
"
"
${
batch_size
}
"
)
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
}
"
eval
$command
status_check
$?
"
${
command
}
"
"
${
status_log
}
"
done
done
done
else
echo
"Currently does not support hardware other than CPU and GPU"
fi
done
}
if
[
${
MODE
}
=
"infer"
]
;
then
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
}
"
"
${
infer_model
}
"
"
${
LOG_PATH
}
"
"
${
infer_img_dir
}
"
"False"
else
IFS
=
"|"
export
Count
=
0
USE_GPU_KEY
=(
${
train_use_gpu_value
}
)
for
gpu
in
${
gpu_list
[*]
}
;
do
use_gpu
=
${
USE_GPU_KEY
[Count]
}
Count
=
$((
$Count
+
1
))
if
[
${
gpu
}
=
"-1"
]
;
then
env
=
""
elif
[
${#
gpu
}
-le
1
]
;
then
env
=
"export CUDA_VISIBLE_DEVICES=
${
gpu
}
"
eval
${
env
}
elif
[
${#
gpu
}
-le
15
]
;
then
IFS
=
","
array
=(
${
gpu
}
)
env
=
"export CUDA_VISIBLE_DEVICES=
${
array
[0]
}
"
IFS
=
"|"
else
IFS
=
";"
array
=(
${
gpu
}
)
ips
=
${
array
[0]
}
gpu
=
${
array
[1]
}
IFS
=
"|"
env
=
" "
fi
for
autocast
in
${
autocast_list
[*]
}
;
do
for
trainer
in
${
trainer_list
[*]
}
;
do
flag_quant
=
False
if
[
${
trainer
}
=
${
pact_key
}
]
;
then
run_train
=
${
pact_trainer
}
run_export
=
${
pact_export
}
flag_quant
=
True
elif
[
${
trainer
}
=
"
${
fpgm_key
}
"
]
;
then
run_train
=
${
fpgm_trainer
}
run_export
=
${
fpgm_export
}
elif
[
${
trainer
}
=
"
${
distill_key
}
"
]
;
then
run_train
=
${
distill_trainer
}
run_export
=
${
distill_export
}
elif
[
${
trainer
}
=
${
trainer_key1
}
]
;
then
run_train
=
${
trainer_value1
}
run_export
=
${
export_value1
}
elif
[[
${
trainer
}
=
${
trainer_key2
}
]]
;
then
run_train
=
${
trainer_value2
}
run_export
=
${
export_value2
}
else
run_train
=
${
norm_trainer
}
run_export
=
${
norm_export
}
fi
if
[
${
run_train
}
=
"null"
]
;
then
continue
fi
set_autocast
=
$(
func_set_params
"
${
autocast_key
}
"
"
${
autocast
}
"
)
set_epoch
=
$(
func_set_params
"
${
epoch_key
}
"
"
${
epoch_num
}
"
)
set_pretrain
=
$(
func_set_params
"
${
pretrain_model_key
}
"
"
${
pretrain_model_value
}
"
)
set_batchsize
=
$(
func_set_params
"
${
train_batch_key
}
"
"
${
train_batch_value
}
"
)
set_train_params1
=
$(
func_set_params
"
${
train_param_key1
}
"
"
${
train_param_value1
}
"
)
set_use_gpu
=
$(
func_set_params
"
${
train_use_gpu_key
}
"
"
${
use_gpu
}
"
)
save_log
=
"
${
LOG_PATH
}
/
${
trainer
}
_gpus_
${
gpu
}
_autocast_
${
autocast
}
"
# 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
}
"
fi
set_save_model
=
$(
func_set_params
"
${
save_model_key
}
"
"
${
save_log
}
"
)
if
[
${#
gpu
}
-le
2
]
;
then
# train with cpu or single gpu
cmd
=
"
${
python
}
${
run_train
}
${
set_use_gpu
}
${
set_save_model
}
${
set_epoch
}
${
set_pretrain
}
${
set_autocast
}
${
set_batchsize
}
${
set_train_params1
}
"
elif
[
${#
gpu
}
-le
15
]
;
then
# train with multi-gpu
cmd
=
"
${
python
}
-m paddle.distributed.launch --gpus=
${
gpu
}
${
run_train
}
${
set_save_model
}
${
set_epoch
}
${
set_pretrain
}
${
set_autocast
}
${
set_batchsize
}
${
set_train_params1
}
"
else
# train with multi-machine
cmd
=
"
${
python
}
-m paddle.distributed.launch --ips=
${
ips
}
--gpus=
${
gpu
}
${
run_train
}
${
set_save_model
}
${
set_pretrain
}
${
set_epoch
}
${
set_autocast
}
${
set_batchsize
}
${
set_train_params1
}
"
fi
# run train
eval
"unset CUDA_VISIBLE_DEVICES"
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
# 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
$eval_cmd
status_check
$?
"
${
eval_cmd
}
"
"
${
status_log
}
"
fi
# run export model
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
}
"
eval
$export_cmd
status_check
$?
"
${
export_cmd
}
"
"
${
status_log
}
"
#run inference
eval
$env
save_infer_path
=
"
${
save_log
}
"
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
done
# done with: for autocast in ${autocast_list[*]}; do
done
# done with: for gpu in ${gpu_list[*]}; do
fi
# end if [ ${MODE} = "infer" ]; then
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录