(self, model_name, model_base_path, verbose=False)
Initialize the service.
        
    Args:
      model_name: The name of the model.
      model_base_path: The file path of the model.
    Return:
      None
Initialize the service.
        
    Args:
      model_name: The name of the model.
      model_base_path: The file path of the model.
    Return:
      None
Initialize the service . Args : model_name : The name of the model . model_base_path : The file path of the model . Return : None
def __init__(self, model_name, model_base_path, verbose=False):
    """
    Initialize the service.
        
    Args:
      model_name: The name of the model.
      model_base_path: The file path of the model.
    Return:
      None
    """
    super(PytorchOnnxInferenceService, self).__init__()

    # Init onnx datatype map to numpy
    self.init_dtype_map()

    self.model_name = model_name
    self.model_base_path = model_base_path
    self.model_version_list = []

    self.model_version_dict = {}
    self.model_dict = {}
    self.executor_dict = {}
    self.model_graph_signature_dict = {}

    # This property is for index.html
    self.model_graph_signature = self.model_graph_signature_dict

    self.platform = "PyTorch_ONNX"
    self.verbose = verbose

    # Find available models
    model_path_list = []
    if os.path.isdir(self.model_base_path):
      for filename in os.path.listdir(self.model_base_path):
        if filename.endswith(".onnx"):
          path = os.path.join(self.model_base_path, filename)
          logging.info("Found onnx model: {}".format(path))
          model_path_list.append(path)
      if len(model_path_list) == 0:
        logging.error("No onnx model found in {}".format(self.model_base_path))
    elif os.path.isfile(self.model_base_path):
      logging.info("Found onnx model: {}".format(self.model_base_path))
      model_path_list.append(self.model_base_path)
    else:
      raise Exception("Invalid model_base_path: {}".format(self.model_base_path))

    # Load available models
    count = 1
    for model_path in model_path_list:
      try:
        version = str(count)
        model, executor, signature = self.load_model(model_path)
        logging.info("Load onnx model: {}, signature: {}".format(
          model_path, json.dumps(signature)))
        self.model_version_dict[version] = model_path
        self.model_dict[version] = model
        self.executor_dict[version] = executor
        self.model_graph_signature_dict[version] = signature
        self.model_version_list.append(version)
        count += 1
      except Exception as e:
        traceback.print_exc()
def __init__ ( self , model_name , model_base_path , verbose = False ) : super ( PytorchOnnxInferenceService , self ) . __init__ ( ) # Init onnx datatype map to numpy self . init_dtype_map ( ) self . model_name = model_name self . model_base_path = model_base_path self . model_version_list = [ ] self . model_version_dict = { } self . model_dict = { } self . executor_dict = { } self . model_graph_signature_dict = { } # This property is for index.html self . model_graph_signature = self . model_graph_signature_dict self . platform = "PyTorch_ONNX" self . verbose = verbose # Find available models model_path_list = [ ] if os . path . isdir ( self . model_base_path ) : for filename in os . path . listdir ( self . model_base_path ) : if filename . endswith ( ".onnx" ) : path = os . path . join ( self . model_base_path , filename ) logging . info ( "Found onnx model: {}" . format ( path ) ) model_path_list . append ( path ) if len ( model_path_list ) == 0 : logging . error ( "No onnx model found in {}" . format ( self . model_base_path ) ) elif os . path . isfile ( self . model_base_path ) : logging . info ( "Found onnx model: {}" . format ( self . model_base_path ) ) model_path_list . append ( self . model_base_path ) else : raise Exception ( "Invalid model_base_path: {}" . format ( self . model_base_path ) ) # Load available models count = 1 for model_path in model_path_list : try : version = str ( count ) model , executor , signature = self . load_model ( model_path ) logging . info ( "Load onnx model: {}, signature: {}" . format ( model_path , json . dumps ( signature ) ) ) self . model_version_dict [ version ] = model_path self . model_dict [ version ] = model self . executor_dict [ version ] = executor self . model_graph_signature_dict [ version ] = signature self . model_version_list . append ( version ) count += 1 except Exception as e : traceback . print_exc ( )