DEV Community

loading...
Cover image for How to make a Flask Web App for Keras Model?

How to make a Flask Web App for Keras Model?

Avi Arora
Machine Learning | Computer Vision | Python | React.js | Data Science Writer
・2 min read

Read the full article here: https://analyticsarora.com/how-to-make-a-flask-web-app-for-keras-model/

Introduction

So, you have built some kind of machine learning model in Keras. Now, you want to add a frontend interface so people can actually interact with your model in an approachable way. Look no further. In this tutorial, I will cover how to package your Keras model into a powerful web application using Flask.

This is the second article in a series talking about how I made and deployed a neural network to rate songs like the popular music reviewer Anthony Fantano. You can read about the process of researching and developing the neural network in the first article. The final article covers the issues I encountered deploying a Flask Web Application to Heroku.

Click here to see all my code.

Article Overview

  • Cloning the Starter Code
  • Mocking Up the Design
  • Writing the HTML and CSS
  • Creating the Model Operation Functions
    • Saving the Best Model
    • Initializing the Tensorflow Session
    • Data Preprocessing Function
    • Prediction Function
  • Taking in User Input
    • Accepting File Drag Events
    • Sending Files through a Post Request
    • Saving Files to Temporary Directory
  • Updating the Frontend with Javascript
    • Showing and Hiding Elements
    • Submit Function
    • Clear Function
  • Demo and Conclusion

Discussion (0)