📚
Learn Python
  • Overview
  • Day 1
  • strings
  • Functions
  • Day 4
  • Day 5
  • Web Development: Flask
    • Installation
      • Virtual Environment
    • Configuration
      • Environment variable in Windows
    • SDLC
  • Python OOPs
    • Python Dunder
    • Page 1
  • Machine Learning
    • Deployment
  • Contributors
Powered by GitBook
On this page

Was this helpful?

  1. Machine Learning

Deployment

PreviousMachine LearningNextContributors

Last updated 3 years ago

Was this helpful?

We will learn how to deploy a machine learning model, for this we will explore

  1. Deploy and host from local system using

  2. Deploy on PaaS using and

  3. Deploy on Serverless using and

  4. Deploy on Virtual Machines using

  5. Deploy on contained using

Deploy and host from local system

The simplest way to undestand deployment is like functions in any programming language. We create / develop a function with / without parameters and it executes when called for example . This is done to avoid repeating same line of code else where in program. Similarly, we will put our main Machine Learning code inside such a function, thereby giving capability of sending input data for prediction, classification or clustering task.

Psudo Code

// Some code: File: ML.py ( path C:\Users\Laptop\desktop\ml\mlfile\ml.py )

def predict():
    > preprocessing
    > x = predict
    return x
    

 // File: main.py ( path C:\Users\Laptop\desktop\ml\main.py )
from mlfile.ml import predict
from flask import Flask

app = Flask(__name__)

@app.route('/')
def index():
    predict() # this is where we try to execute the code
    return 'Web App with Python Flask!'

Example

Here we will just try to create a basic image segmentation machine learning model but here we will already provide the correct path to our image to the ML code. If needed we can always create Flask app that provide ability to upload image file that needs to be segmented.

  1. Create a folder on Desktop name mldeploy

  2. Create Python Virtual Environment here named project

  3. Inside virtual environment download necessary modules to run ML model, Flask app etc.

Create a app.py file inside project folder where our basic Flask app will reside ( )

Create another folder inside project named ML with 3 sub directories Data, Model, Output like for inputting data, creating model.py file and saving output respectively.

ngrok
Heroku
Azure Apps
AWS Lambda
Azure Functions
Azure VM
Docker
here
Code here
this