Coder Social home page Coder Social logo

cruise's Introduction

Cruise ๐Ÿš€

Automatic deployment of tensorflow models as rest apis to heroku using tensorflow serving.

Try it out.

Deploy

How to use:

  1. Save your Tensorflow model using Tensorflow SaveModel API

  2. Create a model cofiguration file in the model base path

  3. zip the model in tar.gz format and upload to a public aws bucket

  4. Click the deploy button on this repo to deploy the model

Visit the documentation for a detailed guide.

How to test it

on clicking the deploy button:

you can use this aws bucket url for deployment:

https://cruise-bucket.s3.amazonaws.com/tf-models.tar.gz

set the MODEL_FOLDER_NAME to img_classifier

then deploy on your heroku account.

on successful deployment, navigate to:

https://YOUR-APP-NAME.herokuapp.com/v1/models/YOUR-MODEL-NAME

you should see something simiilar to:

{
 "model_version_status": [
  {
   "version": "1",
   "state": "AVAILABLE",
   "status": {
    "error_code": "OK",
    "error_message": ""
   }
  }
 ]
}

if you used the url above, here's a simple python script you can run on your PC to test the model:

import requests
import json
import numpy as np
from tensorflow.keras.datasets.mnist import load_data


#load MNIST dataset
(_, _), (x_test, y_test) = load_data()

# reshape data to have a single channel
x_test = x_test.reshape((x_test.shape[0], x_test.shape[1], x_test.shape[2], 1))

# normalize pixel values
x_test = x_test.astype('float32') / 255.0


test_img = x_test[0]

YOUR_APP_NAME = "the-name-of-your-heroku-app"
url = f'https://{YOUR_APP_NAME}.herokuapp.com/v1/models/img_classifier:predict'


def make_prediction(instances, many=False):
    if not many:
        data = json.dumps({"signature_name": "serving_default", "instances": [instances.tolist()]})
    else:
        data = json.dumps({"signature_name": "serving_default", "instances": instances.tolist()})
    headers = {"content-type": "application/json"}
    json_response = requests.post(url, data=data, headers=headers)
    predictions = json.loads(json_response.text)['predictions']
    return predictions


for p in make_prediction(test_img):
    print(np.argmax(p))

Features:

The end goal is to allow you effortlessly deploy your Tensorflow models to heroku and test it easily.

  • allow users deploy multiple versions of their models to heroku with the click of a button

  • allow users to easily extend their server to serve multiple Tensorflow models

References:

cruise's People

Contributors

cornzyblack avatar jesufemi-o avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.