Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Serving
提交
e4705d52
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看板
提交
e4705d52
编写于
6月 01, 2020
作者:
M
MRXLT
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refine lac demo
上级
4533bce1
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
30 addition
and
29 deletion
+30
-29
python/examples/lac/README.md
python/examples/lac/README.md
+7
-8
python/examples/lac/README_CN.md
python/examples/lac/README_CN.md
+6
-7
python/examples/lac/benchmark.py
python/examples/lac/benchmark.py
+2
-2
python/examples/lac/get_data.sh
python/examples/lac/get_data.sh
+0
-2
python/examples/lac/lac_client.py
python/examples/lac/lac_client.py
+7
-3
python/examples/lac/lac_web_service.py
python/examples/lac/lac_web_service.py
+1
-1
python/paddle_serving_server/web_service.py
python/paddle_serving_server/web_service.py
+1
-1
tools/serving_build.sh
tools/serving_build.sh
+6
-5
未找到文件。
python/examples/lac/README.md
浏览文件 @
e4705d52
...
...
@@ -2,28 +2,27 @@
(
[
简体中文
](
./README_CN.md
)
|English)
### Get
model files and sample data
### Get
Model
```
sh get_data.sh
python -m paddle_serving_app.package --get_model lac
tar -xzvf lac.tar.gz
```
the package downloaded contains lac model config along with lac dictionary.
#### Start RPC inference service
```
python -m paddle_serving_server.serve --model
jieba_server
_model/ --port 9292
python -m paddle_serving_server.serve --model
lac
_model/ --port 9292
```
### RPC Infer
```
echo "我爱北京天安门" | python lac_client.py
jieba_client_conf/serving_client_conf.prototxt lac_dict/
echo "我爱北京天安门" | python lac_client.py
lac_client/serving_client_conf.prototxt
```
it will get the segmentation result
It will get the segmentation result.
### Start HTTP inference service
```
python lac_web_service.py
jieba_server
_model/ lac_workdir 9292
python lac_web_service.py
lac
_model/ lac_workdir 9292
```
### HTTP Infer
...
...
python/examples/lac/README_CN.md
浏览文件 @
e4705d52
...
...
@@ -2,28 +2,27 @@
(简体中文|
[
English
](
./README.md
)
)
### 获取模型
和字典文件
### 获取模型
```
sh get_data.sh
python -m paddle_serving_app.package --get_model lac
tar -xzvf lac.tar.gz
```
下载包里包含了lac模型和lac模型预测需要的字典文件
#### 开启RPC预测服务
```
python -m paddle_serving_server.serve --model
jieba_server
_model/ --port 9292
python -m paddle_serving_server.serve --model
lac
_model/ --port 9292
```
### 执行RPC预测
```
echo "我爱北京天安门" | python lac_client.py
jieba_client_conf/serving_client_conf.prototxt lac_dict/
echo "我爱北京天安门" | python lac_client.py
lac_client/serving_client_conf.prototxt
```
我们就能得到分词结果
### 开启HTTP预测服务
```
python lac_web_service.py
jieba_server
_model/ lac_workdir 9292
python lac_web_service.py
lac
_model/ lac_workdir 9292
```
### 执行HTTP预测
...
...
python/examples/lac/benchmark.py
浏览文件 @
e4705d52
...
...
@@ -16,7 +16,7 @@
import
sys
import
time
import
requests
from
lac_
reader
import
LACReader
from
paddle_serving_app.
reader
import
LACReader
from
paddle_serving_client
import
Client
from
paddle_serving_client.utils
import
MultiThreadRunner
from
paddle_serving_client.utils
import
benchmark_args
...
...
@@ -25,7 +25,7 @@ args = benchmark_args()
def
single_func
(
idx
,
resource
):
reader
=
LACReader
(
"lac_dict"
)
reader
=
LACReader
()
start
=
time
.
time
()
if
args
.
request
==
"rpc"
:
client
=
Client
()
...
...
python/examples/lac/get_data.sh
已删除
100644 → 0
浏览文件 @
4533bce1
wget
--no-check-certificate
https://paddle-serving.bj.bcebos.com/lac/lac_model_jieba_web.tar.gz
tar
-zxvf
lac_model_jieba_web.tar.gz
python/examples/lac/lac_client.py
浏览文件 @
e4705d52
...
...
@@ -15,7 +15,7 @@
# pylint: disable=doc-string-missing
from
paddle_serving_client
import
Client
from
lac_
reader
import
LACReader
from
paddle_serving_app.
reader
import
LACReader
import
sys
import
os
import
io
...
...
@@ -24,7 +24,7 @@ client = Client()
client
.
load_client_config
(
sys
.
argv
[
1
])
client
.
connect
([
"127.0.0.1:9292"
])
reader
=
LACReader
(
sys
.
argv
[
2
]
)
reader
=
LACReader
()
for
line
in
sys
.
stdin
:
if
len
(
line
)
<=
0
:
continue
...
...
@@ -32,4 +32,8 @@ for line in sys.stdin:
if
len
(
feed_data
)
<=
0
:
continue
fetch_map
=
client
.
predict
(
feed
=
{
"words"
:
feed_data
},
fetch
=
[
"crf_decode"
])
print
(
fetch_map
)
begin
=
fetch_map
[
'crf_decode.lod'
][
0
]
end
=
fetch_map
[
'crf_decode.lod'
][
1
]
segs
=
reader
.
parse_result
(
line
,
fetch_map
[
"crf_decode"
][
begin
:
end
])
print
({
"word_seg"
:
"|"
.
join
(
segs
)})
python/examples/lac/lac_web_service.py
浏览文件 @
e4705d52
...
...
@@ -14,7 +14,7 @@
from
paddle_serving_server.web_service
import
WebService
import
sys
from
lac_
reader
import
LACReader
from
paddle_serving_app.
reader
import
LACReader
class
LACService
(
WebService
):
...
...
python/paddle_serving_server/web_service.py
浏览文件 @
e4705d52
...
...
@@ -86,7 +86,7 @@ class WebService(object):
for
key
in
fetch_map
:
fetch_map
[
key
]
=
fetch_map
[
key
].
tolist
()
fetch_map
=
self
.
postprocess
(
feed
=
feed
,
fetch
=
fetch
,
fetch_map
=
fetch_map
)
feed
=
request
.
json
[
"feed"
]
,
fetch
=
fetch
,
fetch_map
=
fetch_map
)
result
=
{
"result"
:
fetch_map
}
except
ValueError
:
result
=
{
"result"
:
"Request Value Error"
}
...
...
tools/serving_build.sh
浏览文件 @
e4705d52
#!/usr/bin/env bash
set
-x
function
unsetproxy
()
{
HTTP_PROXY_TEMP
=
$http_proxy
HTTPS_PROXY_TEMP
=
$https_proxy
...
...
@@ -455,15 +455,16 @@ function python_test_lac() {
cd
lac
# pwd: /Serving/python/examples/lac
case
$TYPE
in
CPU
)
sh get_data.sh
check_cmd
"python -m paddle_serving_server.serve --model jieba_server_model/ --port 9292 &"
python
-m
paddle_serving_app.package
--get_model
lac
tar
-xzvf
lac.tar.gz
check_cmd
"python -m paddle_serving_server.serve --model lac_model/ --port 9292 &"
sleep
5
check_cmd
"echo
\"
我爱北京天安门
\"
| python lac_client.py
jieba_client_conf/serving_client_conf.prototxt lac_dict/
"
check_cmd
"echo
\"
我爱北京天安门
\"
| python lac_client.py
lac_client/serving_client_conf.prototxt
"
echo
"lac CPU RPC inference pass"
kill_server_process
unsetproxy
# maybe the proxy is used on iPipe, which makes web-test failed.
check_cmd
"python lac_web_service.py
jieba_server
_model/ lac_workdir 9292 &"
check_cmd
"python lac_web_service.py
lac
_model/ lac_workdir 9292 &"
sleep
5
check_cmd
"curl -H
\"
Content-Type:application/json
\"
-X POST -d '{
\"
feed
\"
:[{
\"
words
\"
:
\"
我爱北京天安门
\"
}],
\"
fetch
\"
:[
\"
word_seg
\"
]}' http://127.0.0.1:9292/lac/prediction"
# check http code
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录