Deployment of Deep Learning Model using Flask

Krish Naik · Intermediate ·🔧 Backend Engineering ·7y ago

Key Takeaways

Deploys a deep learning model using Flask for image classification tasks

Full Transcript

hello all today we will be discussing how we can deploy a deep learning model with the help of flask in this particular example I'm basically going to use a transfer learning process which is called as resonant and I'm trying to deploy that I will deploy that using flask and before going head guys let me just show you a demo how it looks like resonant is basically the transfer learning the most of the technique that I basically used as resonate it is a transfer learning kind of technique where I basically loaded the weights of imagine a Tony now if you don't know about Imogen Imogen it is basically competition where you know different kind of neural networks with respect to like which is 16 we have we are like resonant we have like less intense named mobile in it so all these things they have come over here like they're basically want the competition in the image classification so immediate classification is basically about categorizing thousand different categories so let us just see an example suppose I go and choose a particular image for partners and if I do the prediction it will basically show me a giant underscore panda and similarly if I go and see for a bird so this looks like Macau so this Macau is nothing but it is a bird it's quite famous in the equatorial region you can see over here this is this was a demo thick little mesh but the front end of my behalf and I'm actually interacting with an API which is hosted using the flask and you can also choose different different images again let us see and just try to open up a snake image and try to predict this is like side window this is also a kind of snake Omni basically showing the name of the snake you can see that Sidewinder is also that and this is the demo all about and what we are going to do is that I'm just going to show you the code and how you can actually deploy this particular process reinvade guys there it is please to import all this code will be given in the github it is completely free for you or make sure you utilize it and try to practice by your own okay so initially you just import all these libraries which is which is with respect to chaos and all the other nice real IDs then what do you have is that just define the flask app this is simple because in my previous two videos I have also shown you how you can deploy a machine learning model and an NLP model so you should be pretty much clear if you have seen that you not seen that this is well and good when to see to it it just hardly five to ten minutes then what I do is that initially now initially my model is not created again I have to import that model and again when I am importing ResNet I will basically be getting this model from the corrals or application so what you can do is that just type down from Carol wrote application ResNet importer eyes net 50 and here you initialize the resonate 50 with the weights imaged that's it as soon as you get that value in your model your model will be created you just say model dot C and just give the path where you want to save the model yeah I've saved the model currently inside my model folders so here it is model resonate five model VG 16 if I have tried with both with ResNet and VG 16 it worked pretty well with both this algorithm scales so what you can do is that once you do this right you don't have to run it again and again because your model will get three bits so you can just comment down this particular code okay then you have to uncomment this particular code why you aren't commenting this particular code basically means that you are trying to read the h5 file directly from the model folder so here it is you are just reading it from the model folder then you do load more load model and model underscore predict function this was basically loading your model okay the next thing is that how do you define your approach this app route is basically for a root folder which will be like a get which is not it will which will which will do nothing but just show you their homepage which is present in index dot HTML index dot HTML is basically present inside this template folder or so template folder is basically having in this dot HTML so by default the render template will be there is not a stable for your hood but now the next thing is that for the predacons which is my API what I have to do is that what happen is that I just created a function for an upload as soon as the person uploads the picture in the web app what I do is that first of all I store that image inside a path which is called as uploads I store this image over here so you can see all the images get stored and that is the code this is the code which will store that particular image as soon as I stole this particular image you just have to go and hit on model and this will predict inside this I will just give the file path which is my image path and then my model which I have loaded earlier if I go and see what is my model and the scope predict yeah inside model and this could predict what I am doing is that unloading the image from the image path then I'm converting into an array finally I am expanding the dimensions and I am doing the Preferences input this is basically a normal step that we usually do and finally we do model dot credit so as we do the prediction we get the prediction over here and based on that we are just won't select the categories of the prediction and try to convert that back into string by using decoder underscore prediction this is a normal or ResNet and it is available in the Kalos documentation also and finally my main function from which I'm actually running Maya that's it this quite simple just hardly any lines of code in this particular file you just have all your folders set all you have to do is then run your front that's it in order to run it what you have to do is that just open up on the front again so hang up on the front here what you have to do is that just go to this particular part off in this path you know D Drive I'll say C D and here you just have to write fight them I'm dot T one I said soon as you press ENTER I'm not going to press ENTER because I've already my back end it is a warning you can see in my another command prompt it is already running in this particular you just have to press ENTER then you will suddenly get your local address and port number from where it is funny and after that you just have to open this you know just load it once and then you can choose whatever you want you see do the prediction straight - this is a kind of dog breed of dog basically so you can see it over here your images and this is your breed of dog I show one I had also uploaded one thing but let's see that there's a bad fighter yes in this board a lot so what am i J suffer I don't think so this is categorized properly but that is what this particular model says so this was about this particular session guys I hope you liked this particular video make sure you subscribe the channel like comment share with all your friends whoever required this I try to search and the internet a lot of things regarding how to acquire deep learning model I was not able to get a lot but as we go ahead and deployment part I'm also going to show you a CDC CIC deployment with respect to sure where and everything will be automated you're the coordinate gathering your model processing your feature engineering your feature selection everything every steps I find their deployment part make sure you subscribe the channel guys and I hope you are liking this particular video I'll see y'all in the next video have a great day ahead god bless you all thank you one and all

