Develop
Prepare a model for deployment.

Model preparation

Once the model is trained and placed in the git repo you need to add two files to your main directory such as syndicai.py and requirements.txt. Those files are necessary to recreate the working environment and establish a proper run configuration to your model.
1
./my-model/
2
├── syndicai.py
3
├── ...
4
└── requirements.txt
Copied!

syndicai.py

It is the main file that is responsible for running a model. Input and output data are always sent in the form of JSON format in the payload variable.
1
class PythonPredictor:
2
def __init__(self, config):
3
"""This method is required. It is called once before the API
4
becomes available. It performes the setup such as downloading /
5
initializing the model.
6
7
:param config (required): Dictionary passed from API configuration.
8
"""
9
10
def predict(self, payload):
11
"""This method is required. It is called once per request.
12
Preprocesses the request payload, runs inference, and
13
postprocesses the inference output.
14
15
:param payload (optional): The request payload
16
:returns : Prediction or a batch of predictions.
17
"""
18
pass
Copied!
The good practice is to load/download all additional files not placed in repo (e.g. model weights) in the __init__ method.
The input to your model can be sent in different formats such as JSONformat, andstarlette.datastructures.FormData. Go to API input types to explore each one in detail.
The output of your model (predictor method) can be returned also in three different formats such as JSON-parseable, string, and bytes objects. Explore in detail in the API response section.

requirements.txt

File needed to recreate the environment for the model. It is important to give information about the exact version of the library.
You can
1
tensorflow-hub==0.9.0
2
tensorflow==2.3.0
3
torch==1.6.0
4
torchvision==0.7.0
5
xgboost==1.2.0
Copied!

Sample models

If you are still not comfortable with the above approaches, please go to our Sample Model Repository to explore more models.

More options

With the Syndicai Platform, you can also deploy models using Cortex and Seldon engines.
Last modified 9mo ago