提交 5831f6f4 编写于 作者: G guru4elephant

add more arguments for serve

上级 3527f627
make: *** No targets specified and no makefile found. Stop.
...@@ -17,8 +17,29 @@ Usage: ...@@ -17,8 +17,29 @@ Usage:
Example: Example:
python -m paddle_serving_server.serve model 9292 python -m paddle_serving_server.serve model 9292
""" """
import argparse
def parse_args():
parser = argparse.ArgumentParser("serve")
parser.add_argument("--thread", type=int, default=10, help="Concurrency of server")
parser.add_argument("--model", type=str, default="", help="Model for serving")
parser.add_argument("--port", type=int, default=9292, help="Port the server")
parser.add_argument("--workdir", type=str, default="workdir", help="Working dir of current service")
parser.add_argument("--device", type=str, default="cpu", help="Type of device")
return parser.parse_args()
def start_standard_model():
args = parse_args()
thread_num = args.thread
model = args.model
port = args.port
workdir = args.workdir
device = args.device
if model == "":
print("You must specify your serving model")
exit(-1)
def start_standard_model(model_folder, port, thread_num):
import paddle_serving_server as serving import paddle_serving_server as serving
op_maker = serving.OpMaker() op_maker = serving.OpMaker()
read_op = op_maker.create('general_reader') read_op = op_maker.create('general_reader')
...@@ -30,17 +51,14 @@ def start_standard_model(model_folder, port, thread_num): ...@@ -30,17 +51,14 @@ def start_standard_model(model_folder, port, thread_num):
op_seq_maker.add_op(general_infer_op) op_seq_maker.add_op(general_infer_op)
op_seq_maker.add_op(general_response_op) op_seq_maker.add_op(general_response_op)
server = Server() server = serving.Server()
server.set_op_sequence(op_seq_maker.get_op_sequence()) server.set_op_sequence(op_seq_maker.get_op_sequence())
server.set_num_thread(thread_num) server.set_num_threads(thread_num)
server.set_vlog_level(0)
server.load_model_config(model_folder) server.load_model_config(model)
port = port server.prepare_server(workdir=workdir, port=port, device=device)
server.prepare_server(workdir="workdir", port=port, device="cpu")
server.run_server() server.run_server()
if __name__ == "__main__": if __name__ == "__main__":
if len(sys.argv) != 4: start_standard_model()
print("{} model_folder port thread".format(sys.argv[0]))
sys.exit(0)
start_standard_model(sys.argv[1], int(sys.argv[2]), int(sys.argv[3]))
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册