Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Serving
提交
d810f341
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看板
未验证
提交
d810f341
编写于
3月 31, 2020
作者:
M
MRXLT
提交者:
GitHub
3月 31, 2020
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #370 from MRXLT/0.2.0-cherry-v1
cherry pick bug fix to 0.2.0
上级
6f76accf
90592946
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
117 addition
and
27 deletion
+117
-27
README.md
README.md
+77
-0
doc/RUN_IN_DOCKER.md
doc/RUN_IN_DOCKER.md
+2
-2
doc/RUN_IN_DOCKER_CN.md
doc/RUN_IN_DOCKER_CN.md
+2
-2
python/examples/criteo_ctr/test_client.py
python/examples/criteo_ctr/test_client.py
+8
-1
python/examples/imagenet/image_http_client.py
python/examples/imagenet/image_http_client.py
+7
-11
python/examples/imagenet/image_rpc_client.py
python/examples/imagenet/image_rpc_client.py
+2
-3
python/examples/imdb/imdb_reader.py
python/examples/imdb/imdb_reader.py
+12
-4
python/paddle_serving_client/metric/__init__.py
python/paddle_serving_client/metric/__init__.py
+2
-2
python/paddle_serving_server_gpu/serve.py
python/paddle_serving_server_gpu/serve.py
+1
-1
python/setup.py.client.in
python/setup.py.client.in
+4
-1
未找到文件。
README.md
浏览文件 @
d810f341
...
...
@@ -154,10 +154,87 @@ curl -H "Content-Type:application/json" -X POST -d '{"url": "https://paddle-serv
{
"label"
:
"daisy"
,
"prob"
:0.9341403245925903
}
```
<h3
align=
"center"
>
More Demos
</h4>
| Key | Value |
| :----------------- | :----------------------------------------------------------- |
| Model Name | Bert-Base-Baike |
| URL |
[
https://paddle-serving.bj.bcebos.com/bert_example/bert_seq128.tar.gz
](
https://paddle-serving.bj.bcebos.com/bert_example%2Fbert_seq128.tar.gz
)
|
| Client/Server Code | https://github.com/PaddlePaddle/Serving/tree/develop/python/examples/bert |
| Description | Get semantic representation from a Chinese Sentence |
| Key | Value |
| :----------------- | :----------------------------------------------------------- |
| Model Name | Resnet50-Imagenet |
| URL |
[
https://paddle-serving.bj.bcebos.com/imagenet-example/ResNet50_vd.tar.gz
](
https://paddle-serving.bj.bcebos.com/imagenet-example%2FResNet50_vd.tar.gz
)
|
| Client/Server Code | https://github.com/PaddlePaddle/Serving/tree/develop/python/examples/imagenet |
| Description | Get image semantic representation from an image |
| Key | Value |
| :----------------- | :----------------------------------------------------------- |
| Model Name | Resnet101-Imagenet |
| URL | https://paddle-serving.bj.bcebos.com/imagenet-example/ResNet101_vd.tar.gz |
| Client/Server Code | https://github.com/PaddlePaddle/Serving/tree/develop/python/examples/imagenet |
| Description | Get image semantic representation from an image |
| Key | Value |
| :----------------- | :----------------------------------------------------------- |
| Model Name | CNN-IMDB |
| URL | https://paddle-serving.bj.bcebos.com/imdb-demo/imdb_model.tar.gz |
| Client/Server Code | https://github.com/PaddlePaddle/Serving/tree/develop/python/examples/imdb |
| Description | Get category probability from an English Sentence |
| Key | Value |
| :----------------- | :----------------------------------------------------------- |
| Model Name | LSTM-IMDB |
| URL | https://paddle-serving.bj.bcebos.com/imdb-demo/imdb_model.tar.gz |
| Client/Server Code | https://github.com/PaddlePaddle/Serving/tree/develop/python/examples/imdb |
| Description | Get category probability from an English Sentence |
| Key | Value |
| :----------------- | :----------------------------------------------------------- |
| Model Name | BOW-IMDB |
| URL | https://paddle-serving.bj.bcebos.com/imdb-demo/imdb_model.tar.gz |
| Client/Server Code | https://github.com/PaddlePaddle/Serving/tree/develop/python/examples/imdb |
| Description | Get category probability from an English Sentence |
| Key | Value |
| :----------------- | :----------------------------------------------------------- |
| Model Name | Jieba-LAC |
| URL | https://paddle-serving.bj.bcebos.com/lac/lac_model.tar.gz |
| Client/Server Code | https://github.com/PaddlePaddle/Serving/tree/develop/python/examples/lac |
| Description | Get word segmentation from a Chinese Sentence |
| Key | Value |
| :----------------- | :----------------------------------------------------------- |
| Model Name | DNN-CTR |
| URL | None(Get model by
[
local_train.py
](
./python/examples/criteo_ctr/local_train.py
)
) |
| Client/Server Code | https://github.com/PaddlePaddle/Serving/tree/develop/python/examples/criteo_ctr |
| Description | Get click probability from a feature vector of item |
| Key | Value |
| :----------------- | :----------------------------------------------------------- |
| Model Name | DNN-CTR(with cube) |
| URL | None(Get model by
[
local_train.py
](
python/examples/criteo_ctr_with_cube/local_train.py
)
) |
| Client/Server Code | https://github.com/PaddlePaddle/Serving/tree/develop/python/examples/criteo_ctr_with_cube |
| Description | Get click probability from a feature vector of item |
<h2
align=
"center"
>
Document
</h2>
### New to Paddle Serving
...
...
doc/RUN_IN_DOCKER.md
浏览文件 @
d810f341
...
...
@@ -147,7 +147,7 @@ tar -xzf uci_housing.tar.gz
Running on the Server side (inside the container):
```
bash
python
-m
paddle_serving_server_gpu.serve
--model
uci_housing_model
--thread
10
--port
9292
--name
uci
python
-m
paddle_serving_server_gpu.serve
--model
uci_housing_model
--thread
10
--port
9292
--name
uci
--gpu_ids
0
```
Running on the Client side (inside or outside the container):
...
...
@@ -161,7 +161,7 @@ tar -xzf uci_housing.tar.gz
Running on the Server side (inside the container):
```
bash
python
-m
paddle_serving_server_gpu.serve
--model
uci_housing_model
--thread
10
--port
9292
python
-m
paddle_serving_server_gpu.serve
--model
uci_housing_model
--thread
10
--port
9292
--gpu_ids
0
```
Running following Python code on the Client side (inside or outside the container, The
`paddle-serving-client`
package needs to be installed):
...
...
doc/RUN_IN_DOCKER_CN.md
浏览文件 @
d810f341
...
...
@@ -145,7 +145,7 @@ tar -xzf uci_housing.tar.gz
在Server端(容器内)运行:
```
bash
python
-m
paddle_serving_server_gpu.serve
--model
uci_housing_model
--thread
10
--port
9292
--name
uci
python
-m
paddle_serving_server_gpu.serve
--model
uci_housing_model
--thread
10
--port
9292
--name
uci
--gpu_ids
0
```
在Client端(容器内或容器外)运行:
...
...
@@ -159,7 +159,7 @@ tar -xzf uci_housing.tar.gz
在Server端(容器内)运行:
```
bash
python
-m
paddle_serving_server_gpu.serve
--model
uci_housing_model
--thread
10
--port
9292
python
-m
paddle_serving_server_gpu.serve
--model
uci_housing_model
--thread
10
--port
9292
--gpu_ids
0
```
在Client端(容器内或容器外,需要安装
`paddle-serving-client`
包)运行下面Python代码:
...
...
python/examples/criteo_ctr/test_client.py
浏览文件 @
d810f341
...
...
@@ -21,6 +21,10 @@ import time
import
criteo_reader
as
criteo
from
paddle_serving_client.metric
import
auc
import
sys
py_version
=
sys
.
version_info
[
0
]
client
=
Client
()
client
.
load_client_config
(
sys
.
argv
[
1
])
client
.
connect
([
"127.0.0.1:9292"
])
...
...
@@ -39,7 +43,10 @@ label_list = []
prob_list
=
[]
start
=
time
.
time
()
for
ei
in
range
(
1000
):
data
=
reader
().
next
()
if
py_version
==
2
:
data
=
reader
().
next
()
else
:
data
=
reader
().
__next__
()
feed_dict
=
{}
for
i
in
range
(
1
,
27
):
feed_dict
[
"sparse_{}"
.
format
(
i
-
1
)]
=
data
[
0
][
i
]
...
...
python/examples/imagenet/image_http_client.py
浏览文件 @
d810f341
...
...
@@ -17,10 +17,16 @@ import base64
import
json
import
time
import
os
import
sys
py_version
=
sys
.
version_info
[
0
]
def
predict
(
image_path
,
server
):
image
=
base64
.
b64encode
(
open
(
image_path
).
read
())
if
py_version
==
2
:
image
=
base64
.
b64encode
(
open
(
image_path
).
read
())
else
:
image
=
base64
.
b64encode
(
open
(
image_path
,
"rb"
).
read
()).
decode
(
"utf-8"
)
req
=
json
.
dumps
({
"image"
:
image
,
"fetch"
:
[
"score"
]})
r
=
requests
.
post
(
server
,
data
=
req
,
headers
=
{
"Content-Type"
:
"application/json"
})
...
...
@@ -28,18 +34,8 @@ def predict(image_path, server):
return
r
def
batch_predict
(
image_path
,
server
):
image
=
base64
.
b64encode
(
open
(
image_path
).
read
())
req
=
json
.
dumps
({
"image"
:
[
image
,
image
],
"fetch"
:
[
"score"
]})
r
=
requests
.
post
(
server
,
data
=
req
,
headers
=
{
"Content-Type"
:
"application/json"
})
print
(
r
.
json
()[
"result"
][
1
][
"score"
][
0
])
return
r
if
__name__
==
"__main__"
:
server
=
"http://127.0.0.1:9393/image/prediction"
#image_path = "./data/n01440764_10026.JPEG"
image_list
=
os
.
listdir
(
"./image_data/n01440764/"
)
start
=
time
.
time
()
for
img
in
image_list
:
...
...
python/examples/imagenet/image_rpc_client.py
浏览文件 @
d810f341
...
...
@@ -19,16 +19,15 @@ import time
client
=
Client
()
client
.
load_client_config
(
sys
.
argv
[
1
])
client
.
connect
([
"127.0.0.1:9
295
"
])
client
.
connect
([
"127.0.0.1:9
393
"
])
reader
=
ImageReader
()
start
=
time
.
time
()
for
i
in
range
(
1000
):
with
open
(
"./data/n01440764_10026.JPEG"
)
as
f
:
with
open
(
"./data/n01440764_10026.JPEG"
,
"rb"
)
as
f
:
img
=
f
.
read
()
img
=
reader
.
process_image
(
img
).
reshape
(
-
1
)
fetch_map
=
client
.
predict
(
feed
=
{
"image"
:
img
},
fetch
=
[
"score"
])
print
(
i
)
end
=
time
.
time
()
print
(
end
-
start
)
...
...
python/examples/imdb/imdb_reader.py
浏览文件 @
d810f341
...
...
@@ -19,15 +19,23 @@ import paddle
import
re
import
paddle.fluid.incubate.data_generator
as
dg
py_version
=
sys
.
version_info
[
0
]
class
IMDBDataset
(
dg
.
MultiSlotDataGenerator
):
def
load_resource
(
self
,
dictfile
):
self
.
_vocab
=
{}
wid
=
0
with
open
(
dictfile
)
as
f
:
for
line
in
f
:
self
.
_vocab
[
line
.
strip
()]
=
wid
wid
+=
1
if
py_version
==
2
:
with
open
(
dictfile
)
as
f
:
for
line
in
f
:
self
.
_vocab
[
line
.
strip
()]
=
wid
wid
+=
1
else
:
with
open
(
dictfile
,
encoding
=
"utf-8"
)
as
f
:
for
line
in
f
:
self
.
_vocab
[
line
.
strip
()]
=
wid
wid
+=
1
self
.
_unk_id
=
len
(
self
.
_vocab
)
self
.
_pattern
=
re
.
compile
(
r
'(;|,|\.|\?|!|\s|\(|\))'
)
self
.
return_value
=
(
"words"
,
[
1
,
2
,
3
,
4
,
5
,
6
]),
(
"label"
,
[
0
])
...
...
python/paddle_serving_client/metric/__init__.py
浏览文件 @
d810f341
...
...
@@ -11,5 +11,5 @@
# 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
auc
import
auc
from
acc
import
acc
from
.
auc
import
auc
from
.
acc
import
acc
python/paddle_serving_server_gpu/serve.py
浏览文件 @
d810f341
...
...
@@ -71,7 +71,7 @@ def start_multi_card(args): # pylint: disable=doc-string-missing
else
:
gpus
=
args
.
gpu_ids
.
split
(
","
)
if
len
(
gpus
)
<=
0
:
start_gpu_card_model
(
-
1
,
args
)
start_gpu_card_model
(
-
1
,
0
,
args
)
else
:
gpu_processes
=
[]
for
i
,
gpu_id
in
enumerate
(
gpus
):
...
...
python/setup.py.client.in
浏览文件 @
d810f341
...
...
@@ -18,6 +18,7 @@ from __future__ import print_function
import platform
import os
import sys
from setuptools import setup, Distribution, Extension
from setuptools import find_packages
...
...
@@ -25,6 +26,7 @@ from setuptools import setup
from paddle_serving_client.version import serving_client_version
from pkg_resources import DistributionNotFound, get_distribution
py_version = sys.version_info[0]
def python_version():
return [int(v) for v in platform.python_version().split(".")]
...
...
@@ -37,8 +39,9 @@ def find_package(pkgname):
return False
def copy_lib():
lib_list = ['libpython2.7.so.1.0', 'libssl.so.10', 'libcrypto.so.10'] if py_version == 2 else ['libpython3.6m.so.1.0', 'libssl.so.10', 'libcrypto.so.10']
os.popen('mkdir -p paddle_serving_client/lib')
for lib in
['libpython2.7.so.1.0', 'libssl.so.10', 'libcrypto.so.10']
:
for lib in
lib_list
:
r = os.popen('whereis {}'.format(lib))
text = r.read()
os.popen('cp {} ./paddle_serving_client/lib'.format(text.strip().split(' ')[1]))
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录