Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleClas
提交
25adf371
P
PaddleClas
项目概览
PaddlePaddle
/
PaddleClas
大约 1 年 前同步成功
通知
115
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看板
未验证
提交
25adf371
编写于
12月 15, 2020
作者:
L
littletomatodonkey
提交者:
GitHub
12月 15, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add cpp trt (#479)
上级
e51bef26
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
24 addition
and
3 deletion
+24
-3
deploy/cpp_infer/include/cls.h
deploy/cpp_infer/include/cls.h
+6
-1
deploy/cpp_infer/include/cls_config.h
deploy/cpp_infer/include/cls_config.h
+6
-0
deploy/cpp_infer/readme.md
deploy/cpp_infer/readme.md
+1
-1
deploy/cpp_infer/readme_en.md
deploy/cpp_infer/readme_en.md
+1
-1
deploy/cpp_infer/src/cls.cpp
deploy/cpp_infer/src/cls.cpp
+7
-0
deploy/cpp_infer/src/main.cpp
deploy/cpp_infer/src/main.cpp
+1
-0
deploy/cpp_infer/tools/config.txt
deploy/cpp_infer/tools/config.txt
+2
-0
未找到文件。
deploy/cpp_infer/include/cls.h
浏览文件 @
25adf371
...
...
@@ -40,13 +40,16 @@ public:
const
std
::
string
&
params_path
,
const
bool
&
use_gpu
,
const
int
&
gpu_id
,
const
int
&
gpu_mem
,
const
int
&
cpu_math_library_num_threads
,
const
bool
&
use_mkldnn
,
const
int
&
resize_short_size
,
const
bool
&
use_mkldnn
,
const
bool
&
use_tensorrt
,
const
bool
&
use_fp16
,
const
int
&
resize_short_size
,
const
int
&
crop_size
)
{
this
->
use_gpu_
=
use_gpu
;
this
->
gpu_id_
=
gpu_id
;
this
->
gpu_mem_
=
gpu_mem
;
this
->
cpu_math_library_num_threads_
=
cpu_math_library_num_threads
;
this
->
use_mkldnn_
=
use_mkldnn
;
this
->
use_tensorrt_
=
use_tensorrt
;
this
->
use_fp16_
=
use_fp16
;
this
->
resize_short_size_
=
resize_short_size
;
this
->
crop_size_
=
crop_size
;
...
...
@@ -68,6 +71,8 @@ private:
int
gpu_mem_
=
4000
;
int
cpu_math_library_num_threads_
=
4
;
bool
use_mkldnn_
=
false
;
bool
use_tensorrt_
=
false
;
bool
use_fp16_
=
false
;
std
::
vector
<
float
>
mean_
=
{
0.485
f
,
0.456
f
,
0.406
f
};
std
::
vector
<
float
>
scale_
=
{
1
/
0.229
f
,
1
/
0.224
f
,
1
/
0.225
f
};
...
...
deploy/cpp_infer/include/cls_config.h
浏览文件 @
25adf371
...
...
@@ -41,6 +41,9 @@ public:
this
->
use_mkldnn
=
bool
(
stoi
(
config_map_
[
"use_mkldnn"
]));
this
->
use_tensorrt
=
bool
(
stoi
(
config_map_
[
"use_tensorrt"
]));
this
->
use_fp16
=
bool
(
stoi
(
config_map_
[
"use_fp16"
]));
this
->
cls_model_path
.
assign
(
config_map_
[
"cls_model_path"
]);
this
->
cls_params_path
.
assign
(
config_map_
[
"cls_params_path"
]);
...
...
@@ -60,6 +63,9 @@ public:
bool
use_mkldnn
=
false
;
bool
use_tensorrt
=
false
;
bool
use_fp16
=
false
;
std
::
string
cls_model_path
;
std
::
string
cls_params_path
;
...
...
deploy/cpp_infer/readme.md
浏览文件 @
25adf371
...
...
@@ -175,7 +175,7 @@ cmake .. \
-DDEMO_NAME
=
clas_system
\
-DWITH_GPU
=
OFF
\
-DWITH_STATIC_LIB
=
OFF
\
-D
USE
_TENSORRT
=
OFF
\
-D
WITH
_TENSORRT
=
OFF
\
-DOPENCV_DIR
=
${
OPENCV_DIR
}
\
-DCUDNN_LIB
=
${
CUDNN_LIB_DIR
}
\
-DCUDA_LIB
=
${
CUDA_LIB_DIR
}
\
...
...
deploy/cpp_infer/readme_en.md
浏览文件 @
25adf371
...
...
@@ -183,7 +183,7 @@ cmake .. \
-DDEMO_NAME
=
ocr_system
\
-DWITH_GPU
=
OFF
\
-DWITH_STATIC_LIB
=
OFF
\
-D
USE
_TENSORRT
=
OFF
\
-D
WITH
_TENSORRT
=
OFF
\
-DOPENCV_DIR
=
${
OPENCV_DIR
}
\
-DCUDNN_LIB
=
${
CUDNN_LIB_DIR
}
\
-DCUDA_LIB
=
${
CUDA_LIB_DIR
}
\
...
...
deploy/cpp_infer/src/cls.cpp
浏览文件 @
25adf371
...
...
@@ -23,6 +23,13 @@ void Classifier::LoadModel(const std::string &model_path,
if
(
this
->
use_gpu_
)
{
config
.
EnableUseGpu
(
this
->
gpu_mem_
,
this
->
gpu_id_
);
if
(
this
->
use_tensorrt_
)
{
config
.
EnableTensorRtEngine
(
1
<<
20
,
1
,
3
,
this
->
use_fp16_
?
paddle_infer
::
Config
::
Precision
::
kHalf
:
paddle_infer
::
Config
::
Precision
::
kFloat32
,
false
,
false
);
}
}
else
{
config
.
DisableGpu
();
if
(
this
->
use_mkldnn_
)
{
...
...
deploy/cpp_infer/src/main.cpp
浏览文件 @
25adf371
...
...
@@ -62,6 +62,7 @@ int main(int argc, char **argv) {
Classifier
classifier
(
config
.
cls_model_path
,
config
.
cls_params_path
,
config
.
use_gpu
,
config
.
gpu_id
,
config
.
gpu_mem
,
config
.
cpu_math_library_num_threads
,
config
.
use_mkldnn
,
config
.
use_tensorrt
,
config
.
use_fp16
,
config
.
resize_short_size
,
config
.
crop_size
);
double
elapsed_time
=
0.0
;
...
...
deploy/cpp_infer/tools/config.txt
浏览文件 @
25adf371
...
...
@@ -4,6 +4,8 @@ gpu_id 0
gpu_mem 4000
cpu_math_library_num_threads 10
use_mkldnn 1
use_tensorrt 0
use_fp16 0
# cls config
cls_model_path /PaddleClas/inference/cls_infer.pdmodel
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录