Original Description

Flask is a micro web framework written in Python. It is classified as a microframework because it does not require particular tools or libraries.[3] It has no database abstraction layer, form validation, or any other components where pre-existing third-party libraries provide common functions. However, Flask supports extensions that can add application features as if they were implemented in Flask itself. Extensions exist for object-relational mappers, form validation, upload handling, various open authentication technologies and several common framework related tools. Extensions are updated far more regularly than the core Flask program. #FlaskDeepLearningModelDeployment github url: https://github.com/krishnaik06/Deployment-Deep-Learning-Model You can buy my book where I have provided a detailed explanation of how we can use Machine Learning, Deep Learning in Finance using python url: https://www.amazon.in/Hands-Python-Finance-implementing-strategies/dp/1789346371/ref=sr_1_1?keywords=krish+naik&qid=1560675332&s=gateway&sr=8-1
Watch on YouTube ↗ (saves to browser)
Sign in to unlock AI tutor explanation · ⚡30

Playlist

Uploads from Krish Naik · Krish Naik · 50 of 60

1 Natural Language Processing|Stemming
Natural Language Processing|Stemming
Krish Naik
2 Natural Language Processing|BagofWords
Natural Language Processing|BagofWords
Krish Naik
3 Gaussian distribution or Normal Distribution in statisctics
Gaussian distribution or Normal Distribution in statisctics
Krish Naik
4 Natural Language Processing|TF-IDF for Machine Learning| Text Prerocessing
Natural Language Processing|TF-IDF for Machine Learning| Text Prerocessing
Krish Naik
5 Log Normal Distribution in Statistics
Log Normal Distribution in Statistics
Krish Naik
6 Covariance in Statistics
Covariance in Statistics
Krish Naik
7 Confusion matrix, Precision, Recall| Data Science Interview questions
Confusion matrix, Precision, Recall| Data Science Interview questions
Krish Naik
8 Tutorial 44-Balanced vs Imbalanced Dataset and how to handle Imbalanced Dataset
Tutorial 44-Balanced vs Imbalanced Dataset and how to handle Imbalanced Dataset
Krish Naik
9 Implementing a Spam classifier in python| Natural Language Processing
Implementing a Spam classifier in python| Natural Language Processing
Krish Naik
10 Tutorial 11-Exploratory Data Analysis(EDA) of Titanic dataset
Tutorial 11-Exploratory Data Analysis(EDA) of Titanic dataset
Krish Naik
11 Face Recognition using open CV and VGG 16 Transfer Learning
Face Recognition using open CV and VGG 16 Transfer Learning
Krish Naik
12 Pedestrian Detection using OpenCV from Videos
Pedestrian Detection using OpenCV from Videos
Krish Naik
13 Face and Eye Detection from Videos using HAAR Cascade Classifier
Face and Eye Detection from Videos using HAAR Cascade Classifier
Krish Naik
14 Reading, Writing and Displaying images with Opencv| OpenCV Tutorial
Reading, Writing and Displaying images with Opencv| OpenCV Tutorial
Krish Naik
15 OpenCV Installation | OpenCV tutorial
OpenCV Installation | OpenCV tutorial
Krish Naik
16 Face and Eye Detection from Images using HAAR Cascade Classifier
Face and Eye Detection from Images using HAAR Cascade Classifier
Krish Naik
17 Car Detection using HAAR Cascade and Opencv from Videos.
Car Detection using HAAR Cascade and Opencv from Videos.
Krish Naik
18 Using OpenFace for Face recognition in Keras
Using OpenFace for Face recognition in Keras
Krish Naik
19 OpenPose Tutorial with Tensorflow
OpenPose Tutorial with Tensorflow
Krish Naik
20 Multiple Linear Regression using python and sklearn
Multiple Linear Regression using python and sklearn
Krish Naik
21 Dimensional Reduction| Principal Component Analysis
Dimensional Reduction| Principal Component Analysis
Krish Naik
22 Movie Recommender System using Python
Movie Recommender System using Python
Krish Naik
23 TPR,FPR,FNR,TNR, Confusion Matrix
TPR,FPR,FNR,TNR, Confusion Matrix
Krish Naik
24 Precision, Recall and F1-Score
Precision, Recall and F1-Score
Krish Naik
25 Artificial Neural Network for Customer's Exit Prediction from Bank
Artificial Neural Network for Customer's Exit Prediction from Bank
Krish Naik
26 GridSearchCV- Select the best hyperparameter for any Classification Model
GridSearchCV- Select the best hyperparameter for any Classification Model
Krish Naik
27 RandomizedSearchCV- Select the best hyperparameter for any Classification Model
RandomizedSearchCV- Select the best hyperparameter for any Classification Model
Krish Naik
28 K Nearest Neighbor classification with Intuition and practical solution
K Nearest Neighbor classification with Intuition and practical solution
Krish Naik
29 K Means Clustering Intuition
K Means Clustering Intuition
Krish Naik
30 Create custom Alexa Skill- Lambda function- Part2
Create custom Alexa Skill- Lambda function- Part2
Krish Naik
31 Hierarchical Clustering intuition
Hierarchical Clustering intuition
Krish Naik
32 Implement Transfer Learning with a generic Code Template
Implement Transfer Learning with a generic Code Template
Krish Naik
33 Gender Classifier and Age Estimator using Resnet Convolution Neural Network
Gender Classifier and Age Estimator using Resnet Convolution Neural Network
Krish Naik
34 Unlock Your Application With Your Face using OpenCV
Unlock Your Application With Your Face using OpenCV
Krish Naik
35 Draw rectangle from webcam and sketch process it on a live feed
Draw rectangle from webcam and sketch process it on a live feed
Krish Naik
36 Complete Life Cycle of a Data Science Project
Complete Life Cycle of a Data Science Project
Krish Naik
37 How we can apply Machine Learning in Finance
How we can apply Machine Learning in Finance
Krish Naik
38 Deep Learning in Medical Science
Deep Learning in Medical Science
Krish Naik
39 How to switch your career to Data Science.
How to switch your career to Data Science.
Krish Naik
40 Linear Regression Mathematical Intuition
Linear Regression Mathematical Intuition
Krish Naik
41 Handle Categorical features using Python
Handle Categorical features using Python
Krish Naik
42 Machine Learning Algorithm- Which one to choose for your Problem?
Machine Learning Algorithm- Which one to choose for your Problem?
Krish Naik
43 DBSCAN Clustering Easily Explained with Implementation
DBSCAN Clustering Easily Explained with Implementation
Krish Naik
44 Curse of Dimensionality Easily explained| Machine Learning
Curse of Dimensionality Easily explained| Machine Learning
Krish Naik
45 Feature Selection Techniques Easily Explained | Machine Learning
Feature Selection Techniques Easily Explained | Machine Learning
Krish Naik
46 Tutorial 29-R square and Adjusted R square Clearly Explained| Machine Learning
Tutorial 29-R square and Adjusted R square Clearly Explained| Machine Learning
Krish Naik
47 Cross Validation using sklearn and python | Machine Learning
Cross Validation using sklearn and python | Machine Learning
Krish Naik
48 Handling Missing Data Easily Explained| Machine Learning
Handling Missing Data Easily Explained| Machine Learning
Krish Naik
49 Deploy Machine Learning Model using Flask
Deploy Machine Learning Model using Flask
Krish Naik
Deployment of Deep Learning Model using Flask
Deployment of Deep Learning Model using Flask
Krish Naik
51 How to Visualize Multiple Linear Regression in python
How to Visualize Multiple Linear Regression in python
Krish Naik
52 K Nearest Neighbour Easily Explained with Implementation
K Nearest Neighbour Easily Explained with Implementation
Krish Naik
53 Predicting Heart Disease using Machine Learning
Predicting Heart Disease using Machine Learning
Krish Naik
54 Predicting Lungs Disease using Deep Learning
Predicting Lungs Disease using Deep Learning
Krish Naik
55 Stock Sentiment Analysis using News Headlines
Stock Sentiment Analysis using News Headlines
Krish Naik
56 Random Forest(Bootstrap Aggregation) Easily Explained
Random Forest(Bootstrap Aggregation) Easily Explained
Krish Naik
57 Voting Classifier(Hard Voting and Soft Voting Classifier)
Voting Classifier(Hard Voting and Soft Voting Classifier)
Krish Naik
58 Credit Card Fraud Detection using Machine Learning from Kaggle
Credit Card Fraud Detection using Machine Learning from Kaggle
Krish Naik
59 Hyperparameter Optimization for Xgboost
Hyperparameter Optimization for Xgboost
Krish Naik
60 Tutorial 45-Handling imbalanced Dataset  using python- Part 1
Tutorial 45-Handling imbalanced Dataset using python- Part 1
Krish Naik

Related AI Lessons

Up next
This Cop Was Held Accountable For His Brutality! #police #lawyer
Hampton Law
Watch →