Skip to content

mdh266/DockerMLRestAPI

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
app
 
 
 
 
 
 

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