diff --git a/python/examples/lac/lac_client.py b/python/examples/lac/lac_client.py index ab9af730abb2f5b33f4d0292115b2f7bf682f278..22f3c511dcd2540365623ef9428b60cfcb5e5a34 100644 --- a/python/examples/lac/lac_client.py +++ b/python/examples/lac/lac_client.py @@ -35,5 +35,4 @@ for line in sys.stdin: 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)}) + print("word_seg: " + "|".join(str(words) for words in segs)) diff --git a/python/examples/senta/README.md b/python/examples/senta/README.md index 9aeb6d1191719e067e2cb99d408a6d091c25ede3..8929a9312c17264800f299f77afb583221006068 100644 --- a/python/examples/senta/README.md +++ b/python/examples/senta/README.md @@ -5,6 +5,8 @@ ``` python -m paddle_serving_app.package --get_model senta_bilstm python -m paddle_serving_app.package --get_model lac +tar -xzvf senta_bilstm.tar.gz +tar -xzvf lac.tar.gz ``` ## Start HTTP Service @@ -17,5 +19,5 @@ In this demo, the LAC task is placed in the preprocessing part of the HTTP predi ## Client prediction ``` -curl -H "Content-Type:application/json" -X POST -d '{"feed":[{"words": "天气不错"}], "fetch":["class_probs"]}' http://127.0.0.1:9292/senta/prediction +curl -H "Content-Type:application/json" -X POST -d '{"feed":[{"words": "天气不错"}], "fetch":["class_probs"]}' http://127.0.0.1:9393/senta/prediction ``` diff --git a/python/examples/senta/README_CN.md b/python/examples/senta/README_CN.md index f958af221d843748836bea325f87ba603411d39c..e5624dc975e6bc00de219f68cbf74dea7cac8360 100644 --- a/python/examples/senta/README_CN.md +++ b/python/examples/senta/README_CN.md @@ -5,6 +5,8 @@ ``` python -m paddle_serving_app.package --get_model senta_bilstm python -m paddle_serving_app.package --get_model lac +tar -xzvf lac.tar.gz +tar -xzvf senta_bilstm.tar.gz ``` ## 启动HTTP服务 @@ -17,5 +19,5 @@ python senta_web_service.py ## 客户端预测 ``` -curl -H "Content-Type:application/json" -X POST -d '{"feed":[{"words": "天气不错"}], "fetch":["class_probs"]}' http://127.0.0.1:9292/senta/prediction +curl -H "Content-Type:application/json" -X POST -d '{"feed":[{"words": "天气不错"}], "fetch":["class_probs"]}' http://127.0.0.1:9393/senta/prediction ``` diff --git a/python/paddle_serving_app/models/model_list.py b/python/paddle_serving_app/models/model_list.py index cf0ca3bf5765d65065e541462eb919ccc5c4b978..d5f42ab78acdbe837a719908d27cda513da02c3f 100644 --- a/python/paddle_serving_app/models/model_list.py +++ b/python/paddle_serving_app/models/model_list.py @@ -38,7 +38,7 @@ class ServingModels(object): object_detection_url = "https://paddle-serving.bj.bcebos.com/paddle_hub_models/image/ObjectDetection/" ocr_url = "https://paddle-serving.bj.bcebos.com/paddle_hub_models/image/OCR/" senta_url = "https://paddle-serving.bj.bcebos.com/paddle_hub_models/text/SentimentAnalysis/" - semantic_url = "https://paddle-serving.bj.bcebos.com/paddle_hub_models/text/SemanticRepresentation/" + semantic_url = "https://paddle-serving.bj.bcebos.com/paddle_hub_models/text/SemanticModel/" wordseg_url = "https://paddle-serving.bj.bcebos.com/paddle_hub_models/text/LexicalAnalysis/" self.url_dict = {} diff --git a/python/paddle_serving_app/reader/lac_reader.py b/python/paddle_serving_app/reader/lac_reader.py index 7e804ff371e2d90d79f7f663e83a854b1b0c9647..8f7d79a6a1e7ce8c4c86b689e2856eea6fa42158 100644 --- a/python/paddle_serving_app/reader/lac_reader.py +++ b/python/paddle_serving_app/reader/lac_reader.py @@ -111,6 +111,10 @@ class LACReader(object): return word_ids def parse_result(self, words, crf_decode): + try: + words = unicode(words, "utf-8") + except: + pass tags = [self.id2label_dict[str(x[0])] for x in crf_decode] sent_out = [] diff --git a/python/paddle_serving_server/monitor.py b/python/paddle_serving_server/monitor.py index 3f1ff6436917b8ae7ff4ea06fcae1f55bd65e887..84146039c40794436030a8c5c6ba9d18ccbfda06 100644 --- a/python/paddle_serving_server/monitor.py +++ b/python/paddle_serving_server/monitor.py @@ -20,7 +20,7 @@ Usage: import os import time import argparse -import commands +import subprocess import datetime import shutil import tarfile @@ -209,7 +209,7 @@ class HadoopMonitor(Monitor): remote_filepath = os.path.join(path, filename) cmd = '{} -ls {} 2>/dev/null'.format(self._cmd_prefix, remote_filepath) _LOGGER.debug('check cmd: {}'.format(cmd)) - [status, output] = commands.getstatusoutput(cmd) + [status, output] = subprocess.getstatusoutput(cmd) _LOGGER.debug('resp: {}'.format(output)) if status == 0: [_, _, _, _, _, mdate, mtime, _] = output.split('\n')[-1].split() diff --git a/python/paddle_serving_server_gpu/monitor.py b/python/paddle_serving_server_gpu/monitor.py index 3f1ff6436917b8ae7ff4ea06fcae1f55bd65e887..84146039c40794436030a8c5c6ba9d18ccbfda06 100644 --- a/python/paddle_serving_server_gpu/monitor.py +++ b/python/paddle_serving_server_gpu/monitor.py @@ -20,7 +20,7 @@ Usage: import os import time import argparse -import commands +import subprocess import datetime import shutil import tarfile @@ -209,7 +209,7 @@ class HadoopMonitor(Monitor): remote_filepath = os.path.join(path, filename) cmd = '{} -ls {} 2>/dev/null'.format(self._cmd_prefix, remote_filepath) _LOGGER.debug('check cmd: {}'.format(cmd)) - [status, output] = commands.getstatusoutput(cmd) + [status, output] = subprocess.getstatusoutput(cmd) _LOGGER.debug('resp: {}'.format(output)) if status == 0: [_, _, _, _, _, mdate, mtime, _] = output.split('\n')[-1].split()