GithubHelp home page GithubHelp logo

ugnelis / tensorflow-hello-serving Goto Github PK

View Code? Open in Web Editor NEW
2.0 1.0 0.0 21 KB

Simple TensorFlow Estimator 1.x example with Serving API.

Python 94.20% Shell 5.80%
tensorflow estimator serving tensorflow-examples tensorflow-estimators tensorflow-serving

tensorflow-hello-serving's Introduction

TensorFlow Hello Serving

Simple example of TensorFlow 1.x serving.

Training

Model training:

$ ./train.sh

Prediction

Prediction using the trained model:

$ ./predict.sh

Development (with Docker)

Build Docker Image

In order to run this project as a Docker container, a Docker image has to be built:

$ docker build --file Dockerfile.development -t hello-development:1.0 .

Run Docker Container

Run a Docker container together with NVidia GPUs:

$ docker run -it \
    -v ${PWD}/exported_models:/workspace/exported_models \
    --gpus all \
    --name hello-development \
    hello-development:1.0 bash

In case you need to take your trained models out of the container:

$ docker cp docker-development:/workspace/models/ models/

Read more about it in Docker Hub.

Production (with Docker)

Build Docker Image

Docker Image build which contains of TensorFlow serving:

$ docker build --file Dockerfile.production -t hello-production:1.0 .

Run Docker Container

Run a Docker container:

$ docker run -it --rm \
    -v ${PWD}/exported_models:/models \
    -p 8501:8501 \
    -e MODEL_NAME=hello \
    -e MODEL_PATH=/models/hello \
    --name hello-production \
    hello-production:1.0

Send Request

When production Docker container is running, the prediction requests can be done:

[POST] "http://localhost:8501/v1/models/hello:predict"

JSON body example:

{
  "signature_name": "predict",
  "instances": [
    {
      "f1": 6.4,
      "f2": 2.9,
      "f3": 4.3,
      "f4": 1.3
    }
  ]
}

tensorflow-hello-serving's People

Contributors

dependabot[bot] avatar ugnelis avatar

Stargazers

 avatar  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.