Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Serving
提交
97883259
S
Serving
项目概览
PaddlePaddle
/
Serving
大约 2 年 前同步成功
通知
187
Star
833
Fork
253
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
105
列表
看板
标记
里程碑
合并请求
10
Wiki
2
Wiki
分析
仓库
DevOps
项目成员
Pages
S
Serving
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
105
Issue
105
列表
看板
标记
里程碑
合并请求
10
合并请求
10
Pages
分析
分析
仓库分析
DevOps
Wiki
2
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
97883259
编写于
6月 17, 2020
作者:
M
MRXLT
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
support encryption model
上级
145a26f7
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
36 addition
and
8 deletion
+36
-8
paddle_inference/inferencer-fluid-cpu/include/fluid_cpu_engine.h
...inference/inferencer-fluid-cpu/include/fluid_cpu_engine.h
+10
-5
paddle_inference/inferencer-fluid-cpu/src/fluid_cpu_engine.cpp
...e_inference/inferencer-fluid-cpu/src/fluid_cpu_engine.cpp
+7
-0
python/paddle_serving_server/__init__.py
python/paddle_serving_server/__init__.py
+12
-2
python/paddle_serving_server/serve.py
python/paddle_serving_server/serve.py
+7
-0
python/paddle_serving_server/web_service.py
python/paddle_serving_server/web_service.py
+0
-1
未找到文件。
paddle_inference/inferencer-fluid-cpu/include/fluid_cpu_engine.h
浏览文件 @
97883259
...
@@ -19,6 +19,7 @@
...
@@ -19,6 +19,7 @@
#include <map>
#include <map>
#include <string>
#include <string>
#include <vector>
#include <vector>
#include "cipher.h" // NOLINT
#include "cipher_utils.h" // NOLINT
#include "cipher_utils.h" // NOLINT
#include "core/configure/include/configure_parser.h"
#include "core/configure/include/configure_parser.h"
#include "core/configure/inferencer_configure.pb.h"
#include "core/configure/inferencer_configure.pb.h"
...
@@ -531,8 +532,8 @@ class FluidCpuAnalysisDirWithSigmoidCore : public FluidCpuWithSigmoidCore {
...
@@ -531,8 +532,8 @@ class FluidCpuAnalysisDirWithSigmoidCore : public FluidCpuWithSigmoidCore {
return
0
;
return
0
;
}
}
};
};
#if 1
class
FluidCpuAnalysisEncryCore
:
public
FluidFamilyCore
{
class
FluidCpuAnalysisEncry
pt
Core
:
public
FluidFamilyCore
{
public:
public:
int
create
(
const
predictor
::
InferEngineCreationParams
&
params
)
{
int
create
(
const
predictor
::
InferEngineCreationParams
&
params
)
{
std
::
string
data_path
=
params
.
get_path
();
std
::
string
data_path
=
params
.
get_path
();
...
@@ -564,11 +565,14 @@ class FluidCpuAnalysisEncryCore : public FluidFamilyCore {
...
@@ -564,11 +565,14 @@ class FluidCpuAnalysisEncryCore : public FluidFamilyCore {
key_string
=
std
::
string
(
begin
,
end
);
key_string
=
std
::
string
(
begin
,
end
);
key_file
.
close
();
key_file
.
close
();
}
}
#if 1
auto
cipher
=
paddle
::
CipherFactory
::
CreateCipher
(
);
auto
cipher
=
paddle
::
framework
::
CipherFactory
::
CreateCipher
(
""
);
std
::
string
real_model_string
=
cipher
->
Decrypt
(
model_string
,
key_string
);
std
::
string
real_model_string
=
cipher
->
Decrypt
(
model_string
,
key_string
);
std
::
string
real_params_string
=
cipher
->
Decrypt
(
params_string
,
key_string
);
std
::
string
real_params_string
=
cipher
->
Decrypt
(
params_string
,
key_string
);
#else
std
::
string
real_model_string
;
std
::
string
real_params_string
;
#endif
const
char
*
real_model_buffer
=
real_model_string
.
c_str
();
const
char
*
real_model_buffer
=
real_model_string
.
c_str
();
const
char
*
real_params_buffer
=
real_params_string
.
c_str
();
const
char
*
real_params_buffer
=
real_params_string
.
c_str
();
...
@@ -595,6 +599,7 @@ class FluidCpuAnalysisEncryCore : public FluidFamilyCore {
...
@@ -595,6 +599,7 @@ class FluidCpuAnalysisEncryCore : public FluidFamilyCore {
return
0
;
return
0
;
}
}
};
};
#endif
}
// namespace fluid_cpu
}
// namespace fluid_cpu
}
// namespace paddle_serving
}
// namespace paddle_serving
}
// namespace baidu
}
// namespace baidu
paddle_inference/inferencer-fluid-cpu/src/fluid_cpu_engine.cpp
浏览文件 @
97883259
...
@@ -52,6 +52,13 @@ REGIST_FACTORY_OBJECT_IMPL_WITH_NAME(
...
@@ -52,6 +52,13 @@ REGIST_FACTORY_OBJECT_IMPL_WITH_NAME(
::
baidu
::
paddle_serving
::
predictor
::
InferEngine
,
::
baidu
::
paddle_serving
::
predictor
::
InferEngine
,
"FLUID_CPU_NATIVE_DIR_SIGMOID"
);
"FLUID_CPU_NATIVE_DIR_SIGMOID"
);
#if 1
REGIST_FACTORY_OBJECT_IMPL_WITH_NAME
(
::
baidu
::
paddle_serving
::
predictor
::
FluidInferEngine
<
FluidCpuAnalysisEncryptCore
>
,
::
baidu
::
paddle_serving
::
predictor
::
InferEngine
,
"FLUID_CPU_ANALYSIS_ENCRYPT"
);
#endif
}
// namespace fluid_cpu
}
// namespace fluid_cpu
}
// namespace paddle_serving
}
// namespace paddle_serving
}
// namespace baidu
}
// namespace baidu
python/paddle_serving_server/__init__.py
浏览文件 @
97883259
...
@@ -156,6 +156,7 @@ class Server(object):
...
@@ -156,6 +156,7 @@ class Server(object):
self
.
cur_path
=
os
.
getcwd
()
self
.
cur_path
=
os
.
getcwd
()
self
.
use_local_bin
=
False
self
.
use_local_bin
=
False
self
.
mkl_flag
=
False
self
.
mkl_flag
=
False
self
.
encryption_model
=
False
self
.
model_config_paths
=
None
# for multi-model in a workflow
self
.
model_config_paths
=
None
# for multi-model in a workflow
def
set_max_concurrency
(
self
,
concurrency
):
def
set_max_concurrency
(
self
,
concurrency
):
...
@@ -190,6 +191,9 @@ class Server(object):
...
@@ -190,6 +191,9 @@ class Server(object):
def
set_ir_optimize
(
self
,
flag
=
False
):
def
set_ir_optimize
(
self
,
flag
=
False
):
self
.
ir_optimization
=
flag
self
.
ir_optimization
=
flag
def
use_encryption_model
(
self
,
flag
=
False
):
self
.
encryption_model
=
flag
def
check_local_bin
(
self
):
def
check_local_bin
(
self
):
if
"SERVING_BIN"
in
os
.
environ
:
if
"SERVING_BIN"
in
os
.
environ
:
self
.
use_local_bin
=
True
self
.
use_local_bin
=
True
...
@@ -215,8 +219,14 @@ class Server(object):
...
@@ -215,8 +219,14 @@ class Server(object):
engine
.
force_update_static_cache
=
False
engine
.
force_update_static_cache
=
False
if
device
==
"cpu"
:
if
device
==
"cpu"
:
engine
.
type
=
"FLUID_CPU_ANALYSIS_DIR"
if
self
.
encryption_model
:
engine
.
type
=
"FLUID_CPU_ANALYSIS_ENCRYPT"
else
:
engine
.
type
=
"FLUID_CPU_ANALYSIS_ENCRYPT"
elif
device
==
"gpu"
:
elif
device
==
"gpu"
:
if
self
.
encryption_model
:
engine
.
type
=
"FLUID_GPU_ANALYSIS_ENCRYPT"
else
:
engine
.
type
=
"FLUID_GPU_ANALYSIS_DIR"
engine
.
type
=
"FLUID_GPU_ANALYSIS_DIR"
self
.
model_toolkit_conf
.
engines
.
extend
([
engine
])
self
.
model_toolkit_conf
.
engines
.
extend
([
engine
])
...
...
python/paddle_serving_server/serve.py
浏览文件 @
97883259
...
@@ -56,6 +56,11 @@ def parse_args(): # pylint: disable=doc-string-missing
...
@@ -56,6 +56,11 @@ def parse_args(): # pylint: disable=doc-string-missing
type
=
int
,
type
=
int
,
default
=
512
*
1024
*
1024
,
default
=
512
*
1024
*
1024
,
help
=
"Limit sizes of messages"
)
help
=
"Limit sizes of messages"
)
parse
.
add_argument
(
"--use_encryption_model"
,
default
=
False
,
action
=
"store_true"
,
help
=
"Use encryption model"
)
return
parser
.
parse_args
()
return
parser
.
parse_args
()
...
@@ -70,6 +75,7 @@ def start_standard_model(): # pylint: disable=doc-string-missing
...
@@ -70,6 +75,7 @@ def start_standard_model(): # pylint: disable=doc-string-missing
ir_optim
=
args
.
ir_optim
ir_optim
=
args
.
ir_optim
max_body_size
=
args
.
max_body_size
max_body_size
=
args
.
max_body_size
use_mkl
=
args
.
use_mkl
use_mkl
=
args
.
use_mkl
use_encryption_model
=
args
.
use_encryption_model
if
model
==
""
:
if
model
==
""
:
print
(
"You must specify your serving model"
)
print
(
"You must specify your serving model"
)
...
@@ -94,6 +100,7 @@ def start_standard_model(): # pylint: disable=doc-string-missing
...
@@ -94,6 +100,7 @@ def start_standard_model(): # pylint: disable=doc-string-missing
server
.
use_mkl
(
use_mkl
)
server
.
use_mkl
(
use_mkl
)
server
.
set_max_body_size
(
max_body_size
)
server
.
set_max_body_size
(
max_body_size
)
server
.
set_port
(
port
)
server
.
set_port
(
port
)
server
.
use_encryption_model
(
use_encryption_model
)
server
.
load_model_config
(
model
)
server
.
load_model_config
(
model
)
server
.
prepare_server
(
workdir
=
workdir
,
port
=
port
,
device
=
device
)
server
.
prepare_server
(
workdir
=
workdir
,
port
=
port
,
device
=
device
)
...
...
python/paddle_serving_server/web_service.py
浏览文件 @
97883259
...
@@ -93,7 +93,6 @@ class WebService(object):
...
@@ -93,7 +93,6 @@ class WebService(object):
return
result
return
result
def
run_rpc_service
(
self
):
def
run_rpc_service
(
self
):
import
socket
localIP
=
socket
.
gethostbyname
(
socket
.
gethostname
())
localIP
=
socket
.
gethostbyname
(
socket
.
gethostname
())
print
(
"web service address:"
)
print
(
"web service address:"
)
print
(
"http://{}:{}/{}/prediction"
.
format
(
localIP
,
self
.
port
,
print
(
"http://{}:{}/{}/prediction"
.
format
(
localIP
,
self
.
port
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录