Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleX
提交
87c688ed
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看板
提交
87c688ed
编写于
6月 21, 2020
作者:
J
jack
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add encrypted model loading
上级
7df7269a
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
27 addition
and
24 deletion
+27
-24
deploy/cpp/demo/classifier.cpp
deploy/cpp/demo/classifier.cpp
+1
-1
deploy/cpp/include/paddlex/paddlex.h
deploy/cpp/include/paddlex/paddlex.h
+2
-2
deploy/cpp/src/paddlex.cpp
deploy/cpp/src/paddlex.cpp
+10
-7
tools/codestyle/clang_format.hook
tools/codestyle/clang_format.hook
+14
-14
未找到文件。
deploy/cpp/demo/classifier.cpp
浏览文件 @
87c688ed
...
...
@@ -81,7 +81,7 @@ int main(int argc, char** argv) {
auto
start
=
system_clock
::
now
();
// 读图像
int
im_vec_size
=
std
::
min
(
static_cat
<
int
>
(
image_paths
.
size
()),
i
+
FLAGS_batch_size
);
std
::
min
(
static_ca
s
t
<
int
>
(
image_paths
.
size
()),
i
+
FLAGS_batch_size
);
std
::
vector
<
cv
::
Mat
>
im_vec
(
im_vec_size
-
i
);
std
::
vector
<
PaddleX
::
ClsResult
>
results
(
im_vec_size
-
i
,
PaddleX
::
ClsResult
());
...
...
deploy/cpp/include/paddlex/paddlex.h
浏览文件 @
87c688ed
...
...
@@ -95,10 +95,10 @@ class Model {
* This method aims to load model configurations which include
* transform steps and label list
*
* @param
model_dir: the directory which contains model.yml
* @param
yaml_file: model configuration
* @return true if load configuration successfully
* */
bool
load_config
(
const
std
::
string
&
model_dir
);
bool
load_config
(
const
std
::
string
&
yaml_file
);
/*
* @brief
...
...
deploy/cpp/src/paddlex.cpp
浏览文件 @
87c688ed
...
...
@@ -23,22 +23,25 @@ void Model::create_predictor(const std::string& model_dir,
int
gpu_id
,
std
::
string
key
,
int
batch_size
)
{
// 读取配置文件
if
(
!
load_config
(
model_dir
))
{
std
::
cerr
<<
"Parse file 'model.yml' failed!"
<<
std
::
endl
;
exit
(
-
1
);
}
paddle
::
AnalysisConfig
config
;
std
::
string
model_file
=
model_dir
+
OS_PATH_SEP
+
"__model__"
;
std
::
string
params_file
=
model_dir
+
OS_PATH_SEP
+
"__params__"
;
std
::
string
yaml_file
=
model_dir
+
OS_PATH_SEP
+
"model.yml"
;
#ifdef WITH_ENCRYPTION
if
(
key
!=
""
)
{
model_file
=
model_dir
+
OS_PATH_SEP
+
"__model__.encrypted"
;
params_file
=
model_dir
+
OS_PATH_SEP
+
"__params__.encrypted"
;
std
::
string
yaml_file
=
model_dir
+
OS_PATH_SEP
+
"model.yml.encrypted"
;
paddle_security_load_model
(
&
config
,
key
.
c_str
(),
model_file
.
c_str
(),
params_file
.
c_str
());
}
#endif
// 读取配置文件
if
(
!
load_config
(
yaml_file
))
{
std
::
cerr
<<
"Parse file 'model.yml' failed!"
<<
std
::
endl
;
exit
(
-
1
);
}
if
(
key
==
""
)
{
config
.
SetModel
(
model_file
,
params_file
);
}
...
...
@@ -64,8 +67,8 @@ void Model::create_predictor(const std::string& model_dir,
inputs_batch_
.
assign
(
batch_size
,
ImageBlob
());
}
bool
Model
::
load_config
(
const
std
::
string
&
model_dir
)
{
std
::
string
yaml_file
=
model_dir
+
OS_PATH_SEP
+
"model.yml"
;
bool
Model
::
load_config
(
const
std
::
string
&
yaml_file
)
{
//
std::string yaml_file = model_dir + OS_PATH_SEP + "model.yml";
YAML
::
Node
config
=
YAML
::
LoadFile
(
yaml_file
);
type
=
config
[
"_Attributes"
][
"model_type"
].
as
<
std
::
string
>
();
name
=
config
[
"Model"
].
as
<
std
::
string
>
();
...
...
tools/codestyle/clang_format.hook
浏览文件 @
87c688ed
#!/bin/bash
set
-e
readonly
VERSION
=
"3.8"
version
=
$(
clang-format
-version
)
if
!
[[
$version
==
*
"
$VERSION
"
*
]]
;
then
echo
"clang-format version check failed."
echo
"a version contains '
$VERSION
' is needed, but get '
$version
'"
echo
"you can install the right version, and make an soft-link to '
\$
PATH' env"
exit
-1
fi
clang-format
$@
#
set -e
#
#
readonly VERSION="3.8"
#
#
version=$(clang-format -version)
#
#
if ! [[ $version == *"$VERSION"* ]]; then
#
echo "clang-format version check failed."
#
echo "a version contains '$VERSION' is needed, but get '$version'"
#
echo "you can install the right version, and make an soft-link to '\$PATH' env"
#
exit -1
#
fi
#
#
clang-format $@
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录