About
Applications
HoudiniUnreal EngineUnity 3DNukeMayaBlenderZBrushPythonMixed RealityMachine LearningGraphic DesignExtrasAboutNotes
Overview
- With ML applications, the model, scaler, and any other applicable components run in the Python-based backend.
Process
Flask
- Data input through API requests using Postman which relays JSON data to the flask app and Python's request library.
- Flask app connects to HTML web form.
Components
- App
- HTML form using Flask linked to home.html
- Form data input into Flask.
- Flask returns data generated by function through function.html.
- Templates
- home.html
- Flask-based form for accepting user input.
- Relays user input to Flask app.
- function.html
- Returns data generated by funcion.
Heroku Deployment
- In an Anaconda Prompt, navigate to the location of the files to be deployed.
- Create a venv with intended Python version:
- Activate new venv and install relevant libraries for application.
- Use pip, not conda, so that a pip freeze requirements file can be generated.
- Libraries
- flask
- Flask-WTF
- scikit-learn
- This also installs joblib and numpy.
- tensorflow
- gunicorn
- Python web server gateway interface.
- Used to push the flask app to Heroku server.
- Generate pip freeze requirements file to log the installed libraries.
- Create process file required by Heroku.
- Label the file
Procfile
with no file extension. - Include the following (note the name of the app file reference):
- On Heroku Dashboard, Create new app.
- Choose unique App name. (my-tf-flower-app)
- Choose Deployment method, namely
Heroku Git
and follow instructions. - Push rejected notifications
- No matching distribution found for <libraryname>
- Identify the library that was not able to be installed and identify a suitable version from the available options in Heroku.
- Update the requirements.txt file to reflect the intended version of the library.
- Compile slug size is too large (max is 500M)
- Consider other library versions that may be lighter and without heavy dependencies.
- Resources
- Update the requirements.txt file to reflect the intended version of the library.
- Commit and push update in Prompt
- Heroku attempts to compress and build source.
- Successful deployment results in message of
- Deactivate venv in prompt.
conda create --name venvcustomname python=3.7
pip freeze > requirements.txt
Resource: https://pip.pypa.io/en/stable/cli/pip_freeze/
web: gunicorn app:app
git commit -am "Updated lib in requirements file."
git push heroku master
Launching...
https://<appname>.herokuapp.com/ deployed to Heroku
Verifying deploy... done.
Local Testing
Postman
- Use Postman to send a POST request to the API in JSON format.
Troubleshooting
TF on Heroku
- The Tensorflow module is very large, exceeding the slug limits for Heroku, primarily because of the GPU support. To mitigate the slug limits issue that arises, replace
tensorflow
withtensorflow-cpu
in the pip freeze requirements file. - Beware that apps on Heroku using TF can take some time to load.