Skip to content

olivier-2018/SoftwareEngg_project

Repository files navigation

Software Engineering project

API development using a Machine Learning model

Project requirements:

  • Develop an API making use of a trained machine learning model.
  • Use GIT version control concept through the API development.
  • The API should include testing, code formating, logging and user login features.
  • The API should be executable.
  • Implement a CI/CD pipeline for additional credits.
  • Documentation and presentation should be available upon submission.

API main goal:

  • The API is to process a single digit (from 0 to 9) audio signal and return the corresponding predicted digit using ML model in the backend.
  • The selected machine learning model for this project is the audio MNIST (Dataset, code) which identifies digits from audio inputs.

Disclaimer: the ML model was trained to a 94% test accuracy but does not generalize on all real life test cases due to the reduced dataset size. Training the ML model on additional / augmented data is out of the project'scope.

  • The basic input method is through file selection. Additional developments are listed below if time permits..

API optional future developments (out of project'scope):

  • Capture single digit audio signal from microphone.
  • Capture multiple digit audio signal from microphone and return sequence of predicted digits.
  • Use multiple digit audio prediction for user login.
  • Use augmented / additional data to improve generalization on model prediction (male/female voices, accents, etc).

Getting started:

  • Environment setup :
# Use virtualenv package to create a virtual python environment:
sudo apt-get install python-virtualenv
# Clone the repository:
git clone git@github.com:olivier-2018/SoftwareEngg_project.git  --branch development
# Create a virtual environment within the repo:
virtualenv venv
# Activate the virtual environment:
source venv/bin/activate
# Install dependencies:
pip install -r requirements.txt
  • Set Flask environment variables:
Linux:
export FLASK_APP=run.py
export FLASK_ENV=development (or production, or testing as required)
export SECRETE_KEY="<whatever you want>" (optional, Flask will assign a secret hash if unset)

Windows powershell:
$env:FLASK_APP = 'run.py'
$env:FLASK_ENV = 'development' (or 'production', or 'testing' as required)
$env: SECRETE_KEY = <whatever you want> (optional, Flask will assign a secret hash if unset)
  • Launch the API locally:
flask run

Note: on WSL you may need to export the display with an Xserver to run flask

  • The API will automatically deploy to Heroku upon succesful build on the main branch.

Note: The Heroku app address is kept private not to reach the free account usage limit during the app development.

Testing:

  • Unit and functional testing functions are located in the "tests" folder.
  • Testing is automatic as part of the CI/CD pipeline but can also be launched manually using the command:
pytest -vrxXs

Demo

Demo

Illustrations:

Welcome screen

Welcome screen

Sign-up screen

Sign-up screen

Welcome screen

Sign-in screen

Sign-in screen

Login screen

App selection

App selection

API call and results

API call and results

User profile screen

User profile screen

App version screen

App version screen

Information screen

Information screen

Tests

tests info

CI/CD & deployment

CICD info

About

Machine Learning API

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published