This repository shows how to serve a model with ONNX Runtime and FastAPI. A simple linear regression was trained with scikit-learn framework on the boston housing dataset.
- English article: Deploying a scikit-learn model with ONNX and FastAPI
- German article: Inbetriebnahme eines scikit-learn-Modells mit ONNX und FastAPI
The purpose of the application is to run the model with the ONNX Runtime and to use FastAPI to make the model available via a post request. We are using a token in headers request to secure the application.
- models/boston_housting.onnx: In the models folder we are storing the trained model.
- notebooks/Modeltraining.ipynb: Here you can find the procedure that we are using to train the model.
- application: Contains all of the code that we need to serve the model.
If you want to take a look on how the model was trained take a look into the Modeltraining.ipynb. After the training the model is exported to ONNX with the skl2onnx package.
Just run docker-compose up
to start the project.
- application is available at http://localhost
- docs are available at http://localhost/docs
- take a look on the test.sh script to see an example for a prediction