Coder Social home page Coder Social logo

chenqf25 / ml-in-production Goto Github PK

View Code? Open in Web Editor NEW

This project forked from aissam-out/ml-in-production

0.0 0.0 0.0 224 KB

Pipeline for ML/DL solutions: Build the model, create an API to interact with it, containerize it and deploy it

Dockerfile 8.69% Python 85.28% HTML 6.03%

ml-in-production's Introduction

ML-in-production

In this tutorial we will try to walk together through all the building blocks of a Machine/Deep Learning project in production, i.e. a model that people can actually interact with

As a case study, we’ll be creating a web interface for image recognition using the pretrained model VGG19.

You can check the detailed explanation on the article I wrote in Towards Data Science here

Without going into too much detail, this project consists of 4 major parts :

Build model : VGG19

I've used use a pretrained (and effective) Convolutional Neural Network model for image classification : VGG-19.

model.py describe how to load the model, preprocess images in order to be used by that model, and make predictions.

Create API : Flask

flask logo

We are also using Flask-Uploads (or Flask-Reuploaded) which allows your application to flexibly and efficiently handle file uploading and serving the uploaded files.

upload.py contains the code responsible for running the API. It interacts with the web page where the client will upload his image.

Containerize : Docker

docker logo

In short, Docker allows us to create reproducible environments. To do so for the API we've just created, we have to :

1. The first thing to do, obviously, is to download and install Docker

2. Create the requirements.txt in your main directory

3. Create a Dockerfile (without extension) which contains the instructions for building your Docker image

4. In a terminal, run the following command to build the Docker image:

# docker build -f Dockerfile -t recog_container:api .

5. Run container in background and print container ID using:

# docker run -p 5000:5000 -d recog_container:api

Once this is running, you should be able to view your app running in your browser at

http://localhost:5000/upload

Deploy : Heroku

heroku logo

Thanks to Heroku we will be able to deploy our application in the Cloud

1. Create a new Heroku account if you don’t have one. Then download Heroku Command Line Interface (CLI) which makes it easy to create and manage your Heroku apps directly from the terminal.

2. Login to your Heroku account using # heroku login

3. Log in to Container Registry: # heroku container:login

4. Create a new Heroku app: # heroku create <app-name>

5. Build the image based on your Dockefile and push it to this particular app in Heroku # heroku container:push web --app <app-name>

6. You can finally open up your Heroku application through the command # heroku open --app <app-name>

Contact

Link to the related article in Towards Data Science HERE

Link to Twitter account HERE

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.