A squat detector algorithm running on fastai
and alphapose
.
The classifier uses the AlphaPose network as an intermediate step, and trains quickly using a pretrained resnet34
courtesy of fastai v2
. Each frame is classified as one of 7 labels that I made up from my exercise routine.
πͺπ¬πͺ πͺππͺ πͺπ€ͺπͺ
I spent a long time trying to make this train on the regular unprocessed images from my webcam feed β it didnβt work.
The whole secret to training this network so simply and quickly (which I eventually figured out) was to use an intermediate network β in this case AlphaPose, a paper from 2018. Alphapose estimates the pose position and draws the colorful lines between the nodes.
As soon as the resnet34 was looking at the colorful pose outputs, instead of the raw images, it converged within a handful of epochs. It was cool to see the power of stacking these networks together.
I built the dataset myself by taking a couple of videos and extracting the noteworthy frames, then uploading them to labelbox.com.
I manually labelled them into 6 categories (took me about 1 hour) the whole thing was free β and also the entire dataset was only 196 images.
> conda activate lightweight
# webcam
> python lightweight.py
# sample vid
> python lightweight.py --vid --saveframe
> conda create -n lightweight python=3.8 pip jupyter
> conda activate lightweight
> conda install -c fastai -c pytorch -c anaconda fastai gh anaconda
> pip install -r requirements.txt
CMU-Perceptual-Computing-Lab/openpose
# 1. New conda env
conda create -n alphapose python=3.6 pip jupyter -y
conda activate alphapose
# 2. Install PyTorch
conda install pytorch==1.1.0 torchvision==0.3.0
git clone https://github.com/MVIG-SJTU/AlphaPose.git
# git pull origin pull/592/head if you use PyTorch>=1.5
cd AlphaPose
# 4. install
-- export PATH=/usr/local/cuda/bin/:$PATH
-- export LD_LIBRARY_PATH=/usr/local/cuda/lib64/:$LD_LIBRARY_PATH
python -m pip install cython