RunnerBase
predict: Make prediction with given data and model. This method must be overridden. The data is given from the result ofpreprocess_data, and the return value of this method will be passed topostprocess_databefore service.save_model: Save the model into a file. Return value of this method will be given to theload_modelmethod on model loading. If this method is overriden,load_modelmust be overriden as well.load_model: Load the model from a file.preprocess_data: Preprocess the data before prediction. It converts the API input data to the model input data.postprocess_data: Postprocess the data after prediction. It converts the model output data to the API output data.
.load_model
props is given from the return value of save_model, and artifacts is
given from the register_model method.
If the save_model is not overriden, props will be None
Args
props(dict | None) : Data that was returned bysave_model. Ifsave_modelis not overriden, this will be None.artifacts(dict) : Data that is given byregister_modelfunction.
.preprocess_data
data: Data to be preprocessed.
.predict
model(model_instance) : Model instance.data: Data to be predicted.
.postprocess_data
data: Data to be postprocessed.
.save_model
load_model on model loading.
Args
model(model_instance) : Model instance to save.
load_model on model loading.
Must be a dictionary with key and value both string.
register_model
organization_name as **kwargs.
Args
repository_name(str) : Model repository name.model_number(int | None) : Model number. If None, new model will be created. In such case,model_instancemust be given.runner_cls(RunnerBase) : Runner class that includes code for service.model_instance(ModelType | None) : Model instance. If None,runner_clsmust overrideload_modelmethod. Defaults to None.requirements(List[str]) : Python requirements for the model. Defaults to [].artifacts(Dict[str, str]) : Artifacts to be uploaded. Key is the path to artifact in local filesystem, and value is the path in the model volume. Only trailing asterisk(*) is allowed for glob pattern. Defaults to .
- “model.pt”, “checkpoints/”: “checkpoints/”},
register_torch_model
organization_name as
**kwargs.
Args
repository_name(str) : Model repository name.model_number(int | None) : Model number. If None, new model will be created.model_instance(model_instance) : Torch model instance.preprocess_data(callable) : Function that will preprocess data. Defaults to identity function.postprocess_data(callable) : Function that will postprocess data. Defaults to identity function.requirements(list) : List of requirements. Defaults to [].

