Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Serving
提交
0772c402
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看板
提交
0772c402
编写于
4月 26, 2020
作者:
M
MRXLT
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix demo
上级
3b028ad8
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
8 addition
and
12 deletion
+8
-12
python/examples/senta/README.md
python/examples/senta/README.md
+1
-5
python/examples/senta/senta_web_service.py
python/examples/senta/senta_web_service.py
+7
-7
未找到文件。
python/examples/senta/README.md
浏览文件 @
0772c402
...
@@ -4,10 +4,6 @@
...
@@ -4,10 +4,6 @@
```
```
sh get_data.sh
sh get_data.sh
```
```
## Start rpc service
## Start http service
## Start http service
```
```
python senta_web_service.py senta_bilstm_model/ workdir 9292
python senta_web_service.py senta_bilstm_model/ workdir 9292
...
@@ -15,5 +11,5 @@ python senta_web_service.py senta_bilstm_model/ workdir 9292
...
@@ -15,5 +11,5 @@ python senta_web_service.py senta_bilstm_model/ workdir 9292
## Client prediction
## Client prediction
```
```
curl -H "Content-Type:application/json" -X POST -d '{"words": "天气不错 | 0", "fetch":["sentence_feature"]}' http://127.0.0.1:9
393
/senta/prediction
curl -H "Content-Type:application/json" -X POST -d '{"words": "天气不错 | 0", "fetch":["sentence_feature"]}' http://127.0.0.1:9
292
/senta/prediction
```
```
python/examples/senta/senta_web_service.py
浏览文件 @
0772c402
...
@@ -14,8 +14,7 @@
...
@@ -14,8 +14,7 @@
from
paddle_serving_server_gpu.web_service
import
WebService
from
paddle_serving_server_gpu.web_service
import
WebService
from
paddle_serving_client
import
Client
from
paddle_serving_client
import
Client
from
lac_reader
import
LACReader
from
paddle_serving_app
import
LACReader
,
SentaReader
from
senta_reader
import
SentaReader
import
numpy
as
np
import
numpy
as
np
import
os
import
os
import
io
import
io
...
@@ -28,9 +27,10 @@ class SentaService(WebService):
...
@@ -28,9 +27,10 @@ class SentaService(WebService):
def
start_lac_service
(
self
):
def
start_lac_service
(
self
):
print
(
" ---- start lac service ---- "
)
print
(
" ---- start lac service ---- "
)
os
.
chdir
(
'./lac_serving'
)
os
.
chdir
(
'./lac_serving'
)
self
.
lac_port
=
self
.
port
+
100
r
=
os
.
popen
(
r
=
os
.
popen
(
"GLOG_v=2 python -m paddle_serving_server.serve --model ../../lac/jieba_server_model/ --port
9292 &"
"GLOG_v=2 python -m paddle_serving_server.serve --model ../../lac/jieba_server_model/ --port
{} &"
.
)
format
(
self
.
lac_port
)
)
os
.
chdir
(
'..'
)
os
.
chdir
(
'..'
)
def
init_lac_service
(
self
):
def
init_lac_service
(
self
):
...
@@ -49,7 +49,7 @@ class SentaService(WebService):
...
@@ -49,7 +49,7 @@ class SentaService(WebService):
self
.
lac_client
=
Client
()
self
.
lac_client
=
Client
()
self
.
lac_client
.
load_client_config
(
self
.
lac_client
.
load_client_config
(
"../lac/jieba_client_conf/serving_client_conf.prototxt"
)
"../lac/jieba_client_conf/serving_client_conf.prototxt"
)
self
.
lac_client
.
connect
([
"127.0.0.1:
9292"
])
self
.
lac_client
.
connect
([
"127.0.0.1:
{}"
.
format
(
self
.
lac_port
)
])
def
init_lac_reader
(
self
):
def
init_lac_reader
(
self
):
self
.
lac_reader
=
LACReader
(
"../lac/lac_dict"
)
self
.
lac_reader
=
LACReader
(
"../lac/lac_dict"
)
...
@@ -81,13 +81,13 @@ class SentaService(WebService):
...
@@ -81,13 +81,13 @@ class SentaService(WebService):
senta_service
=
SentaService
(
name
=
"senta"
)
senta_service
=
SentaService
(
name
=
"senta"
)
senta_service
.
load_model_config
(
sys
.
argv
[
1
])
senta_service
.
load_model_config
(
sys
.
argv
[
1
])
senta_service
.
prepare_server
(
workdir
=
sys
.
argv
[
2
],
port
=
int
(
sys
.
argv
[
3
]),
device
=
"cpu"
)
senta_service
.
init_lac_reader
()
senta_service
.
init_lac_reader
()
senta_service
.
init_senta_reader
()
senta_service
.
init_senta_reader
()
print
(
"Init senta done"
)
print
(
"Init senta done"
)
senta_service
.
init_lac_service
()
senta_service
.
init_lac_service
()
print
(
"init lac service done"
)
print
(
"init lac service done"
)
senta_service
.
prepare_server
(
workdir
=
sys
.
argv
[
2
],
port
=
int
(
sys
.
argv
[
3
]),
device
=
"cpu"
)
senta_service
.
run_server
()
senta_service
.
run_server
()
#senta_service.run_flask()
#senta_service.run_flask()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录