Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
wangsen
paddle_dbnet
Commits
55d71902
Commit
55d71902
authored
Nov 12, 2021
by
Leif
Browse files
Merge remote-tracking branch 'origin/dygraph' into dygraph
parents
1d03fd33
10b7e706
Changes
77
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
257 additions
and
80 deletions
+257
-80
test_tipc/test_inference_cpp.sh
test_tipc/test_inference_cpp.sh
+25
-25
test_tipc/test_inference_jeston.sh
test_tipc/test_inference_jeston.sh
+87
-0
test_tipc/test_lite_arm_cpu_cpp.sh
test_tipc/test_lite_arm_cpu_cpp.sh
+60
-0
test_tipc/test_paddle2onnx.sh
test_tipc/test_paddle2onnx.sh
+22
-20
test_tipc/test_serving.sh
test_tipc/test_serving.sh
+1
-1
test_tipc/test_train_inference_python.sh
test_tipc/test_train_inference_python.sh
+15
-6
tools/__init__.py
tools/__init__.py
+14
-0
tools/eval.py
tools/eval.py
+2
-2
tools/export_center.py
tools/export_center.py
+2
-2
tools/export_model.py
tools/export_model.py
+2
-2
tools/infer/utility.py
tools/infer/utility.py
+13
-6
tools/infer_cls.py
tools/infer_cls.py
+2
-2
tools/infer_det.py
tools/infer_det.py
+2
-2
tools/infer_e2e.py
tools/infer_e2e.py
+2
-2
tools/infer_rec.py
tools/infer_rec.py
+3
-5
tools/infer_table.py
tools/infer_table.py
+3
-3
tools/train.py
tools/train.py
+2
-2
No files found.
test_tipc/test_inference_cpp.sh
View file @
55d71902
...
@@ -2,38 +2,38 @@
...
@@ -2,38 +2,38 @@
source
test_tipc/common_func.sh
source
test_tipc/common_func.sh
FILENAME
=
$1
FILENAME
=
$1
dataline
=
$(
awk
'NR==
52
, NR==
6
6{print}'
$FILENAME
)
dataline
=
$(
awk
'NR==
1
, NR==
1
6{print}'
$FILENAME
)
# parser params
# parser params
IFS
=
$'
\n
'
IFS
=
$'
\n
'
lines
=(
${
dataline
}
)
lines
=(
${
dataline
}
)
# parser cpp inference model
# parser cpp inference model
use_opencv
=
$(
func_parser_value
"
${
lines
[1]
}
"
)
model_name
=
$(
func_parser_value
"
${
lines
[1]
}
"
)
cpp_infer_model_dir_list
=
$(
func_parser_value
"
${
lines
[2]
}
"
)
use_opencv
=
$(
func_parser_value
"
${
lines
[2]
}
"
)
cpp_infer_is_quant
=
$(
func_parser_value
"
${
lines
[3]
}
"
)
cpp_infer_model_dir_list
=
$(
func_parser_value
"
${
lines
[3]
}
"
)
cpp_infer_is_quant
=
$(
func_parser_value
"
${
lines
[4]
}
"
)
# parser cpp inference
# parser cpp inference
inference_cmd
=
$(
func_parser_value
"
${
lines
[4]
}
"
)
inference_cmd
=
$(
func_parser_value
"
${
lines
[5]
}
"
)
cpp_use_gpu_key
=
$(
func_parser_key
"
${
lines
[5]
}
"
)
cpp_use_gpu_key
=
$(
func_parser_key
"
${
lines
[6]
}
"
)
cpp_use_gpu_list
=
$(
func_parser_value
"
${
lines
[5]
}
"
)
cpp_use_gpu_list
=
$(
func_parser_value
"
${
lines
[6]
}
"
)
cpp_use_mkldnn_key
=
$(
func_parser_key
"
${
lines
[6]
}
"
)
cpp_use_mkldnn_key
=
$(
func_parser_key
"
${
lines
[7]
}
"
)
cpp_use_mkldnn_list
=
$(
func_parser_value
"
${
lines
[6]
}
"
)
cpp_use_mkldnn_list
=
$(
func_parser_value
"
${
lines
[7]
}
"
)
cpp_cpu_threads_key
=
$(
func_parser_key
"
${
lines
[7]
}
"
)
cpp_cpu_threads_key
=
$(
func_parser_key
"
${
lines
[8]
}
"
)
cpp_cpu_threads_list
=
$(
func_parser_value
"
${
lines
[7]
}
"
)
cpp_cpu_threads_list
=
$(
func_parser_value
"
${
lines
[8]
}
"
)
cpp_batch_size_key
=
$(
func_parser_key
"
${
lines
[8]
}
"
)
cpp_batch_size_key
=
$(
func_parser_key
"
${
lines
[9]
}
"
)
cpp_batch_size_list
=
$(
func_parser_value
"
${
lines
[8]
}
"
)
cpp_batch_size_list
=
$(
func_parser_value
"
${
lines
[9]
}
"
)
cpp_use_trt_key
=
$(
func_parser_key
"
${
lines
[9]
}
"
)
cpp_use_trt_key
=
$(
func_parser_key
"
${
lines
[10]
}
"
)
cpp_use_trt_list
=
$(
func_parser_value
"
${
lines
[9]
}
"
)
cpp_use_trt_list
=
$(
func_parser_value
"
${
lines
[10]
}
"
)
cpp_precision_key
=
$(
func_parser_key
"
${
lines
[10]
}
"
)
cpp_precision_key
=
$(
func_parser_key
"
${
lines
[11]
}
"
)
cpp_precision_list
=
$(
func_parser_value
"
${
lines
[10]
}
"
)
cpp_precision_list
=
$(
func_parser_value
"
${
lines
[11]
}
"
)
cpp_infer_model_key
=
$(
func_parser_key
"
${
lines
[11]
}
"
)
cpp_infer_model_key
=
$(
func_parser_key
"
${
lines
[12]
}
"
)
cpp_image_dir_key
=
$(
func_parser_key
"
${
lines
[12]
}
"
)
cpp_image_dir_key
=
$(
func_parser_key
"
${
lines
[13]
}
"
)
cpp_infer_img_dir
=
$(
func_parser_value
"
${
lines
[12]
}
"
)
cpp_infer_img_dir
=
$(
func_parser_value
"
${
lines
[13]
}
"
)
cpp_infer_key1
=
$(
func_parser_key
"
${
lines
[13]
}
"
)
cpp_infer_key1
=
$(
func_parser_key
"
${
lines
[14]
}
"
)
cpp_infer_value1
=
$(
func_parser_value
"
${
lines
[13]
}
"
)
cpp_infer_value1
=
$(
func_parser_value
"
${
lines
[14]
}
"
)
cpp_benchmark_key
=
$(
func_parser_key
"
${
lines
[14]
}
"
)
cpp_benchmark_key
=
$(
func_parser_key
"
${
lines
[15]
}
"
)
cpp_benchmark_value
=
$(
func_parser_value
"
${
lines
[14]
}
"
)
cpp_benchmark_value
=
$(
func_parser_value
"
${
lines
[15]
}
"
)
LOG_PATH
=
"./test_tipc/output"
LOG_PATH
=
"./test_tipc/output"
mkdir
-p
${
LOG_PATH
}
mkdir
-p
${
LOG_PATH
}
...
...
test_tipc/test_inference_jeston.sh
0 → 100644
View file @
55d71902
#!/bin/bash
source
test_tipc/common_func.sh
source
test_tipc/test_train_inference_python.sh
FILENAME
=
$1
# MODE be one of ['whole_infer']
MODE
=
$2
dataline
=
$(
awk
'NR==1, NR==17{print}'
$FILENAME
)
# parser params
IFS
=
$'
\n
'
lines
=(
${
dataline
}
)
model_name
=
$(
func_parser_value
"
${
lines
[1]
}
"
)
python
=
$(
func_parser_value
"
${
lines
[2]
}
"
)
infer_model_dir_list
=
$(
func_parser_value
"
${
lines
[3]
}
"
)
infer_export_list
=
$(
func_parser_value
"
${
lines
[4]
}
"
)
infer_is_quant
=
$(
func_parser_value
"
${
lines
[5]
}
"
)
# parser inference
inference_py
=
$(
func_parser_value
"
${
lines
[6]
}
"
)
use_gpu_key
=
$(
func_parser_key
"
${
lines
[7]
}
"
)
use_gpu_list
=
$(
func_parser_value
"
${
lines
[7]
}
"
)
use_mkldnn_key
=
$(
func_parser_key
"
${
lines
[8]
}
"
)
use_mkldnn_list
=
$(
func_parser_value
"
${
lines
[8]
}
"
)
cpu_threads_key
=
$(
func_parser_key
"
${
lines
[9]
}
"
)
cpu_threads_list
=
$(
func_parser_value
"
${
lines
[9]
}
"
)
batch_size_key
=
$(
func_parser_key
"
${
lines
[10]
}
"
)
batch_size_list
=
$(
func_parser_value
"
${
lines
[10]
}
"
)
use_trt_key
=
$(
func_parser_key
"
${
lines
[11]
}
"
)
use_trt_list
=
$(
func_parser_value
"
${
lines
[11]
}
"
)
precision_key
=
$(
func_parser_key
"
${
lines
[12]
}
"
)
precision_list
=
$(
func_parser_value
"
${
lines
[12]
}
"
)
infer_model_key
=
$(
func_parser_key
"
${
lines
[13]
}
"
)
image_dir_key
=
$(
func_parser_key
"
${
lines
[14]
}
"
)
infer_img_dir
=
$(
func_parser_value
"
${
lines
[14]
}
"
)
save_log_key
=
$(
func_parser_key
"
${
lines
[15]
}
"
)
benchmark_key
=
$(
func_parser_key
"
${
lines
[16]
}
"
)
benchmark_value
=
$(
func_parser_value
"
${
lines
[16]
}
"
)
infer_key1
=
$(
func_parser_key
"
${
lines
[17]
}
"
)
infer_value1
=
$(
func_parser_value
"
${
lines
[17]
}
"
)
LOG_PATH
=
"./test_tipc/output"
mkdir
-p
${
LOG_PATH
}
status_log
=
"
${
LOG_PATH
}
/results_python.log"
if
[
${
MODE
}
=
"whole_infer"
]
;
then
GPUID
=
$3
if
[
${#
GPUID
}
-le
0
]
;
then
env
=
" "
else
env
=
"export CUDA_VISIBLE_DEVICES=
${
GPUID
}
"
fi
# set CUDA_VISIBLE_DEVICES
eval
$env
export
Count
=
0
IFS
=
"|"
infer_run_exports
=(
${
infer_export_list
}
)
infer_quant_flag
=(
${
infer_is_quant
}
)
for
infer_model
in
${
infer_model_dir_list
[*]
}
;
do
# run export
if
[
${
infer_run_exports
[Count]
}
!=
"null"
]
;
then
save_infer_dir
=
$(
dirname
$infer_model
)
set_export_weight
=
$(
func_set_params
"
${
export_weight
}
"
"
${
infer_model
}
"
)
set_save_infer_key
=
$(
func_set_params
"
${
save_infer_key
}
"
"
${
save_infer_dir
}
"
)
export_cmd
=
"
${
python
}
${
infer_run_exports
[Count]
}
${
set_export_weight
}
${
set_save_infer_key
}
"
echo
${
infer_run_exports
[Count]
}
echo
$export_cmd
eval
$export_cmd
status_export
=
$?
status_check
$status_export
"
${
export_cmd
}
"
"
${
status_log
}
"
else
save_infer_dir
=
${
infer_model
}
fi
#run inference
is_quant
=
${
infer_quant_flag
[Count]
}
if
[
${
MODE
}
=
"klquant_infer"
]
;
then
is_quant
=
"True"
fi
func_inference
"
${
python
}
"
"
${
inference_py
}
"
"
${
save_infer_dir
}
"
"
${
LOG_PATH
}
"
"
${
infer_img_dir
}
"
${
is_quant
}
Count
=
$((
$Count
+
1
))
done
fi
test_tipc/test_lite.sh
→
test_tipc/test_lite
_arm_cpu_cpp
.sh
View file @
55d71902
...
@@ -3,8 +3,7 @@ source ./common_func.sh
...
@@ -3,8 +3,7 @@ source ./common_func.sh
export
LD_LIBRARY_PATH
=
${
PWD
}
:
$LD_LIBRARY_PATH
export
LD_LIBRARY_PATH
=
${
PWD
}
:
$LD_LIBRARY_PATH
FILENAME
=
$1
FILENAME
=
$1
dataline
=
$(
awk
'NR==102, NR==111{print}'
$FILENAME
)
dataline
=
$(
cat
$FILENAME
)
echo
$dataline
# parser params
# parser params
IFS
=
$'
\n
'
IFS
=
$'
\n
'
lines
=(
${
dataline
}
)
lines
=(
${
dataline
}
)
...
@@ -12,13 +11,14 @@ lines=(${dataline})
...
@@ -12,13 +11,14 @@ lines=(${dataline})
# parser lite inference
# parser lite inference
lite_inference_cmd
=
$(
func_parser_value
"
${
lines
[1]
}
"
)
lite_inference_cmd
=
$(
func_parser_value
"
${
lines
[1]
}
"
)
lite_model_dir_list
=
$(
func_parser_value
"
${
lines
[2]
}
"
)
lite_model_dir_list
=
$(
func_parser_value
"
${
lines
[2]
}
"
)
lite_cpu_threads_list
=
$(
func_parser_value
"
${
lines
[3]
}
"
)
runtime_device
=
$(
func_parser_value
"
${
lines
[3]
}
"
)
lite_batch_size_list
=
$(
func_parser_value
"
${
lines
[4]
}
"
)
lite_cpu_threads_list
=
$(
func_parser_value
"
${
lines
[4]
}
"
)
lite_power_mode_list
=
$(
func_parser_value
"
${
lines
[5]
}
"
)
lite_batch_size_list
=
$(
func_parser_value
"
${
lines
[5]
}
"
)
lite_infer_img_dir_list
=
$(
func_parser_value
"
${
lines
[6]
}
"
)
lite_infer_img_dir_list
=
$(
func_parser_value
"
${
lines
[8]
}
"
)
lite_config_dir
=
$(
func_parser_value
"
${
lines
[7]
}
"
)
lite_config_dir
=
$(
func_parser_value
"
${
lines
[9]
}
"
)
lite_rec_dict_dir
=
$(
func_parser_value
"
${
lines
[8]
}
"
)
lite_rec_dict_dir
=
$(
func_parser_value
"
${
lines
[10]
}
"
)
lite_benchmark_value
=
$(
func_parser_value
"
${
lines
[9]
}
"
)
lite_benchmark_value
=
$(
func_parser_value
"
${
lines
[11]
}
"
)
LOG_PATH
=
"./output"
LOG_PATH
=
"./output"
mkdir
-p
${
LOG_PATH
}
mkdir
-p
${
LOG_PATH
}
...
@@ -37,23 +37,14 @@ function func_lite(){
...
@@ -37,23 +37,14 @@ function func_lite(){
else
else
precision
=
"FP32"
precision
=
"FP32"
fi
fi
is_single_img
=
$(
echo
$_img_dir
|
grep
-E
".jpg|.jpeg|.png|.JPEG|.JPG"
)
if
[[
"
$is_single_img
"
!=
""
]]
;
then
single_img
=
"True"
else
single_img
=
"False"
fi
# lite inference
# lite inference
for
num_threads
in
${
lite_cpu_threads_list
[*]
}
;
do
for
num_threads
in
${
lite_cpu_threads_list
[*]
}
;
do
for
power_mode
in
${
lite_power_mode_list
[*]
}
;
do
for
batchsize
in
${
lite_batch_size_list
[*]
}
;
do
for
batchsize
in
${
lite_batch_size_list
[*]
}
;
do
_save_log_path
=
"
${
_log_path
}
/lite_
${
_lite_model
}
_runtime_device_
${
runtime_device
}
_precision_
${
precision
}
_batchsize_
${
batchsize
}
_threads_
${
num_threads
}
.log"
model_name
=
$(
echo
$lite_model
|
awk
-F
"/"
'{print $NF}'
)
command
=
"
${
_script
}
${
_lite_model
}
${
runtime_device
}
${
precision
}
${
num_threads
}
${
batchsize
}
${
_img_dir
}
${
_config
}
${
lite_benchmark_value
}
>
${
_save_log_path
}
2>&1"
_save_log_path
=
"
${
_log_path
}
/lite_
${
model_name
}
_precision_
${
precision
}
_batchsize_
${
batchsize
}
_threads_
${
num_threads
}
_powermode_
${
power_mode
}
_singleimg_
${
single_img
}
.log"
eval
${
command
}
command
=
"
${
_script
}
${
lite_model
}
${
precision
}
${
num_threads
}
${
batchsize
}
${
power_mode
}
${
_img_dir
}
${
_config
}
${
lite_benchmark_value
}
>
${
_save_log_path
}
2>&1"
status_check
$?
"
${
command
}
"
"
${
status_log
}
"
eval
${
command
}
status_check
$?
"
${
command
}
"
"
${
status_log
}
"
done
done
done
done
done
}
}
...
@@ -64,6 +55,6 @@ IFS="|"
...
@@ -64,6 +55,6 @@ IFS="|"
for
lite_model
in
${
lite_model_dir_list
[*]
}
;
do
for
lite_model
in
${
lite_model_dir_list
[*]
}
;
do
#run lite inference
#run lite inference
for
img_dir
in
${
lite_infer_img_dir_list
[*]
}
;
do
for
img_dir
in
${
lite_infer_img_dir_list
[*]
}
;
do
func_lite
"
${
lite_inference_cmd
}
"
"
${
lite_model
}
"
"
${
LOG_PATH
}
"
"
${
img_dir
}
"
"
${
lite_config_dir
}
"
func_lite
"
${
lite_inference_cmd
}
"
"
${
lite_model
}
_opt.nb
"
"
${
LOG_PATH
}
"
"
${
img_dir
}
"
"
${
lite_config_dir
}
"
done
done
done
done
test_tipc/test_paddle2onnx.sh
View file @
55d71902
...
@@ -11,31 +11,33 @@ python=$(func_parser_value "${lines[2]}")
...
@@ -11,31 +11,33 @@ python=$(func_parser_value "${lines[2]}")
# parser params
# parser params
dataline
=
$(
awk
'NR==1
11
, NR==12
3
{print}'
$FILENAME
)
dataline
=
$(
awk
'NR==1, NR==12{print}'
$FILENAME
)
IFS
=
$'
\n
'
IFS
=
$'
\n
'
lines
=(
${
dataline
}
)
lines
=(
${
dataline
}
)
# parser paddle2onnx
# parser paddle2onnx
padlle2onnx_cmd
=
$(
func_parser_value
"
${
lines
[1]
}
"
)
model_name
=
$(
func_parser_value
"
${
lines
[1]
}
"
)
infer_model_dir_key
=
$(
func_parser_key
"
${
lines
[2]
}
"
)
python
=
$(
func_parser_value
"
${
lines
[2]
}
"
)
infer_model_dir_value
=
$(
func_parser_value
"
${
lines
[2]
}
"
)
padlle2onnx_cmd
=
$(
func_parser_value
"
${
lines
[3]
}
"
)
model_filename_key
=
$(
func_parser_key
"
${
lines
[3]
}
"
)
infer_model_dir_key
=
$(
func_parser_key
"
${
lines
[4]
}
"
)
model_filename_value
=
$(
func_parser_value
"
${
lines
[3]
}
"
)
infer_model_dir_value
=
$(
func_parser_value
"
${
lines
[4]
}
"
)
params_filename_key
=
$(
func_parser_key
"
${
lines
[4]
}
"
)
model_filename_key
=
$(
func_parser_key
"
${
lines
[5]
}
"
)
params_filename_value
=
$(
func_parser_value
"
${
lines
[4]
}
"
)
model_filename_value
=
$(
func_parser_value
"
${
lines
[5]
}
"
)
save_file_key
=
$(
func_parser_key
"
${
lines
[5]
}
"
)
params_filename_key
=
$(
func_parser_key
"
${
lines
[6]
}
"
)
save_file_value
=
$(
func_parser_value
"
${
lines
[5]
}
"
)
params_filename_value
=
$(
func_parser_value
"
${
lines
[6]
}
"
)
opset_version_key
=
$(
func_parser_key
"
${
lines
[6]
}
"
)
save_file_key
=
$(
func_parser_key
"
${
lines
[7]
}
"
)
opset_version_value
=
$(
func_parser_value
"
${
lines
[6]
}
"
)
save_file_value
=
$(
func_parser_value
"
${
lines
[7]
}
"
)
enable_onnx_checker_key
=
$(
func_parser_key
"
${
lines
[7]
}
"
)
opset_version_key
=
$(
func_parser_key
"
${
lines
[8]
}
"
)
enable_onnx_checker_value
=
$(
func_parser_value
"
${
lines
[7]
}
"
)
opset_version_value
=
$(
func_parser_value
"
${
lines
[8]
}
"
)
enable_onnx_checker_key
=
$(
func_parser_key
"
${
lines
[9]
}
"
)
enable_onnx_checker_value
=
$(
func_parser_value
"
${
lines
[9]
}
"
)
# parser onnx inference
# parser onnx inference
inference_py
=
$(
func_parser_value
"
${
lines
[
8
]
}
"
)
inference_py
=
$(
func_parser_value
"
${
lines
[
10
]
}
"
)
use_gpu_key
=
$(
func_parser_key
"
${
lines
[
9
]
}
"
)
use_gpu_key
=
$(
func_parser_key
"
${
lines
[
11
]
}
"
)
use_gpu_value
=
$(
func_parser_value
"
${
lines
[
9
]
}
"
)
use_gpu_value
=
$(
func_parser_value
"
${
lines
[
11
]
}
"
)
det_model_key
=
$(
func_parser_key
"
${
lines
[1
0
]
}
"
)
det_model_key
=
$(
func_parser_key
"
${
lines
[1
2
]
}
"
)
image_dir_key
=
$(
func_parser_key
"
${
lines
[1
1
]
}
"
)
image_dir_key
=
$(
func_parser_key
"
${
lines
[1
3
]
}
"
)
image_dir_value
=
$(
func_parser_value
"
${
lines
[1
1
]
}
"
)
image_dir_value
=
$(
func_parser_value
"
${
lines
[1
3
]
}
"
)
LOG_PATH
=
"./test_tipc/output"
LOG_PATH
=
"./test_tipc/output"
...
...
test_tipc/test_serving.sh
View file @
55d71902
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
source
test_tipc/common_func.sh
source
test_tipc/common_func.sh
FILENAME
=
$1
FILENAME
=
$1
dataline
=
$(
awk
'NR==
67
, NR==8
4
{print}'
$FILENAME
)
dataline
=
$(
awk
'NR==
1
, NR==
1
8{print}'
$FILENAME
)
# parser params
# parser params
IFS
=
$'
\n
'
IFS
=
$'
\n
'
...
...
test_tipc/test_train_inference_python.sh
View file @
55d71902
...
@@ -244,7 +244,7 @@ else
...
@@ -244,7 +244,7 @@ else
export
Count
=
0
export
Count
=
0
USE_GPU_KEY
=(
${
train_use_gpu_value
}
)
USE_GPU_KEY
=(
${
train_use_gpu_value
}
)
for
gpu
in
${
gpu_list
[*]
}
;
do
for
gpu
in
${
gpu_list
[*]
}
;
do
use_gpu
=
${
USE_GPU_KEY
[Count]
}
train_
use_gpu
=
${
USE_GPU_KEY
[Count]
}
Count
=
$((
$Count
+
1
))
Count
=
$((
$Count
+
1
))
ips
=
""
ips
=
""
if
[
${
gpu
}
=
"-1"
]
;
then
if
[
${
gpu
}
=
"-1"
]
;
then
...
@@ -302,11 +302,20 @@ else
...
@@ -302,11 +302,20 @@ else
set_pretrain
=
$(
func_set_params
"
${
pretrain_model_key
}
"
"
${
pretrain_model_value
}
"
)
set_pretrain
=
$(
func_set_params
"
${
pretrain_model_key
}
"
"
${
pretrain_model_value
}
"
)
set_batchsize
=
$(
func_set_params
"
${
train_batch_key
}
"
"
${
train_batch_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_train_params1
=
$(
func_set_params
"
${
train_param_key1
}
"
"
${
train_param_value1
}
"
)
set_use_gpu
=
$(
func_set_params
"
${
train_use_gpu_key
}
"
"
${
use_gpu
}
"
)
set_use_gpu
=
$(
func_set_params
"
${
train_use_gpu_key
}
"
"
${
train_use_gpu
}
"
)
save_log
=
"
${
LOG_PATH
}
/
${
trainer
}
_gpus_
${
gpu
}
_autocast_
${
autocast
}
"
if
[
${#
ips
}
-le
26
]
;
then
save_log
=
"
${
LOG_PATH
}
/
${
trainer
}
_gpus_
${
gpu
}
_autocast_
${
autocast
}
"
nodes
=
1
else
IFS
=
","
ips_array
=(
${
ips
}
)
IFS
=
"|"
nodes
=
${#
ips_array
[@]
}
save_log
=
"
${
LOG_PATH
}
/
${
trainer
}
_gpus_
${
gpu
}
_autocast_
${
autocast
}
_nodes_
${
nodes
}
"
fi
# 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
}
])
&&
[
${
nodes
}
-le
1
]
;
then
set_pretrain
=
"
${
load_norm_train_model
}
"
set_pretrain
=
"
${
load_norm_train_model
}
"
fi
fi
...
@@ -325,7 +334,7 @@ else
...
@@ -325,7 +334,7 @@ else
set_eval_pretrain
=
$(
func_set_params
"
${
pretrain_model_key
}
"
"
${
save_log
}
/
${
train_model_name
}
"
)
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
# save norm trained models to set pretrain for pact training and fpgm training
if
[
${
trainer
}
=
${
trainer_norm
}
]
;
then
if
[
${
trainer
}
=
${
trainer_norm
}
]
&&
[
${
nodes
}
-le
1]
;
then
load_norm_train_model
=
${
set_eval_pretrain
}
load_norm_train_model
=
${
set_eval_pretrain
}
fi
fi
# run eval
# run eval
...
...
tools/__init__.py
0 → 100644
View file @
55d71902
# Copyright (c) 2021 PaddlePaddle Authors. All Rights Reserved.
# Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
tools/eval.py
View file @
55d71902
...
@@ -27,7 +27,7 @@ from ppocr.data import build_dataloader
...
@@ -27,7 +27,7 @@ from ppocr.data import build_dataloader
from
ppocr.modeling.architectures
import
build_model
from
ppocr.modeling.architectures
import
build_model
from
ppocr.postprocess
import
build_post_process
from
ppocr.postprocess
import
build_post_process
from
ppocr.metrics
import
build_metric
from
ppocr.metrics
import
build_metric
from
ppocr.utils.save_load
import
init
_model
,
load_dygraph_params
from
ppocr.utils.save_load
import
load
_model
from
ppocr.utils.utility
import
print_dict
from
ppocr.utils.utility
import
print_dict
import
tools.program
as
program
import
tools.program
as
program
...
@@ -60,7 +60,7 @@ def main():
...
@@ -60,7 +60,7 @@ def main():
else
:
else
:
model_type
=
None
model_type
=
None
best_model_dict
=
load_
dygraph_params
(
config
,
model
,
logger
,
None
)
best_model_dict
=
load_
model
(
config
,
model
)
if
len
(
best_model_dict
):
if
len
(
best_model_dict
):
logger
.
info
(
'metric in ckpt ***************'
)
logger
.
info
(
'metric in ckpt ***************'
)
for
k
,
v
in
best_model_dict
.
items
():
for
k
,
v
in
best_model_dict
.
items
():
...
...
tools/export_center.py
View file @
55d71902
...
@@ -27,7 +27,7 @@ sys.path.append(os.path.abspath(os.path.join(__dir__, '..')))
...
@@ -27,7 +27,7 @@ sys.path.append(os.path.abspath(os.path.join(__dir__, '..')))
from
ppocr.data
import
build_dataloader
from
ppocr.data
import
build_dataloader
from
ppocr.modeling.architectures
import
build_model
from
ppocr.modeling.architectures
import
build_model
from
ppocr.postprocess
import
build_post_process
from
ppocr.postprocess
import
build_post_process
from
ppocr.utils.save_load
import
init
_model
,
load_dygraph_params
from
ppocr.utils.save_load
import
load
_model
from
ppocr.utils.utility
import
print_dict
from
ppocr.utils.utility
import
print_dict
import
tools.program
as
program
import
tools.program
as
program
...
@@ -57,7 +57,7 @@ def main():
...
@@ -57,7 +57,7 @@ def main():
model
=
build_model
(
config
[
'Architecture'
])
model
=
build_model
(
config
[
'Architecture'
])
best_model_dict
=
load_
dygraph_params
(
config
,
model
,
logger
,
None
)
best_model_dict
=
load_
model
(
config
,
model
)
if
len
(
best_model_dict
):
if
len
(
best_model_dict
):
logger
.
info
(
'metric in ckpt ***************'
)
logger
.
info
(
'metric in ckpt ***************'
)
for
k
,
v
in
best_model_dict
.
items
():
for
k
,
v
in
best_model_dict
.
items
():
...
...
tools/export_model.py
View file @
55d71902
...
@@ -26,7 +26,7 @@ from paddle.jit import to_static
...
@@ -26,7 +26,7 @@ from paddle.jit import to_static
from
ppocr.modeling.architectures
import
build_model
from
ppocr.modeling.architectures
import
build_model
from
ppocr.postprocess
import
build_post_process
from
ppocr.postprocess
import
build_post_process
from
ppocr.utils.save_load
import
init
_model
from
ppocr.utils.save_load
import
load
_model
from
ppocr.utils.logging
import
get_logger
from
ppocr.utils.logging
import
get_logger
from
tools.program
import
load_config
,
merge_config
,
ArgsParser
from
tools.program
import
load_config
,
merge_config
,
ArgsParser
...
@@ -107,7 +107,7 @@ def main():
...
@@ -107,7 +107,7 @@ def main():
else
:
# base rec model
else
:
# base rec model
config
[
"Architecture"
][
"Head"
][
"out_channels"
]
=
char_num
config
[
"Architecture"
][
"Head"
][
"out_channels"
]
=
char_num
model
=
build_model
(
config
[
"Architecture"
])
model
=
build_model
(
config
[
"Architecture"
])
init
_model
(
config
,
model
)
load
_model
(
config
,
model
)
model
.
eval
()
model
.
eval
()
save_path
=
config
[
"Global"
][
"save_inference_dir"
]
save_path
=
config
[
"Global"
][
"save_inference_dir"
]
...
...
tools/infer/utility.py
View file @
55d71902
...
@@ -17,7 +17,7 @@ import os
...
@@ -17,7 +17,7 @@ import os
import
sys
import
sys
import
cv2
import
cv2
import
numpy
as
np
import
numpy
as
np
import
json
import
paddle
from
PIL
import
Image
,
ImageDraw
,
ImageFont
from
PIL
import
Image
,
ImageDraw
,
ImageFont
import
math
import
math
from
paddle
import
inference
from
paddle
import
inference
...
@@ -205,7 +205,7 @@ def create_predictor(args, mode, logger):
...
@@ -205,7 +205,7 @@ def create_predictor(args, mode, logger):
"nearest_interp_v2_0.tmp_0"
:
[
1
,
256
,
2
,
2
]
"nearest_interp_v2_0.tmp_0"
:
[
1
,
256
,
2
,
2
]
}
}
max_input_shape
=
{
max_input_shape
=
{
"x"
:
[
1
,
3
,
2000
,
200
0
],
"x"
:
[
1
,
3
,
1280
,
128
0
],
"conv2d_92.tmp_0"
:
[
1
,
120
,
400
,
400
],
"conv2d_92.tmp_0"
:
[
1
,
120
,
400
,
400
],
"conv2d_91.tmp_0"
:
[
1
,
24
,
200
,
200
],
"conv2d_91.tmp_0"
:
[
1
,
24
,
200
,
200
],
"conv2d_59.tmp_0"
:
[
1
,
96
,
400
,
400
],
"conv2d_59.tmp_0"
:
[
1
,
96
,
400
,
400
],
...
@@ -255,16 +255,16 @@ def create_predictor(args, mode, logger):
...
@@ -255,16 +255,16 @@ def create_predictor(args, mode, logger):
opt_input_shape
.
update
(
opt_pact_shape
)
opt_input_shape
.
update
(
opt_pact_shape
)
elif
mode
==
"rec"
:
elif
mode
==
"rec"
:
min_input_shape
=
{
"x"
:
[
1
,
3
,
32
,
10
]}
min_input_shape
=
{
"x"
:
[
1
,
3
,
32
,
10
]}
max_input_shape
=
{
"x"
:
[
args
.
rec_batch_num
,
3
,
32
,
2000
]}
max_input_shape
=
{
"x"
:
[
args
.
rec_batch_num
,
3
,
32
,
1024
]}
opt_input_shape
=
{
"x"
:
[
args
.
rec_batch_num
,
3
,
32
,
320
]}
opt_input_shape
=
{
"x"
:
[
args
.
rec_batch_num
,
3
,
32
,
320
]}
elif
mode
==
"cls"
:
elif
mode
==
"cls"
:
min_input_shape
=
{
"x"
:
[
1
,
3
,
48
,
10
]}
min_input_shape
=
{
"x"
:
[
1
,
3
,
48
,
10
]}
max_input_shape
=
{
"x"
:
[
args
.
rec_batch_num
,
3
,
48
,
2000
]}
max_input_shape
=
{
"x"
:
[
args
.
rec_batch_num
,
3
,
48
,
1024
]}
opt_input_shape
=
{
"x"
:
[
args
.
rec_batch_num
,
3
,
48
,
320
]}
opt_input_shape
=
{
"x"
:
[
args
.
rec_batch_num
,
3
,
48
,
320
]}
else
:
else
:
min_input_shape
=
{
"x"
:
[
1
,
3
,
10
,
10
]}
min_input_shape
=
{
"x"
:
[
1
,
3
,
10
,
10
]}
max_input_shape
=
{
"x"
:
[
1
,
3
,
1000
,
1000
]}
max_input_shape
=
{
"x"
:
[
1
,
3
,
512
,
512
]}
opt_input_shape
=
{
"x"
:
[
1
,
3
,
500
,
500
]}
opt_input_shape
=
{
"x"
:
[
1
,
3
,
256
,
256
]}
config
.
set_trt_dynamic_shape_info
(
min_input_shape
,
max_input_shape
,
config
.
set_trt_dynamic_shape_info
(
min_input_shape
,
max_input_shape
,
opt_input_shape
)
opt_input_shape
)
...
@@ -601,5 +601,12 @@ def get_rotate_crop_image(img, points):
...
@@ -601,5 +601,12 @@ def get_rotate_crop_image(img, points):
return
dst_img
return
dst_img
def
check_gpu
(
use_gpu
):
if
use_gpu
and
not
paddle
.
is_compiled_with_cuda
():
use_gpu
=
False
return
use_gpu
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
pass
pass
tools/infer_cls.py
View file @
55d71902
...
@@ -32,7 +32,7 @@ import paddle
...
@@ -32,7 +32,7 @@ import paddle
from
ppocr.data
import
create_operators
,
transform
from
ppocr.data
import
create_operators
,
transform
from
ppocr.modeling.architectures
import
build_model
from
ppocr.modeling.architectures
import
build_model
from
ppocr.postprocess
import
build_post_process
from
ppocr.postprocess
import
build_post_process
from
ppocr.utils.save_load
import
init
_model
from
ppocr.utils.save_load
import
load
_model
from
ppocr.utils.utility
import
get_image_file_list
from
ppocr.utils.utility
import
get_image_file_list
import
tools.program
as
program
import
tools.program
as
program
...
@@ -47,7 +47,7 @@ def main():
...
@@ -47,7 +47,7 @@ def main():
# build model
# build model
model
=
build_model
(
config
[
'Architecture'
])
model
=
build_model
(
config
[
'Architecture'
])
init
_model
(
config
,
model
)
load
_model
(
config
,
model
)
# create data ops
# create data ops
transforms
=
[]
transforms
=
[]
...
...
tools/infer_det.py
View file @
55d71902
...
@@ -34,7 +34,7 @@ import paddle
...
@@ -34,7 +34,7 @@ import paddle
from
ppocr.data
import
create_operators
,
transform
from
ppocr.data
import
create_operators
,
transform
from
ppocr.modeling.architectures
import
build_model
from
ppocr.modeling.architectures
import
build_model
from
ppocr.postprocess
import
build_post_process
from
ppocr.postprocess
import
build_post_process
from
ppocr.utils.save_load
import
init
_model
,
load_dygraph_params
from
ppocr.utils.save_load
import
load
_model
from
ppocr.utils.utility
import
get_image_file_list
from
ppocr.utils.utility
import
get_image_file_list
import
tools.program
as
program
import
tools.program
as
program
...
@@ -59,7 +59,7 @@ def main():
...
@@ -59,7 +59,7 @@ def main():
# build model
# build model
model
=
build_model
(
config
[
'Architecture'
])
model
=
build_model
(
config
[
'Architecture'
])
_
=
load_
dygraph_params
(
config
,
model
,
logger
,
None
)
load_
model
(
config
,
model
)
# build post process
# build post process
post_process_class
=
build_post_process
(
config
[
'PostProcess'
])
post_process_class
=
build_post_process
(
config
[
'PostProcess'
])
...
...
tools/infer_e2e.py
View file @
55d71902
...
@@ -34,7 +34,7 @@ import paddle
...
@@ -34,7 +34,7 @@ import paddle
from
ppocr.data
import
create_operators
,
transform
from
ppocr.data
import
create_operators
,
transform
from
ppocr.modeling.architectures
import
build_model
from
ppocr.modeling.architectures
import
build_model
from
ppocr.postprocess
import
build_post_process
from
ppocr.postprocess
import
build_post_process
from
ppocr.utils.save_load
import
init
_model
from
ppocr.utils.save_load
import
load
_model
from
ppocr.utils.utility
import
get_image_file_list
from
ppocr.utils.utility
import
get_image_file_list
import
tools.program
as
program
import
tools.program
as
program
...
@@ -68,7 +68,7 @@ def main():
...
@@ -68,7 +68,7 @@ def main():
# build model
# build model
model
=
build_model
(
config
[
'Architecture'
])
model
=
build_model
(
config
[
'Architecture'
])
init
_model
(
config
,
model
)
load
_model
(
config
,
model
)
# build post process
# build post process
post_process_class
=
build_post_process
(
config
[
'PostProcess'
],
post_process_class
=
build_post_process
(
config
[
'PostProcess'
],
...
...
tools/infer_rec.py
View file @
55d71902
...
@@ -33,7 +33,7 @@ import paddle
...
@@ -33,7 +33,7 @@ import paddle
from
ppocr.data
import
create_operators
,
transform
from
ppocr.data
import
create_operators
,
transform
from
ppocr.modeling.architectures
import
build_model
from
ppocr.modeling.architectures
import
build_model
from
ppocr.postprocess
import
build_post_process
from
ppocr.postprocess
import
build_post_process
from
ppocr.utils.save_load
import
init
_model
from
ppocr.utils.save_load
import
load
_model
from
ppocr.utils.utility
import
get_image_file_list
from
ppocr.utils.utility
import
get_image_file_list
import
tools.program
as
program
import
tools.program
as
program
...
@@ -58,7 +58,7 @@ def main():
...
@@ -58,7 +58,7 @@ def main():
model
=
build_model
(
config
[
'Architecture'
])
model
=
build_model
(
config
[
'Architecture'
])
init
_model
(
config
,
model
)
load
_model
(
config
,
model
)
# create data ops
# create data ops
transforms
=
[]
transforms
=
[]
...
@@ -75,9 +75,7 @@ def main():
...
@@ -75,9 +75,7 @@ def main():
'gsrm_slf_attn_bias1'
,
'gsrm_slf_attn_bias2'
'gsrm_slf_attn_bias1'
,
'gsrm_slf_attn_bias2'
]
]
elif
config
[
'Architecture'
][
'algorithm'
]
==
"SAR"
:
elif
config
[
'Architecture'
][
'algorithm'
]
==
"SAR"
:
op
[
op_name
][
'keep_keys'
]
=
[
op
[
op_name
][
'keep_keys'
]
=
[
'image'
,
'valid_ratio'
]
'image'
,
'valid_ratio'
]
else
:
else
:
op
[
op_name
][
'keep_keys'
]
=
[
'image'
]
op
[
op_name
][
'keep_keys'
]
=
[
'image'
]
transforms
.
append
(
op
)
transforms
.
append
(
op
)
...
...
tools/infer_table.py
View file @
55d71902
...
@@ -34,11 +34,12 @@ from paddle.jit import to_static
...
@@ -34,11 +34,12 @@ from paddle.jit import to_static
from
ppocr.data
import
create_operators
,
transform
from
ppocr.data
import
create_operators
,
transform
from
ppocr.modeling.architectures
import
build_model
from
ppocr.modeling.architectures
import
build_model
from
ppocr.postprocess
import
build_post_process
from
ppocr.postprocess
import
build_post_process
from
ppocr.utils.save_load
import
init
_model
from
ppocr.utils.save_load
import
load
_model
from
ppocr.utils.utility
import
get_image_file_list
from
ppocr.utils.utility
import
get_image_file_list
import
tools.program
as
program
import
tools.program
as
program
import
cv2
import
cv2
def
main
(
config
,
device
,
logger
,
vdl_writer
):
def
main
(
config
,
device
,
logger
,
vdl_writer
):
global_config
=
config
[
'Global'
]
global_config
=
config
[
'Global'
]
...
@@ -53,7 +54,7 @@ def main(config, device, logger, vdl_writer):
...
@@ -53,7 +54,7 @@ def main(config, device, logger, vdl_writer):
model
=
build_model
(
config
[
'Architecture'
])
model
=
build_model
(
config
[
'Architecture'
])
init
_model
(
config
,
model
,
logger
)
load
_model
(
config
,
model
)
# create data ops
# create data ops
transforms
=
[]
transforms
=
[]
...
@@ -104,4 +105,3 @@ def main(config, device, logger, vdl_writer):
...
@@ -104,4 +105,3 @@ def main(config, device, logger, vdl_writer):
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
config
,
device
,
logger
,
vdl_writer
=
program
.
preprocess
()
config
,
device
,
logger
,
vdl_writer
=
program
.
preprocess
()
main
(
config
,
device
,
logger
,
vdl_writer
)
main
(
config
,
device
,
logger
,
vdl_writer
)
tools/train.py
View file @
55d71902
...
@@ -35,7 +35,7 @@ from ppocr.losses import build_loss
...
@@ -35,7 +35,7 @@ from ppocr.losses import build_loss
from
ppocr.optimizer
import
build_optimizer
from
ppocr.optimizer
import
build_optimizer
from
ppocr.postprocess
import
build_post_process
from
ppocr.postprocess
import
build_post_process
from
ppocr.metrics
import
build_metric
from
ppocr.metrics
import
build_metric
from
ppocr.utils.save_load
import
init
_model
,
load_dygraph_params
from
ppocr.utils.save_load
import
load
_model
import
tools.program
as
program
import
tools.program
as
program
dist
.
get_world_size
()
dist
.
get_world_size
()
...
@@ -97,7 +97,7 @@ def main(config, device, logger, vdl_writer):
...
@@ -97,7 +97,7 @@ def main(config, device, logger, vdl_writer):
# build metric
# build metric
eval_class
=
build_metric
(
config
[
'Metric'
])
eval_class
=
build_metric
(
config
[
'Metric'
])
# load pretrain model
# load pretrain model
pre_best_model_dict
=
load_
dygraph_params
(
config
,
model
,
logger
,
optimizer
)
pre_best_model_dict
=
load_
model
(
config
,
model
,
optimizer
)
logger
.
info
(
'train dataloader has {} iters'
.
format
(
len
(
train_dataloader
)))
logger
.
info
(
'train dataloader has {} iters'
.
format
(
len
(
train_dataloader
)))
if
valid_dataloader
is
not
None
:
if
valid_dataloader
is
not
None
:
logger
.
info
(
'valid dataloader has {} iters'
.
format
(
logger
.
info
(
'valid dataloader has {} iters'
.
format
(
...
...
Prev
1
2
3
4
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment