Primitive deployment using web frameworks

How to integrate a machine learning model into an existing production environment in order to make real data-driven strategic decisions

​

General scenario to deploy a ML model into production

​

In general cases, we mostly follow the above diagram for deployment. There are 4 layers to consider:

  • Storage refers to the database which is updated by images regularly and its database schema. It’s loaded in memory/NoSQL to calculate real-time aggregates.

  • The model stage includes the selection of analytical techniques, testing different models, and reviewing the result. Training a model is required so that it can understand the various patterns, rules, and features followed by testing the model which determines the percentage accuracy of the model as per the requirement of the project or problem. Creating a machine learning model cannot be viewed as a goal in and of itself. The model should bring value to the firm, generate new profits, or reduce costs and other parts of the application need to interact with to start with the basics.

  • Business logic is the portion of an enterprise system that determines how data is transformed or calculated, and how it is routed to people or software (workflow).

Visitors to an e-commerce website for sunglasses, for example, could be able to try out different frames on their own uploaded photographs using a relatively elementary vision AI model.

The website's business logic used for the model may comprise a process such that the Web camera asking for permission to operate or uploading files from the user's computer, the user specifying with glasses they want to test, sending that to the model, which in turns return an image combining the uploaded image with glasses added at the appropriate location.

  • Lastly, we need to design the API to interact with the model. It is important to define how often we want to run inferences on our model. Are online (i.e., real-time) predictions important to us or can we batch-process millions of images overnight? This will impact the API design immensely.

To build such an architecture, web frameworks are used which makes it fairly easy. The frameworks can be installed as a python package and then you can run an interface to interact with the models on any machine.

​

Primitive deployment architecture