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
e77b1f0f
Unverified
Commit
e77b1f0f
authored
Jan 06, 2022
by
WuZhe
Committed by
GitHub
Jan 06, 2022
Browse files
Merge branch 'dygraph' into dygraph
parents
1af19469
a031e333
Changes
46
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
41 additions
and
19 deletions
+41
-19
test_tipc/configs/det_r50_vd_sast_totaltext_v2.0/train_infer_python.txt
...igs/det_r50_vd_sast_totaltext_v2.0/train_infer_python.txt
+1
-1
test_tipc/prepare.sh
test_tipc/prepare.sh
+12
-7
test_tipc/test_train_inference_python.sh
test_tipc/test_train_inference_python.sh
+8
-4
tools/infer/predict_det.py
tools/infer/predict_det.py
+11
-6
tools/infer/predict_rec.py
tools/infer/predict_rec.py
+4
-1
tools/infer/utility.py
tools/infer/utility.py
+5
-0
No files found.
test_tipc/configs/det_r50_vd_sast_totaltext_v2.0/train_infer_python.txt
View file @
e77b1f0f
...
...
@@ -43,7 +43,7 @@ inference:tools/infer/predict_det.py
--cpu_threads:1|6
--rec_batch_num:1
--use_tensorrt:False
--precision:fp32|
fp16|
int8
--precision:fp32|int8
--det_model_dir:
--image_dir:./inference/ch_det_data_50/all-sum-510/
null:null
...
...
test_tipc/prepare.sh
View file @
e77b1f0f
...
...
@@ -179,7 +179,7 @@ elif [ ${MODE} = "whole_infer" ];then
cd
./inference/
&&
tar
xf rec_r34_vd_tps_bilstm_ctc_v2.0_train.tar
&&
cd
../
fi
if
[
${
model_name
}
==
"ch_ppocr_server_v2.0_rec"
]
;
then
wget
-nc
-P
./inference/ https://paddleocr.bj.bcebos.com/dygraph_v2.0/
en
/ch_ppocr_server_v2.0_rec_train.tar
--no-check-certificate
wget
-nc
-P
./inference/ https://paddleocr.bj.bcebos.com/dygraph_v2.0/
ch
/ch_ppocr_server_v2.0_rec_train.tar
--no-check-certificate
cd
./inference/
&&
tar
xf ch_ppocr_server_v2.0_rec_train.tar
&&
cd
../
fi
if
[
${
model_name
}
==
"ch_ppocr_mobile_v2.0_rec"
]
;
then
...
...
@@ -239,18 +239,23 @@ fi
if
[
${
MODE
}
=
"klquant_whole_infer"
]
;
then
wget
-nc
-P
./train_data/ https://paddleocr.bj.bcebos.com/dygraph_v2.0/test/icdar2015_lite.tar
--no-check-certificate
cd
./train_data/
&&
tar
xf icdar2015_lite.tar
ln
-s
./icdar2015_lite ./icdar2015
&&
cd
../
cd
./train_data/
&&
tar
xf icdar2015_lite.tar
&&
rm
-rf
./icdar2015
&&
ln
-s
./icdar2015_lite ./icdar2015
&&
cd
../
if
[
${
model_name
}
=
"ch_ppocr_mobile_v2.0_det_KL"
]
;
then
wget
-nc
-P
./inference https://paddleocr.bj.bcebos.com/dygraph_v2.0/ch/ch_ppocr_mobile_v2.0_det_infer.tar
--no-check-certificate
wget
-nc
-P
./inference https://paddleocr.bj.bcebos.com/dygraph_v2.0/test/ch_det_data_50.tar
--no-check-certificate
cd
./inference
&&
tar
xf ch_ppocr_mobile_v2.0_det_infer.tar
&&
tar
xf ch_det_data_50.tar
&&
cd
../
fi
if
[
${
model_name
}
=
"ch_PPOCRv2_det"
]
;
then
eval_model_name
=
"ch_PP-OCRv2_det_infer"
if
[
${
model_name
}
=
"PPOCRv2_ocr_rec_kl"
]
;
then
wget
-nc
-P
./inference https://paddleocr.bj.bcebos.com/PP-OCRv2/chinese/ch_PP-OCRv2_rec_infer.tar
--no-check-certificate
wget
-nc
-P
./inference/ https://paddleocr.bj.bcebos.com/dygraph_v2.0/test/rec_inference.tar
--no-check-certificate
wget
-nc
-P
./train_data/ https://paddleocr.bj.bcebos.com/dygraph_v2.0/test/ic15_data.tar
--no-check-certificate
cd
./train_data/
&&
tar
xf ic15_data.tar
&&
cd
../
cd
./inference
&&
tar
xf rec_inference.tar
&&
tar
xf ch_PP-OCRv2_rec_infer.tar
&&
cd
../
fi
if
[
${
model_name
}
=
"PPOCRv2_ocr_det_kl"
]
;
then
wget
-nc
-P
./inference https://paddleocr.bj.bcebos.com/dygraph_v2.0/test/ch_det_data_50.tar
--no-check-certificate
wget
-nc
-P
./inference
/
https://paddleocr.bj.bcebos.com/PP-OCRv2/chinese/ch_PP-OCRv2_det_infer.tar
--no-check-certificate
cd
./inference
&&
tar
xf
${
eval_model_name
}
.tar
&&
tar
xf ch_det_data_50.tar
&&
cd
../
wget
-nc
-P
./inference https://paddleocr.bj.bcebos.com/PP-OCRv2/chinese/ch_PP-OCRv2_det_infer.tar
--no-check-certificate
cd
./inference
&&
tar
xf
ch_PP-OCRv2_det_infer
.tar
&&
tar
xf ch_det_data_50.tar
&&
cd
../
fi
if
[
${
model_name
}
=
"ch_ppocr_mobile_v2.0_rec_KL"
]
;
then
wget
-nc
-P
./inference/ https://paddleocr.bj.bcebos.com/dygraph_v2.0/ch/ch_ppocr_mobile_v2.0_rec_infer.tar
--no-check-certificate
...
...
test_tipc/test_train_inference_python.sh
View file @
e77b1f0f
...
...
@@ -183,7 +183,7 @@ function func_inference(){
if
[[
${
precision
}
=
~
"fp16"
||
${
precision
}
=
~
"int8"
]]
&&
[
${
use_trt
}
=
"False"
]
;
then
continue
fi
if
[[
${
use_trt
}
=
"False"
||
${
precision
}
=
~
"int8"
]]
&&
[
${
_flag_quant
}
=
"True"
]
;
then
if
[[
${
use_trt
}
=
"False"
&&
${
precision
}
=
~
"int8"
]]
&&
[
${
_flag_quant
}
=
"True"
]
;
then
continue
fi
for
batch_size
in
${
batch_size_list
[*]
}
;
do
...
...
@@ -227,7 +227,12 @@ if [ ${MODE} = "whole_infer" ] || [ ${MODE} = "klquant_whole_infer" ]; then
for
infer_model
in
${
infer_model_dir_list
[*]
}
;
do
# run export
if
[
${
infer_run_exports
[Count]
}
!=
"null"
]
;
then
save_infer_dir
=
$(
dirname
$infer_model
)
if
[
${
MODE
}
=
"klquant_whole_infer"
]
;
then
save_infer_dir
=
"
${
infer_model
}
_klquant"
fi
if
[
${
MODE
}
=
"whole_infer"
]
;
then
save_infer_dir
=
"
${
infer_model
}
"
fi
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
}
"
...
...
@@ -259,7 +264,6 @@ else
env
=
""
elif
[
${#
gpu
}
-le
1
]
;
then
env
=
"export CUDA_VISIBLE_DEVICES=
${
gpu
}
"
eval
${
env
}
elif
[
${#
gpu
}
-le
15
]
;
then
IFS
=
","
array
=(
${
gpu
}
)
...
...
@@ -280,6 +284,7 @@ else
set_amp_config
=
" "
fi
for
trainer
in
${
trainer_list
[*]
}
;
do
eval
${
env
}
flag_quant
=
False
if
[
${
trainer
}
=
${
pact_key
}
]
;
then
run_train
=
${
pact_trainer
}
...
...
@@ -332,7 +337,6 @@ else
cmd
=
"
${
python
}
-m paddle.distributed.launch --ips=
${
ips
}
--gpus=
${
gpu
}
${
run_train
}
${
set_use_gpu
}
${
set_save_model
}
${
set_pretrain
}
${
set_epoch
}
${
set_autocast
}
${
set_batchsize
}
${
set_train_params1
}
${
set_amp_config
}
"
fi
# run train
eval
"unset CUDA_VISIBLE_DEVICES"
eval
$cmd
status_check
$?
"
${
cmd
}
"
"
${
status_log
}
"
...
...
tools/infer/predict_det.py
View file @
e77b1f0f
...
...
@@ -101,16 +101,21 @@ class TextDetector(object):
else
:
logger
.
info
(
"unknown det_algorithm:{}"
.
format
(
self
.
det_algorithm
))
sys
.
exit
(
0
)
self
.
preprocess_op
=
create_operators
(
pre_process_list
)
self
.
postprocess_op
=
build_post_process
(
postprocess_params
)
self
.
predictor
,
self
.
input_tensor
,
self
.
output_tensors
,
self
.
config
=
utility
.
create_predictor
(
args
,
'det'
,
logger
)
if
self
.
use_onnx
:
img_h
,
img_w
=
self
.
input_tensor
.
shape
[
2
:]
if
img_h
is
not
None
and
img_w
is
not
None
and
img_h
>
0
and
img_w
>
0
:
pre_process_list
[
0
]
=
{
'DetResizeForTest'
:
{
'image_shape'
:
[
640
,
640
]
'image_shape'
:
[
img_h
,
img_w
]
}
}
self
.
preprocess_op
=
create_operators
(
pre_process_list
)
self
.
postprocess_op
=
build_post_process
(
postprocess_params
)
self
.
predictor
,
self
.
input_tensor
,
self
.
output_tensors
,
self
.
config
=
utility
.
create_predictor
(
args
,
'det'
,
logger
)
if
args
.
benchmark
:
import
auto_log
...
...
tools/infer/predict_rec.py
View file @
e77b1f0f
...
...
@@ -109,7 +109,10 @@ class TextRecognizer(object):
assert
imgC
==
img
.
shape
[
2
]
imgW
=
int
((
32
*
max_wh_ratio
))
if
self
.
use_onnx
:
imgW
=
100
w
=
self
.
input_tensor
.
shape
[
3
:][
0
]
if
w
is
not
None
and
w
>
0
:
imgW
=
w
h
,
w
=
img
.
shape
[:
2
]
ratio
=
w
/
float
(
h
)
if
math
.
ceil
(
imgH
*
ratio
)
>
imgW
:
...
...
tools/infer/utility.py
View file @
e77b1f0f
...
...
@@ -15,6 +15,7 @@
import
argparse
import
os
import
sys
import
platform
import
cv2
import
numpy
as
np
import
paddle
...
...
@@ -313,6 +314,10 @@ def create_predictor(args, mode, logger):
def
get_infer_gpuid
():
sysstr
=
platform
.
system
()
if
sysstr
==
"Windows"
:
return
0
if
not
paddle
.
fluid
.
core
.
is_compiled_with_rocm
():
cmd
=
"env | grep CUDA_VISIBLE_DEVICES"
else
:
...
...
Prev
1
2
3
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