提交 0772c402 编写于 作者: M MRXLT

fix demo

上级 3b028ad8
...@@ -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:9393/senta/prediction curl -H "Content-Type:application/json" -X POST -d '{"words": "天气不错 | 0", "fetch":["sentence_feature"]}' http://127.0.0.1:9292/senta/prediction
``` ```
...@@ -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.
先完成此消息的编辑!
想要评论请 注册