Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleX
提交
9cc2b119
P
PaddleX
项目概览
PaddlePaddle
/
PaddleX
通知
138
Star
4
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
43
列表
看板
标记
里程碑
合并请求
5
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleX
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
43
Issue
43
列表
看板
标记
里程碑
合并请求
5
合并请求
5
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
9cc2b119
编写于
8月 29, 2020
作者:
S
syyxsxx
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add cpu mkl supported
上级
5c5ff738
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
52 addition
and
7 deletion
+52
-7
deploy/cpp/demo/classifier.cpp
deploy/cpp/demo/classifier.cpp
+4
-1
deploy/cpp/demo/detector.cpp
deploy/cpp/demo/detector.cpp
+4
-1
deploy/cpp/demo/segmenter.cpp
deploy/cpp/demo/segmenter.cpp
+4
-1
deploy/cpp/demo/video_classifier.cpp
deploy/cpp/demo/video_classifier.cpp
+7
-1
deploy/cpp/demo/video_detector.cpp
deploy/cpp/demo/video_detector.cpp
+7
-1
deploy/cpp/demo/video_segmenter.cpp
deploy/cpp/demo/video_segmenter.cpp
+7
-1
deploy/cpp/include/paddlex/paddlex.h
deploy/cpp/include/paddlex/paddlex.h
+13
-1
deploy/cpp/src/paddlex.cpp
deploy/cpp/src/paddlex.cpp
+6
-0
未找到文件。
deploy/cpp/demo/classifier.cpp
浏览文件 @
9cc2b119
...
...
@@ -29,6 +29,7 @@ using namespace std::chrono; // NOLINT
DEFINE_string
(
model_dir
,
""
,
"Path of inference model"
);
DEFINE_bool
(
use_gpu
,
false
,
"Infering with GPU or CPU"
);
DEFINE_bool
(
use_trt
,
false
,
"Infering with TensorRT"
);
DEFINE_bool
(
use_mkl
,
true
,
"Infering with MKL"
);
DEFINE_int32
(
gpu_id
,
0
,
"GPU card id"
);
DEFINE_string
(
key
,
""
,
"key of encryption"
);
DEFINE_string
(
image
,
""
,
"Path of test image file"
);
...
...
@@ -56,8 +57,10 @@ int main(int argc, char** argv) {
model
.
Init
(
FLAGS_model_dir
,
FLAGS_use_gpu
,
FLAGS_use_trt
,
FLAGS_use_mkl
,
FLAGS_gpu_id
,
FLAGS_key
);
FLAGS_key
,
FLAGS_thread_num
);
// Predict
int
imgs
=
1
;
...
...
deploy/cpp/demo/detector.cpp
浏览文件 @
9cc2b119
...
...
@@ -31,6 +31,7 @@ using namespace std::chrono; // NOLINT
DEFINE_string
(
model_dir
,
""
,
"Path of inference model"
);
DEFINE_bool
(
use_gpu
,
false
,
"Infering with GPU or CPU"
);
DEFINE_bool
(
use_trt
,
false
,
"Infering with TensorRT"
);
DEFINE_bool
(
use_mkl
,
true
,
"Infering with MKL"
);
DEFINE_int32
(
gpu_id
,
0
,
"GPU card id"
);
DEFINE_string
(
key
,
""
,
"key of encryption"
);
DEFINE_string
(
image
,
""
,
"Path of test image file"
);
...
...
@@ -61,8 +62,10 @@ int main(int argc, char** argv) {
model
.
Init
(
FLAGS_model_dir
,
FLAGS_use_gpu
,
FLAGS_use_trt
,
FLAGS_use_mkl
,
FLAGS_gpu_id
,
FLAGS_key
);
FLAGS_key
,
FLAGS_thread_num
);
int
imgs
=
1
;
std
::
string
save_dir
=
"output"
;
// Predict
...
...
deploy/cpp/demo/segmenter.cpp
浏览文件 @
9cc2b119
...
...
@@ -30,6 +30,7 @@ using namespace std::chrono; // NOLINT
DEFINE_string
(
model_dir
,
""
,
"Path of inference model"
);
DEFINE_bool
(
use_gpu
,
false
,
"Infering with GPU or CPU"
);
DEFINE_bool
(
use_trt
,
false
,
"Infering with TensorRT"
);
DEFINE_bool
(
use_mkl
,
true
,
"Infering with MKL"
);
DEFINE_int32
(
gpu_id
,
0
,
"GPU card id"
);
DEFINE_string
(
key
,
""
,
"key of encryption"
);
DEFINE_string
(
image
,
""
,
"Path of test image file"
);
...
...
@@ -58,8 +59,10 @@ int main(int argc, char** argv) {
model
.
Init
(
FLAGS_model_dir
,
FLAGS_use_gpu
,
FLAGS_use_trt
,
FLAGS_use_mkl
,
FLAGS_gpu_id
,
FLAGS_key
);
FLAGS_key
,
FLAGS_thread_num
);
int
imgs
=
1
;
// Predict
if
(
FLAGS_image_list
!=
""
)
{
...
...
deploy/cpp/demo/video_classifier.cpp
浏览文件 @
9cc2b119
...
...
@@ -35,8 +35,12 @@ using namespace std::chrono; // NOLINT
DEFINE_string
(
model_dir
,
""
,
"Path of inference model"
);
DEFINE_bool
(
use_gpu
,
false
,
"Infering with GPU or CPU"
);
DEFINE_bool
(
use_trt
,
false
,
"Infering with TensorRT"
);
DEFINE_bool
(
use_mkl
,
true
,
"Infering with MKL"
);
DEFINE_int32
(
gpu_id
,
0
,
"GPU card id"
);
DEFINE_string
(
key
,
""
,
"key of encryption"
);
DEFINE_int32
(
thread_num
,
omp_get_num_procs
(),
"Number of preprocessing threads"
);
DEFINE_bool
(
use_camera
,
false
,
"Infering with Camera"
);
DEFINE_int32
(
camera_id
,
0
,
"Camera id"
);
DEFINE_string
(
video_path
,
""
,
"Path of input video"
);
...
...
@@ -62,8 +66,10 @@ int main(int argc, char** argv) {
model
.
Init
(
FLAGS_model_dir
,
FLAGS_use_gpu
,
FLAGS_use_trt
,
FLAGS_use_mkl
,
FLAGS_gpu_id
,
FLAGS_key
);
FLAGS_key
,
FLAGS_thread_num
);
// Open video
cv
::
VideoCapture
capture
;
...
...
deploy/cpp/demo/video_detector.cpp
浏览文件 @
9cc2b119
...
...
@@ -35,6 +35,7 @@ using namespace std::chrono; // NOLINT
DEFINE_string
(
model_dir
,
""
,
"Path of inference model"
);
DEFINE_bool
(
use_gpu
,
false
,
"Infering with GPU or CPU"
);
DEFINE_bool
(
use_trt
,
false
,
"Infering with TensorRT"
);
DEFINE_bool
(
use_mkl
,
true
,
"Infering with MKL"
);
DEFINE_int32
(
gpu_id
,
0
,
"GPU card id"
);
DEFINE_bool
(
use_camera
,
false
,
"Infering with Camera"
);
DEFINE_int32
(
camera_id
,
0
,
"Camera id"
);
...
...
@@ -42,6 +43,9 @@ DEFINE_string(video_path, "", "Path of input video");
DEFINE_bool
(
show_result
,
false
,
"show the result of each frame with a window"
);
DEFINE_bool
(
save_result
,
true
,
"save the result of each frame to a video"
);
DEFINE_string
(
key
,
""
,
"key of encryption"
);
DEFINE_int32
(
thread_num
,
omp_get_num_procs
(),
"Number of preprocessing threads"
);
DEFINE_string
(
save_dir
,
"output"
,
"Path to save visualized image"
);
DEFINE_double
(
threshold
,
0.5
,
...
...
@@ -64,8 +68,10 @@ int main(int argc, char** argv) {
model
.
Init
(
FLAGS_model_dir
,
FLAGS_use_gpu
,
FLAGS_use_trt
,
FLAGS_use_mkl
,
FLAGS_gpu_id
,
FLAGS_key
);
FLAGS_key
,
FLAGS_thread_num
);
// Open video
cv
::
VideoCapture
capture
;
if
(
FLAGS_use_camera
)
{
...
...
deploy/cpp/demo/video_segmenter.cpp
浏览文件 @
9cc2b119
...
...
@@ -35,8 +35,12 @@ using namespace std::chrono; // NOLINT
DEFINE_string
(
model_dir
,
""
,
"Path of inference model"
);
DEFINE_bool
(
use_gpu
,
false
,
"Infering with GPU or CPU"
);
DEFINE_bool
(
use_trt
,
false
,
"Infering with TensorRT"
);
DEFINE_bool
(
use_mkl
,
true
,
"Infering with MKL"
);
DEFINE_int32
(
gpu_id
,
0
,
"GPU card id"
);
DEFINE_string
(
key
,
""
,
"key of encryption"
);
DEFINE_int32
(
thread_num
,
omp_get_num_procs
(),
"Number of preprocessing threads"
);
DEFINE_bool
(
use_camera
,
false
,
"Infering with Camera"
);
DEFINE_int32
(
camera_id
,
0
,
"Camera id"
);
DEFINE_string
(
video_path
,
""
,
"Path of input video"
);
...
...
@@ -62,8 +66,10 @@ int main(int argc, char** argv) {
model
.
Init
(
FLAGS_model_dir
,
FLAGS_use_gpu
,
FLAGS_use_trt
,
FLAGS_use_mkl
,
FLAGS_gpu_id
,
FLAGS_key
);
FLAGS_key
,
FLAGS_thread_num
);
// Open video
cv
::
VideoCapture
capture
;
if
(
FLAGS_use_camera
)
{
...
...
deploy/cpp/include/paddlex/paddlex.h
浏览文件 @
9cc2b119
...
...
@@ -77,17 +77,29 @@ class Model {
void
Init
(
const
std
::
string
&
model_dir
,
bool
use_gpu
=
false
,
bool
use_trt
=
false
,
bool
use_mkl
=
true
,
int
gpu_id
=
0
,
std
::
string
key
=
""
,
int
thread_num
=
1
,
bool
use_ir_optim
=
true
)
{
create_predictor
(
model_dir
,
use_gpu
,
use_trt
,
gpu_id
,
key
,
use_ir_optim
);
create_predictor
(
model_dir
,
use_gpu
,
use_trt
,
use_mkl
,
gpu_id
,
key
,
thread_num
,
use_ir_optim
);
}
void
create_predictor
(
const
std
::
string
&
model_dir
,
bool
use_gpu
=
false
,
bool
use_trt
=
false
,
bool
use_mkl
=
true
,
int
gpu_id
=
0
,
std
::
string
key
=
""
,
int
thread_num
=
1
,
bool
use_ir_optim
=
true
);
/*
...
...
deploy/cpp/src/paddlex.cpp
浏览文件 @
9cc2b119
...
...
@@ -21,8 +21,10 @@ namespace PaddleX {
void
Model
::
create_predictor
(
const
std
::
string
&
model_dir
,
bool
use_gpu
,
bool
use_trt
,
bool
use_mkl
,
int
gpu_id
,
std
::
string
key
,
int
thread_num
,
bool
use_ir_optim
)
{
paddle
::
AnalysisConfig
config
;
std
::
string
model_file
=
model_dir
+
OS_PATH_SEP
+
"__model__"
;
...
...
@@ -57,6 +59,10 @@ void Model::create_predictor(const std::string& model_dir,
if
(
key
==
""
)
{
config
.
SetModel
(
model_file
,
params_file
);
}
if
(
use_mkl
&&
name
!=
"HRNet"
&&
name
!=
"DeepLabv3p"
)
{
config
.
EnableMKLDNN
();
config
.
SetCpuMathLibraryNumThreads
(
12
);
}
if
(
use_gpu
)
{
config
.
EnableUseGpu
(
100
,
gpu_id
);
}
else
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录