diff --git a/python/paddle_serving_server/web_service.py b/python/paddle_serving_server/web_service.py index 0327af03647377e1fc10c4b42fc6aca67e366d8a..18e6664edbfd486bb0156ecc58232795f16d74bb 100644 --- a/python/paddle_serving_server/web_service.py +++ b/python/paddle_serving_server/web_service.py @@ -52,6 +52,20 @@ class WebService(object): def load_model_config(self, model_config): print("This API will be deprecated later. Please do not use it") self.model_config = model_config + import os + from .proto import general_model_config_pb2 as m_config + import google.protobuf.text_format + if os.path.isdir(model_config): + client_config = "{}/serving_server_conf.prototxt".format( + model_config) + elif os.path.isfile(path): + client_config = model_config + model_conf = m_config.GeneralModelConfig() + f = open(client_config, 'r') + model_conf = google.protobuf.text_format.Merge( + str(f.read()), model_conf) + self.feed_names = [var.alias_name for var in model_conf.feed_var] + self.fetch_names = [var.alias_name for var in model_conf.fetch_var] def _launch_rpc_service(self): op_maker = OpMaker() @@ -179,10 +193,7 @@ class WebService(object): def run_web_service(self): print("This API will be deprecated later. Please do not use it") - self.app_instance.run(host="0.0.0.0", - port=self.port, - threaded=False, - processes=1) + self.app_instance.run(host="0.0.0.0", port=self.port, threaded=True) def get_app_instance(self): return self.app_instance diff --git a/python/paddle_serving_server_gpu/web_service.py b/python/paddle_serving_server_gpu/web_service.py index 560ffa83d067de4bb296a3e6b479c0b00f595a8c..47bf38bf94d6b6444377e3e3967b196bb3edd6a7 100644 --- a/python/paddle_serving_server_gpu/web_service.py +++ b/python/paddle_serving_server_gpu/web_service.py @@ -58,6 +58,20 @@ class WebService(object): def load_model_config(self, model_config): print("This API will be deprecated later. Please do not use it") self.model_config = model_config + import os + from .proto import general_model_config_pb2 as m_config + import google.protobuf.text_format + if os.path.isdir(model_config): + client_config = "{}/serving_server_conf.prototxt".format( + model_config) + elif os.path.isfile(path): + client_config = model_config + model_conf = m_config.GeneralModelConfig() + f = open(client_config, 'r') + model_conf = google.protobuf.text_format.Merge( + str(f.read()), model_conf) + self.feed_names = [var.alias_name for var in model_conf.feed_var] + self.fetch_names = [var.alias_name for var in model_conf.fetch_var] def set_gpus(self, gpus): print("This API will be deprecated later. Please do not use it") @@ -240,10 +254,7 @@ class WebService(object): def run_web_service(self): print("This API will be deprecated later. Please do not use it") - self.app_instance.run(host="0.0.0.0", - port=self.port, - threaded=False, - processes=4) + self.app_instance.run(host="0.0.0.0", port=self.port, threaded=True) def get_app_instance(self): return self.app_instance