AI Want to Pump... You Up!

There are few things one can do that will benefit them more than having a regular exercise routine. Physical activity can improve brain health, help maintain a healthy weight, reduce the risk of certain diseases, and strengthen the musculoskeletal system. The CDC estimates that even 10 minutes of activity per day could prevent 110,000 deaths per year among adults in the US. All of these facts make a strong case that nearly everyone should consider adopting a regular workout schedule, but the fact is that only about five percent of adults manage to fit any meaningful amount of exercise into their daily lives.

While there are many reasons that people do not exercise as much as they should, there are some things we can do to help us change that and stay more active. One popular option is to make use of a wearable fitness tracker that passively records one’s physical activities to provide insights and motivation through positive feedback. The hardware hackers over at CodersCafe have recently designed an open source fitness tracker — called GetFit — that is inexpensive, simple to build, and can give you the insights and motivation you need to get the most out of your workouts. GetFit uses an Arduino and Edge Impulse to keep tabs on your activities and let you know how much progress you are making.

Data sampling

GetFit consists of an Arduino Nano 33 BLE Sense board in a 3D-printed case that is strapped to the upper arm. By using a rechargeable LiPo battery to power the device, and the Bluetooth Low Energy radio onboard the Arduino to transmit data, GetFit is completely self-contained and wireless. The nine-axis accelerometer that is built into the Arduino is used to record the movements of the person wearing the device. Those motions are classified by a machine learning model developed with Edge Impulse to decipher what exercises the wearer is performing, and how many repetitions of each are completed. This information is wirelessly transmitted to a companion smartphone app that gives the GetFit user the motivation they need to power through another workout.

The workouts may be challenging, but no heavy lifting was required to build the machine learning data analysis pipeline. The Arduino Nano 33 BLE Sense is fully supported by Edge Impulse, so CodersCafe was able to flash new firmware to the board that gave it a direct connection to Edge Impulse Studio. This simplified data collection, because they were able to just run through some exercises, and the accelerometer measurements were automatically uploaded to Edge Impulse to serve as training data for the model.  For the prototype device, they captured data for pushups, squats and arm circles — but by recording more data, any exercise could be supported in theory.

Accelerometer data representing a pushup

The next step in the impulse is a spectral analysis preprocessor, which is very effective at extracting the most important features from accelerometer data. These features are then fed into both a convolutional neural network classifier and a K-means anomaly detector. The training process was kicked off, then it was checked against a test dataset that was held back from the training process. Testing showed that the model achieved an 87.23% classification accuracy, which is quite good considering that less than 13 minutes of motion data was collected.

To keep GetFit fully self-contained, the Edge Impulse classification pipeline was deployed as an Arduino library that could easily be incorporated into any Arduino sketch. By enabling the EON Compiler, the model was reduced in size while maintaining a high degree of accuracy. The final model requires no more than 12.8 KB of RAM, and inferences can run in about a quarter of a second.

Machine learning classification pipeline

The completed device continually monitors the wearer’s movements to determine when known exercises are performed. To prevent false positives, the anomaly detector looks for anything out of the ordinary, and will prevent those cases from being counted as exercises. This data is transmitted to a smartphone app that provides a summary of the day’s activities, and translates that activity into a count of the calories that have been burned to add some extra motivation. One can also look at historical data to see how their performance has changed over time.

Model testing

Lace up your gym shoes, point your browser to Edge Impulse, then head over to CodersCafe’s write-up for the information you need to build your own customizable fitness tracker.


Want to see Edge Impulse in action? Schedule a demo today.

Subscribe

Are you interested in bringing machine learning intelligence to your devices? We're happy to help.

Subscribe to our newsletter