This project is aimed to help machine learning developers to quickly build and deploy a Flask web app that take advantage of their machine learning ready PyTorch model. The documentation explains how to get up and running with either virtualenv or Docker.
This website is deployed in Heroku: https://flaskpytorch.herokuapp.com/
By default, this app uses MobileNetV2 image classifier that was pre-trained on the ImageNet dataset. This can be easily changed with any custom deep learning model.
You need to have Python installed in your computer.
-
Install
virtualenv
:pip install virtualenv
-
Create a Python virtual environment:
virtualenv venv
-
Activate virtual environment:
- Windows:
cd venv\Scripts activate cd ..\..
- Lunix / Mac:
source venv/bin/activate
-
Install libraries:
pip install -r requirements.txt
- Run the app:
flask run
- Run on a specific port:
flask run -p <port>
-
Create a Docker image
docker build -t pytorchflask .
This will create an image with the name
pytorchflask
. You can replace that with a custom name for your app. -
Run the docker image
docker run -d -p 127.0.0.1:5000:80 pytorchflask
This will run the app on port
5000
. You can replace that with which ever port that is more suitable.
- Go to
models.py
- Follow the structure of the class
MobileNet
to create a custom model class - Use your class in
app.py
- Imad Eddine Toubal - Initial work - imadtoubal
This project is licensed under the MIT License - see the LICENSE file for details
Happy coding!