Skip to content

Graduation project of the rootsacademy: A bikefitting application consisting of a website where users can upload a short video of themselves on a bike trainer and will receive a recommendation to either move the bike saddle up or down.

License

Notifications You must be signed in to change notification settings

datarootsio/bikefitting

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

49 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

maintained by dataroots codecov Streamlit frontend Azure Function ML backend

LinkedIn

logo-dtr

rootsacademy-bikefitting

This is an easy-to-use tool to adjust your bike saddle to the ideal height based on a recommendation by a machine learning model.

General

This is the graduation project of the rootsacademy of October 2021: A bikefitting application consisting of a website where users can upload a 10sec video of themselves on a bike trainer and receive a recommendation to either move the bike saddle up or down. To make the prediction a back-end script will estimate the position of hip, knee and heel for each frame of the video using MoveNet. It then calculates the innerknee-angle and compares this angle to an optimal value of 145°. In case the angle is lower than 140°, the website will recommend the user to move the bike saddle up. In case the angle is higher than 150°, the website will recommend the user to move the bike saddle down. This repository contains the frontend and backend code of the project. This solution is supported on the cloud by Azure.

More information on the project can be read in this blog post.

Source:

We based our angle recommendations on the book: 'Bike fit' by Phil Burt. (Burt, P. (2014). Bike Fit, Optimise your bike position for high performance and injury avoidance. London: Bloomsbury Publishing) It is recommended in this book that the knee angle is between 140° and 150°. An angle around 140° would be more comfortable for the user while an angle closer to 150° would be more performant.

Built With

(back to top)

Quickstart

Quickstart Deployment

  • Clone the repository
  • Follow the terraform readme instructions instantiate the github secrets and create the resources
  • Trigger the terraform workflow to create the required resources on Azure
  • Trigger the backend, frontend and function workflows to deploy the code to the newly created resources

Quickstart Local Testing

  • To test the solution locally, first create a virtual environment containing all dependencencies from the frontend/requirements.txt file. Within this virtual environment, from the rootdirectory, run

    streamlit run frontend/src/app.py
    

Resources

A short section giving an overview of the resources used in this project.

Resources needed to deploy this application on Azure:

  • 2 Resource groups
    • One for frontend and backend resources
    • One for Function resources
  • Storage account
  • Web app with service plan (frontend)
  • Container registry with webhook
  • Function app with service plan
  • Azure ML workspace (backend)
  • Key vault

These resources can be created by using the Terraform scripts.

Code

This repository contains all the code for this project.

Deployment

Azure Cloud:

  • Data Storage: Azure Blob Storage
  • Website Hosting: Azure App Service
  • Backend Hosting: Azure ML

Infrastructure

GitHub Workflows

For deploying the different part of the solution there are four CI/CD piplines, with following jobs/steps. These workflows are automatically triggered when pushing to the master branch.

  1. Streamlit Frontend
    • Check linting (black and flake8)
    • Run python test with coverage
    • Build and upload docker image for frontend to Azure Container Registry
  1. ML Backend
    • Check linting (black and flake8)
    • Run python test with coverage
    • Register and deploy backend model to Azure ML workspace and set model endpoint url in Azure Function
  1. Azure Function
    • Check linting (black and flake8)
    • Deploy function code to Azure Function
  1. Terraform deployment
    • Terraform Init
    • Terraform Validate
    • Terraform Format check
    • Terraform Plan
    • Terraform Apply

When using these pipelines make sure that the environment variables match with the resource names used. Also make sure that the Azure login details are stored in GitHub Secrets.

(back to top)

Code Structure

Tree Overview
├── backend
│   ├── data
│   │   └── videoinputquality_vs_angleaccuracy.csv
│   ├── models
│   │   ├── movenet_lightning
│   │   │   └── ...
│   │   └── movenet_thunder
│   │       └── ...
│   ├── notebooks
│   │   └── ...
│   ├── src
│   │   ├── scripts
│   │   │   └── ...
│   │   ├── test
│   │   │   └── ...
│   │   ├── utils
│   │   │   ├── azure.py
│   │   │   ├── cropping.py
│   │   │   ├── keypoints.py
│   │   │   ├── model.py
│   │   │   ├── postprocessing.py
│   │   │   ├── preprocessing.py
│   │   │   ├── utils.py
│   │   │   └── visualizations.py
│   │   ├── entry.py
│   │   └── local_testing.py
│   └── requirements.txt
├── frontend
│   ├── images
│   │   └── ...
│   ├── src
│   │   ├── scripts
│   │   │   └── ...
│   │   ├── test
│   │   │   └── ...
│   │   ├── utils
│   │   │   ├── azure.py
│   │   │   ├── datahandling.py
│   │   │   ├── ui.py
│   │   │   ├── utils.py
│   │   │   └── visualizations.py
│   │   ├── app.py
│   ├── textfiles
│   │   └── ...
│   ├── config.toml
│   ├── credentials.toml
│   ├── Dockerfile
│   └── requirements.txt
├── function
│   ├── BlobTrigger
│   │   ├── function.json
│   │   └── __init__.py
│   ├── host.json
│   └── requirements.txt
├── terraform
│   ├── images
│   │   └── ...
│   ├── backend.tf
│   ├── frontend.tf
│   ├── function.tf
│   ├── main.tf
│   ├── README.md
│   └── variables.tf
└── README.md

Contact

Acknowledgments

Special thanks to MoveNet for providing such a performant model and to our supervisors at dataroots for guiding us through this project.

(back to top)

About

Graduation project of the rootsacademy: A bikefitting application consisting of a website where users can upload a short video of themselves on a bike trainer and will receive a recommendation to either move the bike saddle up or down.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published