Skip to content

Machine Learning App As REST API with Docker & Google Cloud Run

License

Notifications You must be signed in to change notification settings

mdh266/DockerMLRestAPI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 

Repository files navigation

Dockerized Machine Learning Rest API


Example of turning an XGBoost model (built here) using Flask, Docker and Google Cloud Run.

Local Use


Build the image

docker build -t mlapp app

Run the API locally:

docker run -ip 8080:8080 mlapp

From Python:

data = {'columns': ['Energy_Star', 'Site_EUI', 'NGI', 'EI', 'Residential'],
      'data': [[7744, 52.7, 45.9641802469, 10.1204555556, 1],
               [9, 112.2, 25.9187489356, 29.7707095517, 1]]}


import requests

result = requests.post(url="http://0.0.0.0:8080/predict",
                     json=data)

result.json() # [0.0031427741050720215, 0.007205158472061157]

Deploying to Google Cloud Run:


Build image on Google Cloud:

cd app

gcloud builds submit --tag gcr.io/<project-id>/mlapp

Deploy to Google Cloud Run:

gcloud run deploy --image gcr.io/<project-id>/mlapp --platform managed

About

Machine Learning App As REST API with Docker & Google Cloud Run

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published