GithubHelp home page GithubHelp logo

ie-hy / deep-learning-push-up-counter Goto Github PK

View Code? Open in Web Editor NEW

This project forked from netopedro/deep-learning-push-up-counter

0.0 0.0 0.0 93.95 MB

Deep Learning approach to count the number of repetitions in a video of push ups or pull ups.

License: MIT License

Jupyter Notebook 100.00%

deep-learning-push-up-counter's Introduction

Deep Learning Exercise Repetitions Counter

Disclaimer: This project was developed to integrate with an Android application during a 24 hours hackathon. One of the key elements was to keep the model small, capable of performing well on phones and easy to train with data manually gathered during those 24 hours. Therefore, this a simplistic approach to the problem of counting push ups, pull ups and squats.

Demo (Youtube)

Click to open the youtube video.

Demo

Goal

This project aims to build a deep learning solution to count the repetitions of exercises such as push ups or pull ups. A model that can run on phones and that is possible to train with only a few hundred images.

Workflow

  • Gather videos from push ups

  • Use farneback optical flow algorithm to preprocess the videos frame by frame.

  • Label individually a few hundred of images generated.

  • Train a deep neural network using those images.

  • Develop a method to count the repetition from the analysis of the movement in the video.

  • Process test videos using a pipeline composed of the farneback optical flow algorithm + the deep neural network + the algorithm to estimate the repetitions using the predictions of the network.

Dataset construction

The dataset (available in ./data/) was constructed from several videos removed from youtube and some home-made videos. The videos were processed with the optical flow algorithm. This algorithm allowed to construct a new video with a few colours representing the movement of the subjects in the videos.

Afterwards, from the recently generated videos some frames were selected and manually labeled. The labels used were "Moving Up", "Moving Down" or "Not Moving". The latter represents all kind of moves different from down and up.

A validation set was also created to evaluate the performance of the algorithm.

Model training

The model used was a small convolutional neural network built in Keras. The goal of the model was from the input frames, predict if the subject was moving down, up or not moving. The training was a simple process so the input was resized to 64x64. However, the result in the test set was not perfect, and this might indicate that some of the frames were wrongly labeled, or the dataset slightly skewed. In a more positive note, despicte the fact that the model was trained only on push ups, it was able to correctly predict pull ups in the test set.

Counting repetitions

To count the repetitions of an exercise, the movement of the subject was analysed frame by frame. And what was considered as a repetition was a change of state, for example for push ups when the subject moves from an "Up move" to a "Down move". This did not work immediately so a tolerance had to be built due to the accuracy of the model not being 100%. The current state of the subject was then changed to a specific movement if X consecutive frames were classified with that movement. This value of X can be changed exercise wise, and I have found that push ups and pull ups work better with different X values.

Evaluation on a test video

Finally I have added some result videos to my youtube channel.

Video1

Video2

Video3

Video4

deep-learning-push-up-counter's People

Contributors

netopedro avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.