isaacmg / model_agnostic_prediction

Peelout model agnostic is a class for easily performing production pipeline predictions.
8 stars 2 forks source link
deep-learning deployment machine-learning prediction

Agnostic model loader

Build Status

Model Agnostic (MA) provides an easy model instantiation for Flask, Django, and other production Python projects. It also supports exporting models to other common serving platforms. Finally MA, allows you to easily load models and perform predictions without having to worry about the model backends. Moreover, it helps you organize your code for easy updating and maintainance.

Usage

To install run pip install model_agnostic

You can also build from the source by (though we strongly reccomend using pip)

git clone https://github.com/isaacmg/model_agnostic_prediction.git

cd model_agnostic_prediction

python setup.py build install

To use create a new class that extends your model's backend subclass. Models are located in the model folder in the "frameworkName_serve" format.

from model_agnostic.models.pytorch_serve import PytorchModel
class NewPyTorch(PytorchModel):
    def __init__(self, weight_path=None):
        super(NewPyTorch, self).__init__(weight_path)
        # Handle any model specific loading here 
    def preprocessing(self, raw_data):
        # Apply necessary pre-processing here for your data here.
        pass
    def process_result(self):
        # Implement this function if have any post-processing needs of predictions.
        pass

You will have to implement preprocessing and possibly create_model and process_result depending on your model (see examples for more info).

Project Goals

Examples