diff --git a/python/examples/senta/README.md b/python/examples/senta/README.md index 0fa4d860ab7fc0a41b009a782a73668f19e05dfc..085820dc7a616667edb5973c0cae3a3da3ba5e57 100644 --- a/python/examples/senta/README.md +++ b/python/examples/senta/README.md @@ -4,10 +4,6 @@ ``` sh get_data.sh ``` - -## Start rpc service - - ## Start http service ``` 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 ``` -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 ``` diff --git a/python/examples/senta/senta_web_service.py b/python/examples/senta/senta_web_service.py index 7785c0d4081fbc3c94db7b981dbc9dbe1c6ace01..1384c74a3e6699bbe30d2025a0b26366ee4b28f4 100644 --- a/python/examples/senta/senta_web_service.py +++ b/python/examples/senta/senta_web_service.py @@ -14,8 +14,7 @@ from paddle_serving_server_gpu.web_service import WebService from paddle_serving_client import Client -from lac_reader import LACReader -from senta_reader import SentaReader +from paddle_serving_app import LACReader, SentaReader import numpy as np import os import io @@ -28,9 +27,10 @@ class SentaService(WebService): def start_lac_service(self): print(" ---- start lac service ---- ") os.chdir('./lac_serving') + self.lac_port = self.port + 100 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('..') def init_lac_service(self): @@ -49,7 +49,7 @@ class SentaService(WebService): self.lac_client = Client() self.lac_client.load_client_config( "../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): self.lac_reader = LACReader("../lac/lac_dict") @@ -81,13 +81,13 @@ class SentaService(WebService): senta_service = SentaService(name="senta") 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_senta_reader() print("Init senta done") senta_service.init_lac_service() 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_flask()