Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Serving
提交
9ed23895
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看板
提交
9ed23895
编写于
1月 07, 2021
作者:
H
HexToString
浏览文件
操作
浏览文件
下载
差异文件
fix python bug and add java client.
上级
d7a468dd
94b6f8aa
变更
6
显示空白变更内容
内联
并排
Showing
6 changed file
with
135 addition
and
0 deletion
+135
-0
python/examples/encryption/README.md
python/examples/encryption/README.md
+34
-0
python/examples/encryption/README_CN.md
python/examples/encryption/README_CN.md
+33
-0
python/examples/encryption/encrypt.py
python/examples/encryption/encrypt.py
+27
-0
python/examples/encryption/get_data.sh
python/examples/encryption/get_data.sh
+4
-0
python/examples/encryption/test_client.py
python/examples/encryption/test_client.py
+32
-0
python/examples/pipeline/simple_web_service/web_service_java.py
.../examples/pipeline/simple_web_service/web_service_java.py
+5
-0
未找到文件。
python/examples/encryption/README.md
0 → 100644
浏览文件 @
9ed23895
# Encryption Model Prediction
(
[
简体中文
](
README_CN.md
)
|English)
## Get Origin Model
The example uses the model file of the fit_a_line example as a origin model
```
sh get_data.sh
```
## Encrypt Model
```
python encrypt.py
```
The key is stored in the
`key`
file, and the encrypted model file and server-side configuration file are stored in the
`encrypt_server`
directory.
client-side configuration file are stored in the
`encrypt_client`
directory.
## Start Encryption Service
CPU Service
```
python -m paddle_serving_server.serve --model encrypt_server/ --port 9300 --use_encryption_model
```
GPU Service
```
python -m paddle_serving_server_gpu.serve --model encrypt_server/ --port 9300 --use_encryption_model --gpu_ids 0
```
## Prediction
```
python test_client.py uci_housing_client/serving_client_conf.prototxt
```
python/examples/encryption/README_CN.md
0 → 100644
浏览文件 @
9ed23895
# 加密模型预测
(简体中文|
[
English
](
README.md
)
)
## 获取明文模型
示例中使用fit_a_line示例的模型文件作为明文模型
```
sh get_data.sh
```
## 模型加密
```
python encrypt.py
```
密钥保存在
`key`
文件中,加密模型文件以及server端配置文件保存在
`encrypt_server`
目录下,client端配置文件保存在
`encrypt_client`
目录下。
## 启动加密预测服务
CPU预测服务
```
python -m paddle_serving_server.serve --model encrypt_server/ --port 9300 --use_encryption_model
```
GPU预测服务
```
python -m paddle_serving_server_gpu.serve --model encrypt_server/ --port 9300 --use_encryption_model --gpu_ids 0
```
## 预测
```
python test_client.py uci_housing_client/serving_client_conf.prototxt
```
python/examples/encryption/encrypt.py
0 → 100644
浏览文件 @
9ed23895
# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from
paddle_serving_client.io
import
inference_model_to_serving
def
serving_encryption
():
inference_model_to_serving
(
dirname
=
"./uci_housing_model"
,
serving_server
=
"encrypt_server"
,
serving_client
=
"encrypt_client"
,
encryption
=
True
)
if
__name__
==
"__main__"
:
serving_encryption
()
python/examples/encryption/get_data.sh
0 → 100644
浏览文件 @
9ed23895
wget
--no-check-certificate
https://paddle-serving.bj.bcebos.com/uci_housing_example/encrypt.tar.gz
tar
-xzf
encrypt.tar.gz
cp
-rvf
../fit_a_line/uci_housing_model
.
cp
-rvf
../fit_a_line/uci_housing_client
.
python/examples/encryption/test_client.py
0 → 100644
浏览文件 @
9ed23895
# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# pylint: disable=doc-string-missing
from
paddle_serving_client
import
Client
import
sys
client
=
Client
()
client
.
load_client_config
(
sys
.
argv
[
1
])
client
.
use_key
(
"./key"
)
client
.
connect
([
"127.0.0.1:9300"
],
encryption
=
True
)
import
paddle
test_reader
=
paddle
.
batch
(
paddle
.
reader
.
shuffle
(
paddle
.
dataset
.
uci_housing
.
test
(),
buf_size
=
500
),
batch_size
=
1
)
for
data
in
test_reader
():
fetch_map
=
client
.
predict
(
feed
=
{
"x"
:
data
[
0
][
0
]},
fetch
=
[
"price"
])
print
(
"{} {}"
.
format
(
fetch_map
[
"price"
][
0
],
data
[
0
][
1
][
0
]))
python/examples/pipeline/simple_web_service/web_service_java.py
浏览文件 @
9ed23895
...
@@ -28,6 +28,11 @@ class UciOp(Op):
...
@@ -28,6 +28,11 @@ class UciOp(Op):
self
.
separator
=
","
self
.
separator
=
","
def
preprocess
(
self
,
input_dicts
,
data_id
,
log_id
):
def
preprocess
(
self
,
input_dicts
,
data_id
,
log_id
):
"""
diff with web_server.py
javaclient input type is INDArray, restful request input is list.
this function simply reshape input to the Specified shape.
"""
(
_
,
input_dict
),
=
input_dicts
.
items
()
(
_
,
input_dict
),
=
input_dicts
.
items
()
_LOGGER
.
error
(
"UciOp::preprocess >>> log_id:{}, input:{}"
.
format
(
_LOGGER
.
error
(
"UciOp::preprocess >>> log_id:{}, input:{}"
.
format
(
log_id
,
input_dict
))
log_id
,
input_dict
))
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录