Пример #1
0
 def start_single_app_with_file(self):
     port = self.args.config.get("port", 8866)
     self.args.port = port
     if ServingCommand.is_port_occupied("127.0.0.1", port) is True:
         print("Port %s is occupied, please change it." % port)
         return False
     self.modules_info = self.args.config.get("modules_info")
     self.preinstall_modules()
     self.dump_pid_file()
     app.run(configs=self.modules_info, port=port)
Пример #2
0
 def start_single_app_with_args(self):
     module = self.args.modules
     if module is not None:
         port = self.args.port
         if ServingCommand.is_port_occupied("127.0.0.1", port) is True:
             print("Port %s is occupied, please change it." % port)
             return False
         self.preinstall_modules()
         self.dump_pid_file()
         app.run(configs=self.modules_info, port=port)
     else:
         print("Lack of necessary parameters!")
Пример #3
0
 def start_single_app_with_file(configs):
     use_gpu = configs.get("use_gpu", False)
     port = configs.get("port", 8866)
     if ServingCommand.is_port_occupied("127.0.0.1", port) is True:
         print("Port %s is occupied, please change it." % port)
         return False
     configs = configs.get("modules_info")
     module = [str(i["module"]) + "==" + str(i["version"]) for i in configs]
     module_info = ServingCommand.preinstall_modules(module)
     for index in range(len(module_info)):
         configs[index].update(module_info[index])
     app.run(use_gpu, configs=configs, port=port)
Пример #4
0
 def start_single_app_with_args(self):
     module = self.args.modules
     if module is not None:
         use_gpu = self.args.use_gpu
         port = self.args.port
         if ServingCommand.is_port_occupied("127.0.0.1", port) is True:
             print("Port %s is occupied, please change it." % port)
             return False
         module_info = ServingCommand.preinstall_modules(module)
         [
             item.update({
                 "batch_size": 1,
                 "queue_size": 20
             }) for item in module_info
         ]
         app.run(use_gpu, configs=module_info, port=port)
     else:
         print("Lack of necessary parameters!")
Пример #5
0
 def start_serving(args):
     config_file = args.config
     if config_file is not None:
         config_file = config_file[0]
         if os.path.exists(config_file):
             with open(config_file, "r") as fp:
                 configs = json.load(fp)
                 use_multiprocess = configs.get("use_multiprocess", False)
                 if use_multiprocess is True:
                     if platform.system() == "Windows":
                         print(
                             "Warning: Windows cannot use multiprocess working "
                             "mode, Hub-Serving will switch to single process mode"
                         )
                         from paddlehub.serving import app_single as app
                     else:
                         from paddlehub.serving import app
                 else:
                     from paddlehub.serving import app_single as app
                 use_gpu = configs.get("use_gpu", False)
                 port = configs.get("port", 8866)
                 if ServingCommand.is_port_occupied("127.0.0.1",
                                                    port) is True:
                     print("Port %s is occupied, please change it." %
                           (port))
                     return False
                 configs = configs.get("modules_info")
                 module = [
                     str(i["module"]) + "==" + str(i["version"])
                     for i in configs
                 ]
                 module_info = ServingCommand.preinstall_modules(module)
                 for index in range(len(module_info)):
                     configs[index].update(module_info[index])
                 app.run(use_gpu, configs=configs, port=port)
         else:
             print("config_file ", config_file, "not exists.")
     else:
         if args.use_multiprocess is True:
             if platform.system() == "Windows":
                 print(
                     "Warning: Windows cannot use multiprocess working "
                     "mode, Hub-Serving will switch to single process mode")
                 from paddlehub.serving import app_single as app
             else:
                 from paddlehub.serving import app
         else:
             from paddlehub.serving import app_single as app
         module = args.modules
         if module is not None:
             use_gpu = args.use_gpu
             port = args.port[0]
             if ServingCommand.is_port_occupied("127.0.0.1", port) is True:
                 print("Port %s is occupied, please change it." % (port))
                 return False
             module_info = ServingCommand.preinstall_modules(module)
             [
                 item.update({
                     "batch_size": 1,
                     "queue_size": 20
                 }) for item in module_info
             ]
             app.run(use_gpu, configs=module_info, port=port)
         else:
             print("Lack of necessary parameters!")