Code Monkey home page Code Monkey logo

deeplearning-as-a-function's Introduction

Deep Learning as a function (DLaaF)

Easy deployment of Deep Learning predictions as functions thanks to OpenFaas awesome projet :-)

List of current functions :

  • darknet

More to come...

Initialize Swarm Mode (from OpenFaas deployment documentation)

You can create a single-host Docker Swarm on your laptop with a single command. You don't need any additional software to Docker 17.05 or greater. You can also run these commands on a Linux VM or cloud host.

This is how you initialize your master node:

# docker swarm init

If you have more than one IP address you may need to pass a string like --advertise-addr eth0 to this command.

Take a note of the join token

  • Join any workers you need

Log into your worker node and type in the output from docker swarm init on the master. If you've lost this info then type in docker swarm join-token worker and then enter that on the worker.

It's also important to pass the --advertise-addr string to any hosts which have a public IP address.

Note: check whether you need to enable firewall rules for the Docker Swarm ports listed here.

Deploy all the things

  • Connect to a swarm manager
  • Clone this repository
git clone https://github.com/yogeek/deeplearning-as-a-function.git
  • chmod u+x install.sh
  • Execute the install script :
./install.sh

Your functions are available !

Test

Classify an image with darknet :

  • Get an image
wget https://upload.wikimedia.org/wikipedia/commons/thumb/1/19/%C3%81guila_calva.jpg/1200px-%C3%81guila_calva.jpg -O eagle.jpg
  • Call the function from any node
curl localhost:8080/function/darknet --data-binary @eagle.jpg

or with faas-cli

cat eagle.jpg | faas-cli invoke darknet

Improvements

To use in production mode, follow the guide to lock-down OpenFaas with a reverse proxy like Traefik for example.

Example of lock-down using Traefik

The following script will :

  • Ask for a password
  • Add Traefik reverse proxy in the stack
  • Deploy the secured stack
chmod u+x install.sh
./install-secure.sh

Test :

curl -X POST http://localhost/function/darknet --data-binary @eagle.jpg
401 : Acces Denied
curl -u user:password -X POST http://localhost/function/darknet --data-binary @eagle.jpg
OK !

deeplearning-as-a-function's People

Stargazers

 avatar  avatar

Watchers

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