A boilerplate template to wrap your PyTorch machine learning code as a Flask REST API, complete with Dockerfiles, Tensorboard, etc. This template is designed for classification tasks in PyTorch so minor changes are required for regression tasks. Checkout this simple text-classification repository for an example of how this boilerplate template can be leveraged.
pip install cookiecutter invoke requests
cookiecutter gh:practicalAI/boilerplate
- Place data in src/datasets or have it in S3, etc.
- Edit the training.json configuration file in src/configs.
- Define requirements and setup.py for your package in src.
- Edit application.py, config.py, and wsgi.py in src.
- Edit endpoints.py and utils.py functions in src/api.
- Add ML components in src/{{ cookiecutter.service_name }}.
- Add unit and e2e tests in src/tests.
{{ cookiecutter.service_name }}/
βββ src/ - source files
| βββ api/ - holds all API scripts
| | βββ endpoints.py - API endpoint definitions
| | βββ operations.py - endpoint operation
| | βββ utils.py - api utility functions
| βββ configs/ - configuration files
| | βββ logging.json - logger configuration
| | βββ training.json - training configuration
| βββ data/ - directory of datasets
| βββ experiments/ - directory of experiments
| βββ logs/ - directory of log files
| | βββ errors/ - error log
| | βββ info/ - info log
| βββ tensorboard/ - TensorBoard events
| βββ tests/ - tests
| | βββ e2e/ - integration tests
| | βββ unit/ - unit tests
| βββ {{ cookiecutter.package_name }}/ - ML files
| | βββ dataset.py - dataset generator functions
| | βββ eval.py - evaluation operations
| | βββ load.py - load data
| | βββ model.py - model functions
| | βββ predict.py - inference operations
| | βββ split.py - split data
| | βββ train.py - training operations
| | βββ utilities.py - utilities
| | βββ vectorize.py - vectorize data
| βββ application.py - application script
| βββ config.py - application configuration
| βββ requirements.txt - python package requirements
| βββ setup.py - custom package setup
| βββ wsgi.py - application initialization
βββ .dockerignore - dockerignore file
βββ .gitignore - gitignore file
βββ Dockerfile - Dockerfile for the application
βββ CODE_OF_CONDUCT.md - code of conduct
βββ CODEOWNERS - code owner assignments
βββ LICENSE - license description
βββ README.md - repository readme