Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleClas
提交
dd6bd28d
P
PaddleClas
项目概览
PaddlePaddle
/
PaddleClas
接近 2 年 前同步成功
通知
116
Star
4999
Fork
1114
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
19
列表
看板
标记
里程碑
合并请求
6
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleClas
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
19
Issue
19
列表
看板
标记
里程碑
合并请求
6
合并请求
6
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
dd6bd28d
编写于
12月 01, 2021
作者:
D
dongshuilong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix bug for c++(cls, shitu) chain for tipc
上级
de726400
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
34 addition
and
21 deletion
+34
-21
test_tipc/config/PP-ShiTu/PPShiTu_linux_gpu_normal_normal_infer_cpp_linux_gpu_cpu.txt
...ShiTu_linux_gpu_normal_normal_infer_cpp_linux_gpu_cpu.txt
+2
-0
test_tipc/config/ResNet/ResNet50_vd_linux_gpu_normal_normal_infer_cpp_linux_gpu_cpu.txt
...50_vd_linux_gpu_normal_normal_infer_cpp_linux_gpu_cpu.txt
+1
-0
test_tipc/generate_cpp_yaml.py
test_tipc/generate_cpp_yaml.py
+2
-0
test_tipc/test_inference_cpp.sh
test_tipc/test_inference_cpp.sh
+29
-21
未找到文件。
test_tipc/config/PP-ShiTu/PPShiTu_linux_gpu_normal_normal_infer_cpp_linux_gpu_cpu.txt
浏览文件 @
dd6bd28d
...
@@ -15,3 +15,5 @@ use_tensorrt:False|True
...
@@ -15,3 +15,5 @@ use_tensorrt:False|True
precision:fp32|fp16
precision:fp32|fp16
data_dir:./dataset/drink_dataset_v1.0
data_dir:./dataset/drink_dataset_v1.0
benchmark:True
benchmark:True
generate_yaml_cmd:python3 test_tipc/generate_cpp_yaml.py
transform_index_cmd:python3 deploy/cpp_shitu/tools/transform_id_map.py -c inference_drink.yaml
test_tipc/config/ResNet/ResNet50_vd_linux_gpu_normal_normal_infer_cpp_linux_gpu_cpu.txt
浏览文件 @
dd6bd28d
...
@@ -15,3 +15,4 @@ use_tensorrt:False|True
...
@@ -15,3 +15,4 @@ use_tensorrt:False|True
precision:fp32|fp16
precision:fp32|fp16
image_dir:./dataset/ILSVRC2012/val
image_dir:./dataset/ILSVRC2012/val
benchmark:True
benchmark:True
generate_yaml_cmd:python3 test_tipc/generate_cpp_yaml.py
test_tipc/generate_cpp_yaml.py
浏览文件 @
dd6bd28d
...
@@ -20,6 +20,7 @@ def parse_args():
...
@@ -20,6 +20,7 @@ def parse_args():
parser
.
add_argument
(
'--tensorrt'
,
type
=
str2bool
,
default
=
False
)
parser
.
add_argument
(
'--tensorrt'
,
type
=
str2bool
,
default
=
False
)
parser
.
add_argument
(
'--precision'
,
type
=
str
,
choices
=
[
"fp32"
,
"fp16"
])
parser
.
add_argument
(
'--precision'
,
type
=
str
,
choices
=
[
"fp32"
,
"fp16"
])
parser
.
add_argument
(
'--benchmark'
,
type
=
str2bool
,
default
=
True
)
parser
.
add_argument
(
'--benchmark'
,
type
=
str2bool
,
default
=
True
)
parser
.
add_argument
(
'--gpu_id'
,
type
=
int
,
default
=
0
)
parser
.
add_argument
(
parser
.
add_argument
(
'--cls_yaml_path'
,
'--cls_yaml_path'
,
type
=
str
,
type
=
str
,
...
@@ -55,6 +56,7 @@ def main():
...
@@ -55,6 +56,7 @@ def main():
config
[
"Global"
][
"benchmark"
]
=
args
.
benchmark
config
[
"Global"
][
"benchmark"
]
=
args
.
benchmark
config
[
"Global"
][
"use_tensorrt"
]
=
args
.
tensorrt
config
[
"Global"
][
"use_tensorrt"
]
=
args
.
tensorrt
config
[
"Global"
][
"use_fp16"
]
=
True
if
args
.
precision
==
"fp16"
else
False
config
[
"Global"
][
"use_fp16"
]
=
True
if
args
.
precision
==
"fp16"
else
False
config
[
"Global"
][
"gpu_id"
]
=
args
.
gpu_id
if
args
.
type
==
"cls"
:
if
args
.
type
==
"cls"
:
config
[
"Global"
][
"infer_imgs"
]
=
args
.
data_dir
config
[
"Global"
][
"infer_imgs"
]
=
args
.
data_dir
assert
args
.
cls_model_dir
assert
args
.
cls_model_dir
...
...
test_tipc/test_inference_cpp.sh
浏览文件 @
dd6bd28d
...
@@ -2,6 +2,10 @@
...
@@ -2,6 +2,10 @@
source
test_tipc/common_func.sh
source
test_tipc/common_func.sh
FILENAME
=
$1
FILENAME
=
$1
GPUID
=
$2
if
[[
!
$GPUID
]]
;
then
GPUID
=
0
fi
dataline
=
$(
awk
'NR==1, NR==16{print}'
$FILENAME
)
dataline
=
$(
awk
'NR==1, NR==16{print}'
$FILENAME
)
# parser params
# parser params
...
@@ -24,11 +28,13 @@ cpp_use_trt_list=$(func_parser_value "${lines[13]}")
...
@@ -24,11 +28,13 @@ cpp_use_trt_list=$(func_parser_value "${lines[13]}")
cpp_precision_list
=
$(
func_parser_value
"
${
lines
[14]
}
"
)
cpp_precision_list
=
$(
func_parser_value
"
${
lines
[14]
}
"
)
cpp_image_dir_value
=
$(
func_parser_value
"
${
lines
[15]
}
"
)
cpp_image_dir_value
=
$(
func_parser_value
"
${
lines
[15]
}
"
)
cpp_benchmark_value
=
$(
func_parser_value
"
${
lines
[16]
}
"
)
cpp_benchmark_value
=
$(
func_parser_value
"
${
lines
[16]
}
"
)
generate_yaml_cmd
=
$(
func_parser_value
"
${
lines
[17]
}
"
)
transform_index_cmd
=
$(
func_parser_value
"
${
lines
[18]
}
"
)
LOG_PATH
=
"./test_tipc/output"
LOG_PATH
=
"./test_tipc/output"
mkdir
-p
${
LOG_PATH
}
mkdir
-p
${
LOG_PATH
}
status_log
=
"
${
LOG_PATH
}
/results_cpp.log"
status_log
=
"
${
LOG_PATH
}
/results_cpp.log"
generate_yaml_cmd
=
"python3 test_tipc/generate_cpp_yaml.py"
#
generate_yaml_cmd="python3 test_tipc/generate_cpp_yaml.py"
function
func_shitu_cpp_inference
(){
function
func_shitu_cpp_inference
(){
IFS
=
'|'
IFS
=
'|'
...
@@ -53,8 +59,9 @@ function func_shitu_cpp_inference(){
...
@@ -53,8 +59,9 @@ function func_shitu_cpp_inference(){
fi
fi
_save_log_path
=
"
${
_log_path
}
/shitu_cpp_infer_cpu_usemkldnn_
${
use_mkldnn
}
_threads_
${
threads
}
_precision_
${
precision
}
_batchsize_
${
batch_size
}
.log"
_save_log_path
=
"
${
_log_path
}
/shitu_cpp_infer_cpu_usemkldnn_
${
use_mkldnn
}
_threads_
${
threads
}
_precision_
${
precision
}
_batchsize_
${
batch_size
}
.log"
command
=
"
${
generate_yaml_cmd
}
--type shitu --batch_size
${
batch_size
}
--mkldnn
${
use_mkldnn
}
--gpu
${
use_gpu
}
--cpu_thread
${
threads
}
--tensorrt False --precision
${
precision
}
--data_dir
${
_img_dir
}
--benchmark True --cls_model_dir
${
cpp_infer_model_dir
}
--det_model_dir
${
cpp_det_infer_model_dir
}
"
command
=
"
${
generate_yaml_cmd
}
--type shitu --batch_size
${
batch_size
}
--mkldnn
${
use_mkldnn
}
--gpu
${
use_gpu
}
--cpu_thread
${
threads
}
--tensorrt False --precision
${
precision
}
--data_dir
${
_img_dir
}
--benchmark True --cls_model_dir
${
cpp_infer_model_dir
}
--det_model_dir
${
cpp_det_infer_model_dir
}
--gpu_id
${
GPUID
}
"
eval
$command
eval
$command
eval
$transform_index_cmd
command
=
"
${
_script
}
2>&1|tee
${
_save_log_path
}
"
command
=
"
${
_script
}
2>&1|tee
${
_save_log_path
}
"
eval
$command
eval
$command
last_status
=
${
PIPESTATUS
[0]
}
last_status
=
${
PIPESTATUS
[0]
}
...
@@ -76,8 +83,9 @@ function func_shitu_cpp_inference(){
...
@@ -76,8 +83,9 @@ function func_shitu_cpp_inference(){
fi
fi
for
batch_size
in
${
cpp_batch_size_list
[*]
}
;
do
for
batch_size
in
${
cpp_batch_size_list
[*]
}
;
do
_save_log_path
=
"
${
_log_path
}
/shitu_cpp_infer_gpu_usetrt_
${
use_trt
}
_precision_
${
precision
}
_batchsize_
${
batch_size
}
.log"
_save_log_path
=
"
${
_log_path
}
/shitu_cpp_infer_gpu_usetrt_
${
use_trt
}
_precision_
${
precision
}
_batchsize_
${
batch_size
}
.log"
command
=
"
${
generate_yaml_cmd
}
--type shitu --batch_size
${
batch_size
}
--mkldnn False --gpu
${
use_gpu
}
--cpu_thread 1 --tensorrt
${
use_trt
}
--precision
${
precision
}
--data_dir
${
_img_dir
}
--benchmark True --cls_model_dir
${
cpp_infer_model_dir
}
--det_model_dir
${
cpp_det_infer_model_dir
}
"
command
=
"
${
generate_yaml_cmd
}
--type shitu --batch_size
${
batch_size
}
--mkldnn False --gpu
${
use_gpu
}
--cpu_thread 1 --tensorrt
${
use_trt
}
--precision
${
precision
}
--data_dir
${
_img_dir
}
--benchmark True --cls_model_dir
${
cpp_infer_model_dir
}
--det_model_dir
${
cpp_det_infer_model_dir
}
--gpu_id
${
GPUID
}
"
eval
$command
eval
$command
eval
$transform_index_cmd
command
=
"
${
_script
}
2>&1|tee
${
_save_log_path
}
"
command
=
"
${
_script
}
2>&1|tee
${
_save_log_path
}
"
eval
$command
eval
$command
last_status
=
${
PIPESTATUS
[0]
}
last_status
=
${
PIPESTATUS
[0]
}
...
@@ -114,7 +122,7 @@ function func_cls_cpp_inference(){
...
@@ -114,7 +122,7 @@ function func_cls_cpp_inference(){
fi
fi
_save_log_path
=
"
${
_log_path
}
/cls_cpp_infer_cpu_usemkldnn_
${
use_mkldnn
}
_threads_
${
threads
}
_precision_
${
precision
}
_batchsize_
${
batch_size
}
.log"
_save_log_path
=
"
${
_log_path
}
/cls_cpp_infer_cpu_usemkldnn_
${
use_mkldnn
}
_threads_
${
threads
}
_precision_
${
precision
}
_batchsize_
${
batch_size
}
.log"
command
=
"
${
generate_yaml_cmd
}
--type cls --batch_size
${
batch_size
}
--mkldnn
${
use_mkldnn
}
--gpu
${
use_gpu
}
--cpu_thread
${
threads
}
--tensorrt False --precision
${
precision
}
--data_dir
${
_img_dir
}
--benchmark True --cls_model_dir
${
cpp_infer_model_dir
}
"
command
=
"
${
generate_yaml_cmd
}
--type cls --batch_size
${
batch_size
}
--mkldnn
${
use_mkldnn
}
--gpu
${
use_gpu
}
--cpu_thread
${
threads
}
--tensorrt False --precision
${
precision
}
--data_dir
${
_img_dir
}
--benchmark True --cls_model_dir
${
cpp_infer_model_dir
}
--gpu_id
${
GPUID
}
"
eval
$command
eval
$command
command1
=
"
${
_script
}
2>&1|tee
${
_save_log_path
}
"
command1
=
"
${
_script
}
2>&1|tee
${
_save_log_path
}
"
eval
${
command1
}
eval
${
command1
}
...
@@ -137,7 +145,7 @@ function func_cls_cpp_inference(){
...
@@ -137,7 +145,7 @@ function func_cls_cpp_inference(){
fi
fi
for
batch_size
in
${
cpp_batch_size_list
[*]
}
;
do
for
batch_size
in
${
cpp_batch_size_list
[*]
}
;
do
_save_log_path
=
"
${
_log_path
}
/cls_cpp_infer_gpu_usetrt_
${
use_trt
}
_precision_
${
precision
}
_batchsize_
${
batch_size
}
.log"
_save_log_path
=
"
${
_log_path
}
/cls_cpp_infer_gpu_usetrt_
${
use_trt
}
_precision_
${
precision
}
_batchsize_
${
batch_size
}
.log"
command
=
"
${
generate_yaml_cmd
}
--type cls --batch_size
${
batch_size
}
--mkldnn False --gpu
${
use_gpu
}
--cpu_thread 1 --tensorrt
${
use_trt
}
--precision
${
precision
}
--data_dir
${
_img_dir
}
--benchmark True --cls_model_dir
${
cpp_infer_model_dir
}
"
command
=
"
${
generate_yaml_cmd
}
--type cls --batch_size
${
batch_size
}
--mkldnn False --gpu
${
use_gpu
}
--cpu_thread 1 --tensorrt
${
use_trt
}
--precision
${
precision
}
--data_dir
${
_img_dir
}
--benchmark True --cls_model_dir
${
cpp_infer_model_dir
}
--gpu_id
${
GPUID
}
"
eval
$command
eval
$command
command
=
"
${
_script
}
2>&1|tee
${
_save_log_path
}
"
command
=
"
${
_script
}
2>&1|tee
${
_save_log_path
}
"
eval
$command
eval
$command
...
@@ -152,6 +160,7 @@ function func_cls_cpp_inference(){
...
@@ -152,6 +160,7 @@ function func_cls_cpp_inference(){
done
done
}
}
if
[[
$cpp_infer_type
==
"cls"
]]
;
then
if
[[
$cpp_infer_type
==
"cls"
]]
;
then
cd
deploy/cpp
cd
deploy/cpp
elif
[[
$cpp_infer_type
==
"shitu"
]]
;
then
elif
[[
$cpp_infer_type
==
"shitu"
]]
;
then
...
@@ -183,6 +192,7 @@ if [[ $cpp_infer_type == "shitu" ]]; then
...
@@ -183,6 +192,7 @@ if [[ $cpp_infer_type == "shitu" ]]; then
eval
"cmake -B build . -DFAISS_ENABLE_PYTHON=OFF -DCMAKE_INSTALL_PREFIX=
${
faiss_install_path
}
"
eval
"cmake -B build . -DFAISS_ENABLE_PYTHON=OFF -DCMAKE_INSTALL_PREFIX=
${
faiss_install_path
}
"
make
-C
build
-j
faiss
make
-C
build
-j
faiss
make
-C
build
install
make
-C
build
install
cd
..
fi
fi
if
[
-d
"opencv-3.4.7/opencv3/"
]
&&
[
$(
md5sum
opencv-3.4.7.tar.gz |
awk
-F
' '
'{print $1}'
)
=
"faa2b5950f8bee3f03118e600c74746a"
]
;
then
if
[
-d
"opencv-3.4.7/opencv3/"
]
&&
[
$(
md5sum
opencv-3.4.7.tar.gz |
awk
-F
' '
'{print $1}'
)
=
"faa2b5950f8bee3f03118e600c74746a"
]
;
then
...
@@ -220,15 +230,14 @@ else
...
@@ -220,15 +230,14 @@ else
make
-j
make
-j
make
install
make
install
cd
../
cd
../
../
echo
"################### build opencv finished ###################"
echo
"################### build opencv finished ###################"
fi
fi
echo
"################### build PaddleClas demo ####################"
echo
"################### build PaddleClas demo ####################"
OPENCV_DIR
=
$(
pwd
)
/opencv-3.4.7/opencv3/
OPENCV_DIR
=
$(
pwd
)
/opencv-3.4.7/opencv3/
LIB_DIR
=
/work/project/project/test/paddle_inference/
#
LIB_DIR=/work/project/project/test/paddle_inference/
#
LIB_DIR=$(pwd)/Paddle/build/paddle_inference_install_dir/
LIB_DIR
=
$(
pwd
)
/Paddle/build/paddle_inference_install_dir/
CUDA_LIB_DIR
=
$(
dirname
`
find /usr
-name
libcudart.so
`
)
CUDA_LIB_DIR
=
$(
dirname
`
find /usr
-name
libcudart.so
`
)
CUDNN_LIB_DIR
=
$(
dirname
`
find /usr
-name
libcudnn.so
`
)
CUDNN_LIB_DIR
=
$(
dirname
`
find /usr
-name
libcudnn.so
`
)
...
@@ -247,7 +256,6 @@ if [[ $cpp_infer_type == cls ]]; then
...
@@ -247,7 +256,6 @@ if [[ $cpp_infer_type == cls ]]; then
-DCUDNN_LIB
=
${
CUDNN_LIB_DIR
}
\
-DCUDNN_LIB
=
${
CUDNN_LIB_DIR
}
\
-DCUDA_LIB
=
${
CUDA_LIB_DIR
}
\
-DCUDA_LIB
=
${
CUDA_LIB_DIR
}
\
-DTENSORRT_DIR
=
${
TENSORRT_DIR
}
-DTENSORRT_DIR
=
${
TENSORRT_DIR
}
echo
"---------------------------"
else
else
cmake ..
\
cmake ..
\
-DPADDLE_LIB
=
${
LIB_DIR
}
\
-DPADDLE_LIB
=
${
LIB_DIR
}
\
...
@@ -259,7 +267,7 @@ else
...
@@ -259,7 +267,7 @@ else
-DCUDNN_LIB
=
${
CUDNN_LIB_DIR
}
\
-DCUDNN_LIB
=
${
CUDNN_LIB_DIR
}
\
-DCUDA_LIB
=
${
CUDA_LIB_DIR
}
\
-DCUDA_LIB
=
${
CUDA_LIB_DIR
}
\
-DTENSORRT_DIR
=
${
TENSORRT_DIR
}
\
-DTENSORRT_DIR
=
${
TENSORRT_DIR
}
\
-DFAISS_DIR
=
${
FAISS_DIR
}
\
-DFAISS_DIR
=
${
faiss_install_path
}
\
-DFAISS_WITH_MKL
=
OFF
-DFAISS_WITH_MKL
=
OFF
fi
fi
make
-j
make
-j
...
@@ -269,14 +277,14 @@ echo "################### build PaddleClas demo finished ###################"
...
@@ -269,14 +277,14 @@ echo "################### build PaddleClas demo finished ###################"
# set cuda device
# set cuda device
GPUID
=
$2
#
GPUID=$2
if
[
${#
GPUID
}
-le
0
]
;
then
#
if [ ${#GPUID} -le 0 ];then
env
=
"
"
# env="export CUDA_VISIBLE_DEVICES=0
"
else
#
else
env
=
"export CUDA_VISIBLE_DEVICES=
${
GPUID
}
"
#
env="export CUDA_VISIBLE_DEVICES=${GPUID}"
fi
#
fi
set
CUDA_VISIBLE_DEVICES
#
set CUDA_VISIBLE_DEVICES
eval
$env
#
eval $env
echo
"################### run test ###################"
echo
"################### run test ###################"
...
@@ -287,9 +295,9 @@ for infer_model in ${cpp_infer_model_dir[*]}; do
...
@@ -287,9 +295,9 @@ for infer_model in ${cpp_infer_model_dir[*]}; do
#run inference
#run inference
is_quant
=
${
infer_quant_flag
[Count]
}
is_quant
=
${
infer_quant_flag
[Count]
}
if
[[
$cpp_infer_type
==
"cls"
]]
;
then
if
[[
$cpp_infer_type
==
"cls"
]]
;
then
func_cls_cpp_inference
"
${
inference_cmd
}
"
"
${
infer_model
}
"
"
${
LOG_PATH
}
"
"
${
cpp_image_dir_value
}
"
${
is_quant
}
func_cls_cpp_inference
"
${
inference_cmd
}
"
"
${
infer_model
}
"
"
${
LOG_PATH
}
"
"
${
cpp_image_dir_value
}
"
${
is_quant
}
else
else
func_shitu_cpp_inference
"
${
inference_cmd
}
"
"
${
infer_model
}
"
"
${
LOG_PATH
}
"
"
${
cpp_image_dir_value
}
"
${
is_quant
}
func_shitu_cpp_inference
"
${
inference_cmd
}
"
"
${
infer_model
}
"
"
${
LOG_PATH
}
"
"
${
cpp_image_dir_value
}
"
${
is_quant
}
fi
fi
Count
=
$((
$Count
+
1
))
Count
=
$((
$Count
+
1
))
done
done
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录