This is a pose estimation demo application for exercise counting with YOLOv8 using YOLOv8-Pose model. Click here to see more vision AI demo and project.
This has been tested and deployed on a reComputer Jetson J4011. However, you can use any NVIDIA Jetson device to deploy this demo.
Current only 3 different exercise types can be counted:
- Squats
- Pushups
- Situps
However, I will keep updating this repo to add more exercises and also add the function of detecting the exercise type.
The YOLOv8-Pose model can detect 17 key points in the human body, then select discriminative key-points based on the characteristics of the exercise. Calculate the angle between key-point lines, when the angle reaches a certain threshold, the target can be considered to have completed a certain action. By utilizing the above-mentioned mechanism, it is possible to achieve an interesting Exercise Counter Application.
-
Step 1: Flash JetPack OS to reComputer Jetson device (Refer to here).
-
Step 2: Access the terminal of Jetson device, install pip and upgrade it
sudo apt update
sudo apt install -y python3-pip
pip3 install --upgrade pip
- Step 3: Clone the following repo
git clone https://github.com/ultralytics/ultralytics.git
- Step 4: Open requirements.txt
cd ultralytics
vi requirements.txt
- Step 5: Edit the following lines. Here you need to press i first to enter editing mode. Press ESC, then type :wq to save and quit
# torch>=1.7.0
# torchvision>=0.8.1
Note: torch and torchvision are excluded for now because they will be installed later.
- Step 6: Install the necessary packages
pip3 install -e .
- Step 7: If there is an error in numpy version, install the required version of numpy
pip3 install numpy==1.20.3
-
Step 8: Install PyTorch and Torchvision (Refer to here).
-
Step 9: Run the following command to make sure yolo is installed properly
yolo detect predict model=yolov8n.pt source='https://ultralytics.com/images/bus.jpg'
- Step 10: Clone exercise counter demo
git clone https://github.com/yuyoujiang/exercise-counting-with-YOLOv8.git
YOLOv8-pose pretrained pose models are PyTorch models and you can directly use them for inferencing on the Jetson device. However, to have a better speed, you can convert the PyTorch models to TensorRT optimized models by following below instructions.
-
Step 1: Download model weights in PyTorch format (Refer to here).
-
Step 2: Execute the following command to convert this PyTorch model into a TensorRT model
# TensorRT FP32 export
yolo export model=yolov8s-pose.pt format=engine device=0
# TensorRT FP16 export
yolo export model=yolov8s-pose.pt format=engine half=True device=0
Tip: Click here to learn more about yolo export
- Step 3: Prepare a video to be tested. Here we have included sample videos for you to test
To run the exercise counter, enter the following commands with the exercise_type
as:
- sit-up
- pushup
- squat
python3 demo.py --sport <exercise_type> --model yolov8s-pose.pt --show True --input <path_to_your_video>
python3 demo.py --sport <exercise_type> --model yolov8s-pose.pt --show True --input 0
https://github.com/ultralytics/
https://wiki.seeedstudio.com