Image Classification Model & Deployment with Flask and Azure WebApp

An end to end pipeline on creating a Deep Learning model to creating a Web Application

Photo by TAALAI DJUMABAEV on Unsplash
  1. Creating a wireframe Flask Model
  2. Run on Local and deploy on Azure
  3. Test on web
  4. Additional notes
Process flow for creating the Web Service

Classification model example

Let’s take a binary classification model created on a set of images (dataset here).

Creating the Flask App

Now we will have to create a simple flask model. The flask model contains an app.py file that calls the model and a wireframe http model for uploading an image file and throwing the result on the web.

Running the model on local server

From the command line we run :

python app.py
Image on Local server (port 5000) — The app predicts correctly that there is a crack

Deployment in Azure Web app

For developing a web app in Azure, there are a couple of prerequisites.

  1. GitHub account on the web or local. It is also possible to host static websites and uploading files on Azure via FTP but I prefer the ease of Git. Create a procfile of the form << web: gunicorn app:app >> and save the file in the same folder as above. Gunicorn is a WSGI http server that is compatible with a number of web servers and is a good deployment tool.
Creating app from the Azure Portal — make sure you change the size to the lowest option to save money!!
Inside the created App resource, we need to link it to our Files to run the Application
Creating a webapp from Local Git
Save the url and Username and Password
git init
git add .
git remote add azure <copied url>
git push azure master
Azure Webapp deployment — The app is accurately predicting that the image has no cracks.

Additional Notes and Closing Thoughts

There are multiple ways one can create webapps on Azure — Local Git, GitHub, BitBucket, Kudu, FTP, VS Code extensions etc. Here I have provided a couple of methods of doing the same without going deep into the aesthetics of the website, which is left to the individual’s interest. Do check out the GitHub repo for the codes. This was just a dive into web service on Azure and its ease of usage. Hope it was helpful. In the next article I will develop a docker image on Azure and run the app from the container.

References

  1. Özgenel, Çağlar Fırat (2019), “Concrete Crack Segmentation Dataset”, Mendeley Data, v1http://dx.doi.org/10.17632/jwsn7tfbrp.1
  2. https://docs.microsoft.com/en-us/azure/devops/pipelines/targets/deploy-to-azure-vscode?view=azure-devops
  3. https://code.visualstudio.com/docs/azure/deployment

Senior Researcher and Data Scientist at Saint-Gobain Research https://www.linkedin.com/mwlite/in/lalitha-raghavan-b9939558

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store