Docker Prototype

One of the most important features of our web-app is to allow users to upload trained python models, for them to be dockerised, and allow users to download these docker images, run them, and test said model.

What is a trained model?

A trained model is a machine learning model which has been trained on some dataset, and can now therefore make predictions on similar data. When a model is trained it contains data which it uses to make predictions, it is an instantiated class with some instance variables.

What is a docker image?

A Docker Image is an executable package of software that includes everything needed to run an application. This image informs how a container should instantiate, determining which software components will run and how.

A Docker Container is a virtual environment that bundles application code with all the dependencies required to run the application. The application runs quickly and reliably from one computing environment to another.

So how will we go about storing an instantiated class? and how will the user test it? This is what we learnt when building our prototype.

The prototype

To be able to upload a trained model, the user must create a pickle, which is a serialization of a python class, and upload that along with the source code of the class so that when we load this pickle, it has a 'blue print' to fit into. But then how does the user call functions on live code?

To solve this I wrote a simple API with FastAPI which has a predict method, in our complete implementation this API will have a series of end-points for the user to test the model, but for now we'll just test with a predict method. This method takes a file and returns an output. The end-point loads the pickle, then calls the predict function on the trained model, before returning its output as a JSON object to our API.

The dummy model

The API

The docker file

The prototype in action!

Not exactly Google 2, but a great start that lets us see how our back-end will work, and how users will interact with these models.