
Template details
Serving Machine Learning Models
Template source code and instructions for serving ML models with FastAPI, Flask, BentoML, Streamlit, MLflow, and as an Android app.
About this template
Serving Machine Learning Models is a boilerplate GitHub repository by Nneji123 that bundles template source code, instructions, and examples for deploying trained machine learning models as REST APIs, web apps, and an Android application using Python.
What is Serving Machine Learning Models?
Serving Machine Learning Models is a multi-framework template repository that takes a trained car price prediction model (saved as a .pkl file with joblib) and produces runnable serving applications in FastAPI, Flask, BentoML, MLflow, Streamlit, and KivyMD. It runs on Python 3.8.10, which a provided setup.sh script installs via pyenv, and each framework folder contains its own requirements.txt. The repository is maintained by Nneji123 and is licensed under MIT.
Key Features
- Multi-framework serving — separate folders for FastAPI, Flask, BentoML, MLflow, Streamlit, and KivyMD all serve the same car price model from the Data/cars.csv dataset.
- Docker deployment — the fastapi folder includes a Dockerfile, and the README walks through containerizing the FastAPI API.
- Cloud deployment guides — step-by-step commands show how to deploy the FastAPI and Flask apps to Heroku and to an AWS EC2 Ubuntu instance, including a fastapi-setup.sh script.
- CI/CD with GitHub Actions — workflows automatically deploy the Flask and FastAPI apps to Heroku whenever code is pushed or pulled.
- Model version control with DVC — the project demonstrates using Data Version Control to manage models and data alongside Git.
- Testing with pytest — a tests/test_api.py file shows how to write tests for the served APIs.
- Android packaging — the androidapp folder contains main.py and buildozer.spec for building a KivyMD-based APK with buildozer.
- Platform configs — includes Procfile, runtime.txt, heroku.yml, and vercel.json for deployment.
Who is it for?
Data scientists who want to turn a trained model into a production REST API. ML engineers who need working Docker and cloud deployment setups for model serving. DevOps engineers looking to automate model redeployment with GitHub Actions. Students and tutorial-followers who want to compare FastAPI, Flask, BentoML, MLflow, and Streamlit on the same model.
What can you do with it?
- REST API developers: serve the car price model with FastAPI and get automatic interactive OpenAPI documentation at the /docs endpoint.
- Web app builders: run the Flask app or Streamlit app to get a browser-based form for entering car features and receiving price predictions.
- Mobile developers: package the KivyMD app as an Android APK with buildozer; prebuilt APKs are noted as available in the data branch bin folder.
- Cloud deployers: push the FastAPI app to Heroku using the container stack, or run fastapi-setup.sh on an AWS EC2 instance to serve it on port 80.
How does the repository work?
The workflow is: clone the repository, run ./setup.sh to install pyenv and Python 3.8.10, then cd into the framework folder of your choice (for example fastapi), pip install -r requirements.txt, and launch the app — uvicorn app:app --reload for FastAPI, python app.py for Flask, streamlit run streamlit_app.py for Streamlit. Each app uses the same saved model files in its models/ directory.
FAQ
Which frameworks are included?
The repository includes FastAPI, Flask, BentoML, MLflow, Streamlit, and KivyMD folders, each with a runnable car price prediction app and its own requirements.txt file.
What dataset is used in the examples?
The example model predicts car prices using cars.csv, a dataset from Kaggle. A Data Dictionary file explaining the columns is included in both the Data/ and bentoml/ folders.
Does the repository support Android deployment?
Yes, the androidapp folder uses KivyMD and buildozer. The README mentions that prebuilt APK files are available in the bin folder of the data branch of the repository.
What is the license?
The repository is licensed under the MIT license, as stated in the LICENSE.md file.
How do I deploy to Heroku?
The README provides commands to install the Heroku CLI, log in, create an app, set the stack to container, and git push. GitHub Actions also handles continuous deployment to Heroku for the Flask and FastAPI apps.
















