You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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.
Getting Started (using Python virtualenv)
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 code
Run the app:
flask run
Run on a specific port:
flask run -p <port>
Getting Started (using Docker)
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.
Deploying to Heroku
Create Heroku app
heroku create
git push heroku master
OR
Add to existing Heroku app
heroku git:remote -a <your-app-name>
git push heroku master
Changing the model
Go to models.py
Follow the structure of the class MobileNetto create a custom model class