Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Serving
提交
8c7956ba
S
Serving
项目概览
PaddlePaddle
/
Serving
大约 1 年 前同步成功
通知
186
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看板
提交
8c7956ba
编写于
6月 16, 2020
作者:
M
MRXLT
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
encry
上级
fbd1ecd9
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
129 addition
and
1 deletion
+129
-1
paddle_inference/inferencer-fluid-cpu/include/fluid_cpu_engine.h
...inference/inferencer-fluid-cpu/include/fluid_cpu_engine.h
+64
-0
python/paddle_serving_server/__init__.py
python/paddle_serving_server/__init__.py
+31
-0
python/paddle_serving_server/serve.py
python/paddle_serving_server/serve.py
+34
-1
未找到文件。
paddle_inference/inferencer-fluid-cpu/include/fluid_cpu_engine.h
浏览文件 @
8c7956ba
...
...
@@ -19,6 +19,7 @@
#include <map>
#include <string>
#include <vector>
#include "cipher_utils.h" // NOLINT
#include "core/configure/include/configure_parser.h"
#include "core/configure/inferencer_configure.pb.h"
#include "core/predictor/framework/infer.h"
...
...
@@ -531,6 +532,69 @@ class FluidCpuAnalysisDirWithSigmoidCore : public FluidCpuWithSigmoidCore {
}
};
class
FluidCpuAnalysisEncryCore
:
public
FluidFamilyCore
{
public:
int
create
(
const
predictor
::
InferEngineCreationParams
&
params
)
{
std
::
string
data_path
=
params
.
get_path
();
if
(
access
(
data_path
.
c_str
(),
F_OK
)
==
-
1
)
{
LOG
(
ERROR
)
<<
"create paddle predictor failed, path note exits: "
<<
data_path
;
return
-
1
;
}
std
::
ifstream
model_file
(
data_path
+
"encry_model"
,
std
::
ios
::
in
|
std
::
ios
::
binary
);
std
::
string
model_string
;
if
(
model_file
.
is_open
())
{
std
::
istreambuf_iterator
<
char
>
begin
(
model_file
),
end
;
model_string
=
std
::
string
(
begin
,
end
);
model_file
.
close
();
}
std
::
ifstream
params_file
(
data_path
+
"encry_params"
,
std
::
ios
::
in
|
std
::
ios
::
binary
);
std
::
string
params_string
;
if
(
params_file
.
is_open
())
{
std
::
istreambuf_iterator
<
char
>
begin
(
params_file
),
end
;
params_string
=
std
::
string
(
begin
,
end
);
params_file
.
close
();
}
std
::
ifstream
key_file
(
data_path
+
"key"
,
std
::
ios
::
in
|
std
::
ios
::
binary
);
std
::
string
key_string
;
if
(
key_file
.
is_open
())
{
std
::
istreambuf_iterator
<
char
>
begin
(
key_file
),
end
;
key_string
=
std
::
string
(
begin
,
end
);
key_file
.
close
();
}
auto
cipher
=
paddle
::
CipherFactory
::
CreateCipher
();
std
::
string
real_model_string
=
cipher
->
Decrypt
(
model_string
,
key_string
);
std
::
string
real_params_string
=
cipher
->
Decrypt
(
params_string
,
key_string
);
const
char
*
real_model_buffer
=
real_model_string
.
c_str
();
const
char
*
real_params_buffer
=
real_params_string
.
c_str
();
paddle
::
AnalysisConfig
analysis_config
;
analysis_config
.
SetModelBuffer
(
real_model_buffer
,
real_model_string
.
size
(),
real_params_buffer
,
real_model_string
.
size
());
analysis_config
.
DisableGpu
();
analysis_config
.
SetCpuMathLibraryNumThreads
(
1
);
if
(
params
.
enable_memory_optimization
())
{
analysis_config
.
EnableMemoryOptim
();
}
analysis_config
.
SwitchSpecifyInputNames
(
true
);
AutoLock
lock
(
GlobalPaddleCreateMutex
::
instance
());
_core
=
paddle
::
CreatePaddlePredictor
<
paddle
::
AnalysisConfig
>
(
analysis_config
);
if
(
NULL
==
_core
.
get
())
{
LOG
(
ERROR
)
<<
"create paddle predictor failed, path: "
<<
data_path
;
return
-
1
;
}
VLOG
(
2
)
<<
"create paddle predictor sucess, path: "
<<
data_path
;
return
0
;
}
};
}
// namespace fluid_cpu
}
// namespace paddle_serving
}
// namespace baidu
python/paddle_serving_server/__init__.py
浏览文件 @
8c7956ba
...
...
@@ -593,3 +593,34 @@ class MultiLangServer(object):
server
.
start
()
p_bserver
.
join
()
server
.
wait_for_termination
()
from
BaseHTTPServer
import
BaseHTTPRequestHandler
import
urllib
import
json
from
.serve
import
start_standard_model
import
subprocess
class
MainService
(
BaseHTTPRequestHandler
):
def
_set_headers
(
self
):
self
.
send_response
(
200
)
self
.
send_header
(
'Content-type'
,
'application/json'
)
self
.
end_headers
()
def
do_GET
(
self
):
response
=
{
'status'
:
'SUCCESS'
,
'data'
:
'hello from server'
}
self
.
_set_headers
()
self
.
wfile
.
write
(
json
.
dumps
(
response
))
def
do_POST
(
self
):
path
=
self
.
path
print
(
path
)
content_length
=
int
(
self
.
headers
[
'Content-Length'
])
post_data
=
self
.
rfile
.
read
(
content_length
)
print
(
post_data
)
p
=
subprocess
.
popen
(
start_standard_model
)
response
=
{
"endpoint_list"
:
[
"9292"
]}
self
.
_set_headers
()
self
.
wfile
.
write
(
json
.
dumps
(
response
))
python/paddle_serving_server/serve.py
浏览文件 @
8c7956ba
...
...
@@ -97,11 +97,44 @@ def start_standard_model(): # pylint: disable=doc-string-missing
server
.
run_server
()
from
BaseHTTPServer
import
BaseHTTPRequestHandler
,
HTTPServer
import
urllib
import
json
import
subprocess
class
MainService
(
BaseHTTPRequestHandler
):
def
_set_headers
(
self
):
self
.
send_response
(
200
)
self
.
send_header
(
'Content-type'
,
'application/json'
)
self
.
end_headers
()
def
do_GET
(
self
):
response
=
{
'status'
:
'SUCCESS'
,
'data'
:
'hello from server'
}
self
.
_set_headers
()
self
.
wfile
.
write
(
json
.
dumps
(
response
))
def
do_POST
(
self
):
path
=
self
.
path
print
(
path
)
content_length
=
int
(
self
.
headers
[
'Content-Length'
])
post_data
=
self
.
rfile
.
read
(
content_length
)
print
(
post_data
)
p
=
subprocess
.
popen
(
start_standard_model
)
response
=
{
"endpoint_list"
:
[
"9292"
]}
self
.
_set_headers
()
self
.
wfile
.
write
(
json
.
dumps
(
response
))
if
__name__
==
"__main__"
:
args
=
parse_args
()
if
args
.
name
==
"None"
:
start_standard_model
()
#start_standard_model()
server
=
HTTPServer
((
''
,
int
(
args
.
port
)),
MainService
)
server
.
serve_forever
()
else
:
service
=
WebService
(
name
=
args
.
name
)
service
.
load_model_config
(
args
.
model
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录