Skip to content
Train and Deploy Simple Machine Learning Model With Web Interface - Docker, PyTorch & Flask
Jupyter Notebook Python JavaScript HTML CSS Dockerfile
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
Notebooks Create Jul 29, 2019
app Update home.html Jul 28, 2019
Dockerfile Create Dockerfile Jul 28, 2019
Dockerfile-jetson Update Dockerfile-jetson Jul 28, 2019 Update Aug 29, 2019
requirements.txt Update requirements.txt Jul 28, 2019

Train and Deploy Machine Learning Model With Web Interface - Docker, PyTorch & Flask

Live access (deployed on GCP):

alt text

Blog post:

This repo contains code associated with the above blog post.

Running on Local/cloud machine

Clone the repo and build the docker image

sudo docker build -t flaskml .

NB: if you have MemoryError while installing PyTorch in the container, please consider adding 2G swap to your virtual machine (

Then after that you can run the container while specefying the absolute path to the app

sudo docker run -i -t --rm -p 8888:8888 -v **absolute path to app directory**:/app flaskml

This will run the application on localhost:8888

You can use or Ngrok to port the application to the web.

Running on Jetson-Nano

On Jetson-nano, to avoid long running time to build the image, you can download it from Docker Hub. We will also use a costumized Docker command to be able to access the GPU of the device on the container.

docker pull imadelh/jetson_pytorch_flask:arm_v1

Then on your device you can access the bash (this the default command on that image)

sudo ./ run -i -t --rm -v /home/imad:/home/root/ imadelh/jetson_pytorch_flask:arm_v1

and then simply get to the application directory and run it

cd app

Useful files


This a generic web app for ML models. You can update your the network and weights by changing the following files.


Imad El Hanafi

You can’t perform that action at this time.