Skip to content

This repository shows an example using FastAPI and Docker to run a simple machine learning model (Random Forest Classifier) ​​trained with the scikit-learn library.

Notifications You must be signed in to change notification settings

hfmartinez/docker-fastAPI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ML Model + Docker + FastAPI

General description

This repository shows an example using FastAPI and Docker to run a simple machine learning model (Random Forest Classifier) ​​trained with the scikit-learn library.

Quick start

There are two important scripts in this repository:

  • generate-model.py: This file downloads the dataset (mnist_784), trains the model (Random Forest Classifier) ​​and generates a new file with the already trained model.
  • app.py: This file creates an endpoint to process HTTP requests to get a prediction using the pre-trained model

Install dependencies

Note: It is mandatory to have Python and Pip installed in your environment

To install the dependencies run the following command:

pip install -r requirements.txt

Train the model

To train the model run the following command:

python generate-model.py

Run the FastAPI application

To run the FastAPI application run the following command:

uvicorn app:app --reload

Build and run the docker container

To build the docker container run the following command:

docker build -t hfmartinez/ml-fastapi .

To run the docker container use the following command:

docker run --name test -p 5500:5500 hfmartinez/ml-fastapi

References

About

This repository shows an example using FastAPI and Docker to run a simple machine learning model (Random Forest Classifier) ​​trained with the scikit-learn library.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages