How to Deploy AI Models? — Part 1

--

Wish you all Happy New Year Guys!!! May this New Year add more feathers to our hat.

Model deployment is one of the very crucial task of the whole process. Deployment of trained model is very important because it makes the process easier for the end user and add value to the organization. In this series of model deployment, we are going to learn the following steps in upcoming articles:

  1. Repository Directory — Arrangement of the files in the repository.
  2. Git installation and RSA setup.
  3. Introduction of Github as well as creating and maintaining repositories in Github (Push, Pull, clone, branch and other important commands) as well as Source tree.
  4. Deployment of the model to Heroku app.
  5. Deployment of the model to Streamlit app.

Without any delay, let start our journey to Deploy ML/DL model.

  1. Repository Directory — Arrangement of the files and folders in the repository.

This is the basic section if you don't want you can skip this section.While creating or initiating any project, it is very importing to arrange the files and folder of the project in a detailed way so any person who visit the repository can understand the content of the folder as well as file contents and he or she can carry it forward. In this Section of this article we are going to discuss this is detailed way.

Big Data Jobs

There is some kind of unstated rules which is followed in each and every step of the repository they are:

  1. Requirement.txt: As we all know for developing any project we need to import packages, library and project is based on some programing language i.e. Python, Javascript, NodeJS, etc. These programming languages and library have version associated with them and if these versions associated with these libraries and the programming language. If we do not install the same version of the programming language along with the programming language which we have used in thee development server in the production server then it will create a huge chaos and our whole hard work can go in the trash can. The best way is to automatically extract the installed library in the .txt format or you can update it manually. For reference how to extract the installed python packages and their respective version can be found in the article and code. It is always recommended to freeze the installed libraries/package before extracting it into the text file.
  2. Log.txt: This file is same as the log of any application, we use it contains the each and every activity which is performed on the repository. It can be updated automatically or manually. It keeps the track of the activity performed by the different teams on the repository.
  3. The structure of the Repository: It is very important to have segregated folder structure with multiple branch dedicated to development, testing, integration and bug. The below diagram defines the folder structure of the repository.
Figure 1. Repository Structure

Trending AI Articles:

1. 130 Machine Learning Projects Solved and Explained

2. The New Intelligent Sales Stack

3. Time Series and How to Detect Anomalies in Them — Part I

4. Beginners Guide -CNN Image Classifier | Part 1

2. Git Introduction and set-up

Git is a version control system which automatically tracks and keeps records of the changes which have been performed on the repository (local or remote) over the time. Below image summarizes the workflow of the git with local repository and remote repository.

Figure. 2 Git workflow

Installation: For installation of git you can visit the link.

  1. Configuration of Git: Before we take any step further we have to configure the username and as well as the email globally. For authentication we can set up ssh authentication the help of the RSA algorithm in which we have to upload the public key in the Github SSH and GSA section, so we do not need to write our email and password when we pull or push into the repository.

Setting- up email:

Command: git config — global user.email “enter your email”

Setting- up username:

Command: git config — global user.name “enter your user name”

Note: Create a github account prior to this section, use email and username associated with the github account.

Figure 3. Example of Username and Email Configuration

Setting- up RSA SSH authentication:

Command: ssh-keygen -t ed25519 -C “enter your email”

This above command will generate the RSA public and private key and you have to upload the public key in the SSH section of the Github inside settings page.

Checking SSH key:

Command: eval “$(ssh-agent -s)”

This above command will give the Agent pid which means it is functioning in local machine perfectly. Now we have to add SSH private key to the SSH agent using below command.

Command: ssh-add ~/ .ssh/id_ed25519

Note: If you have generated a key with different id please replace the “id_ed25519” with the id you have generated the private key.

Copying Key and Pasting it into Github SSH public key section:

Installing xclip to copy the content of the public key file

Command: sudo apt-get install xclip

Copy the content of the file to clipboard

Command: xclip -selection clipboard < ~/.ssh/id_ed25519.pub

Note: If you have generated a key with the different id please replace the “id_ed25519” with the id you have generated the public key.

The below image will describe the whole process :

Figure 4. SSH key generation procedure
Figure 5. Linking SSH with Github

Special Thanks:

As we say “Car is useless if it doesn’t have a good engine” similarly student is useless without proper guidance and motivation. I will like to thank my Guru as well as my Idol “Dr. P. Supraja”- guided me throughout the journey, from the bottom of my heart. As a Guru, she has lighted the best available path for me, motivated me whenever I encountered failure or roadblock- without her support and motivation this was an impossible task for me.

Reference:

Extract installed packages and version : Article Link.

Installation of Git: Link,

Git Documentation: Link

Github Documentation: Link

Notebook Link Extract installed packages and version : Notebook Link

YouTube : Link

If you have any query feel free to contact me on any of the below-mentioned options:

Website: www.rstiwari.com

Medium: https://tiwari11-rst.medium.com

Google Form: https://forms.gle/mhDYQKQJKtAKP78V7

Don’t forget to give us your 👏 !

--

--