Using AI to Detect Proper Exercise Form
Abstract
Have you ever wondered how Artificial Intelligence (AI) can be used to improve human health and medicine? Computers can now identify human joints as key points to track our body movements. They can then use this information along with training data sets to show us if we perform exercises safely, to prevent us from getting injured. Create your own data set and test out if your algorithm can reliably detect good and bad exercise form.
Summary
None
Readily available
Always exercise with care and pay attention to how your body feels during each movement. Immediately stop or modify any exercise that causes pain or discomfort. Participants should take frequent breaks, especially if they notice muscle fatigue or weakness, as performing many repetitive motions in a short period of time can put unnecessary strain on the body.
Objective
In this science project, you will train an AI model that uses multiple object tracking to see if it can spot safe exercise form. By doing this, you will explore how AI might help make weight training more effective and safer--boosting strength while preventing injuries to support better health.
Introduction
Have you ever wondered how Artificial Intelligence (AI) could be used in healthcare or to improve your overall health? AI refers to computer systems that can perform tasks that normally require human intelligence, such as recognizing patterns, learning from data, and making decisions. Research has shown that increased muscle strength is correlated to overall health and longevity, or living longer. New AI methods will allow scientists and physicians to more reliably track body movements to assess the accuracy of joint movement for medical practices like physical therapy, which is necessary to regain range of motion for patients to be able to effectively use their bodies, limbs, and digits after an injury. These algorithms can also be used to check for proper form in physical activity, such as lifting heavy weights for strength training, to prevent injuries. So, how can AI be harnessed for these health applications?
Computer vision is a field within AI. It aims to make sense of and interpret what is happening in images and videos, similar to how humans perceive or see them. To do this, complex algorithms are necessary, such as Multiple Object Tracking (MOT). MOT maps objects by both detecting them and tracking them in two separate computational processes. This is often accomplished using deep learning models such as YOLO (You Only Look Once) for object detection, paired with tracking algorithms to follow the identified objects over time.

Computer vision of a multiple object tracking algorithm, showing mapping of keypoints, in this case joints, over the image of a human body.
This AI learning model is commonly used in research and development of autonomous driving, action recognition, mobile robotics, and intelligent surveillance. However, it could also be used for everyday applications. Have you ever been nervous about lifting heavy weights at the gym because you were worried about your body's ergonomics or best form being incorrect and potentially getting hurt? What if you could develop a science project to help you with this and prevent yourself or others from getting injured?
In this science project, you will first give the AI model images of examples of good and bad weight-lifting or exercise forms to train the machine learning model. To do this, the model will map the “keypoints” or movable joints onto the image of a human body. These points include the wrist, elbow, and shoulder to map the arm's position and the ankle, knee, and hip joint to map the leg's position. Using this information, you can also compare their locations relative to each other to see if you are using the proper form in your exercise, such as a squat. After mapping the keypoints, videos will be required to train the AI model. It will do this by determining the positions of the keypoints and assessing if they represented ergonomic or good exercise form compared to improper or bad form for each exercise. In this science project, you will test if an AI model can reliably indicate whether you or your participants are performing an exercise correctly and safely.
Terms and Concepts
- Artificial Intelligence (AI)
- Longevity
- Algorithm
- Computer vision
- Multiple Object Tracking (MOT)
- Deep learning
- YOLO (You Only Look Once)
- Ergonomics
- AI Model
- Keypoints
Questions
- What health applications can AI with MOT be used for?
- What are the benefits of strength training?
- What is a potential consequence of doing improper or unsafe body movements?
- What is an ergonomic or safe movement?
- What keypoints need to be mapped to show body movement? What does each grouping of joints represent?
- What AI algorithm is used in this project to map body movement? How does it do that?
Bibliography
Resources on human health and strength training:
- Harvard Health Publishing. (2021, February 15). Want to live longer and better? Do strength training. Retrieved April 14, 2025.
- Mayo Clinic Staff (2022, November 19). Weight training: Do's and don'ts of proper technique. Retrieved April 14, 2025.
- Mayo Clinic. (2023, November 18). Strength training: How-to video collection. Retrieved April 14, 2025.
Resources on AI Tools:
- Chan et al. (2022, October). Online multiple object tracking using joint detection and embedding network. Retrieved April 14, 2025.
- Kohli, S. (2019, November 17). Understanding a Classification Report For Your Machine Learning Model. Retrieved April 16, 2025.
- Turp, Misra. (2023, February 22). Why do we split data into train test and validation sets? Retrieved April 16, 2025.
- StatQuest with Josh Starmer. (2020, January 13). XGBoost Part 2 (of 4): Classification. YouTube. Retrieved April 16, 2025.
Materials and Equipment
- Computer with Internet access
- Phone or camera with the ability to record videos
Experimental Procedure

Setting Up the Google Colab Environment
- You will need a Google account. If you do not have one, make one when prompted.
- Download the exercise_form.ipynb file from Science Buddies. This is the code you will need to process your data.
- Within your Google Drive, click on ‘MyDrive,’ then create a new folder and rename it
exercise_form. Inside the folder, upload the exercise_form.ipynb folder. - Double-click on the exercise_form.ipynb. This should automatically open in Google Colab. You will need to do the following in the notebook:
- Read the Troubleshooting Tips and How to Use This Notebook sections. Follow the instructions you find in that section.
- Run the block under Importing Libraries to ensure you have access to all the functions we will use for this project.
Collecting the Data
Working with Human Test Subjects
There are special considerations when designing an experiment involving human subjects. Fairs affiliated with Regeneron International Science and Engineering Fair (ISEF) often require an Informed Consent Form (permission sheet) for every participant who is questioned. Consult the rules and regulations of the science fair that you are entering, prior to performing experiments or surveys. Please refer to the Science Buddies documents Projects Involving Human Subjects and Scientific Review Committee for additional important requirements. If you are working with minors, you must get advance permission from the children's parents or guardians (and teachers if you are performing the test while they are in school) to make sure that it is all right for the children to participate in the science fair project. Here are suggested guidelines for obtaining permission for working with minors:
- Write a clear description of your science fair project, what you are studying, and what you hope to learn. Include how the child will be tested. Include a paragraph where you get a parent's or guardian's and/or teacher's signature.
- Print out as many copies as you need for each child you will be surveying.
- Pass out the permission sheet to the children or to the teachers of the children to give to the parents. You must have permission for all the children in order to be able to use them as test subjects.
You have the flexibility to choose any exercise for your model to classify as having good or bad form–such as pull-ups, push-ups, squats, or lunges. Just make sure that you (or whoever is demonstrating) can consistently perform the chosen exercise with proper form.
- Record at least 100 short videos of the chosen exercise performed with good form using a phone or any camera. Each video should feature one person completing a single repetition and should be consistent in length (e.g., each video should be between 2 and 4 seconds). Ensure the footage focuses solely on the exercise–avoid including actions like walking to or from the camera. If you are filming alone, trim out these parts. Having a second person record the exercise can make this process easier and result in cleaner videos. Here are some video-taking tips to make your model robust:
- Change the camera angle between shots by rotating around the person performing the exercise.
- Have the person rotate their body before starting the exercise in different recordings.
- Vary the zoom level between recordings, taking closer shots and further shots (make sure the whole person can still be seen).
- These are just a few ideas–feel free to explore other variations to make your dataset more robust!
- Inside the
exercise_formfolder is another folder calledexercise_videos, inside that is a folder calledgood_form. Upload the videos of the exercise with good form to thegood_formfolder. - Repeat Step 1, but this time perform the exercise using bad form. While there are many ways to perform an exercise incorrectly, it is important to stay consistent and collect multiple videos of the same type of poor form. For example, if you are recording squats, one common mistake is letting the knees extend past the feet. In this case, you should capture at least 50 videos from different angles showing this specific error.
- If you want your model to detect additional types of poor form, you will need to collect separate sets of videos for each. Aim to gather at least 50 videos for every variation of poor form you plan to include.
- Once you have recorded the poor form videos, upload them to the
exercise_form/exercise_videos/bad_formfolder. - For your test data, record at least two additional videos of the same person performing the exercise – one with good form and one with bad form. To keep things organized, it is a good idea to rename the files to something like good_form_test(1).MP4 and bad_form_test(2).MP4 so you can easily tell them apart. Upload these test videos to the
exercise_form/test_videosfolder.
Saving Keypoints
Now, head back to the Google Colab environment to move on to the next section of the project.
- (Code Block 1A) This code block processes videos of exercise repetitions using a YOLOv8 pose estimation model. It loops through folders of good and bad form videos, runs pose detection on each frame, and creates annotated versions of the videos with drawn keypoints (specific body landmarks like shoulders, elbows, knees, etc.) and skeletons (lines connecting those keypoints to represent the body’s posture). At the same time, it extracts the keypoint coordinates and confidence scores for each frame, saving them into CSV files for further analysis. This prepares clean, labeled data for training or evaluating a model to classify exercise form. Run this code block. This may take a few minutes.
- You can view the labeled videos in the
exercise_form/exercise_labeled_videosfolder. Inside, you will find two subfolders–one for good form and one for bad form–each containing their respective labeled videos. - You can view the CSV files the model will use for training in the
exercise_form/exercise_keypointsfolder. You will again find two subfolders–one for good form and one for bad form–each containing their respective CSV files.
- You can view the labeled videos in the
Training the Model
- (Code Block 2A) This code block extracts features from keypoints CSV files, which contain detected body keypoints for each frame of a video. From these points, the algorithm creates feature vectors for machine learning. It calculates the mean and standard deviation of keypoint positions to summarize posture and movement, and then stores these feature vectors for each video. The code loops through both good and bad form video folders to extract the features, and labels them accordingly (0 for good form, 1 for bad form). It then prepares the data as arrays (X for features, Y for labels) to be used for training a machine learning model. Run this code block. This may take a few minutes.
- (Code Block 2B) This code block splits the exercise form dataset into training and test sets. It trains an XGBoost classifier on training data, predicts the form labels for the test set, and evaluates the model’s performance using a classification report. Run this code block.
- We split our dataset into train and test to avoid overfitting and ensure the model is tested on data it has never seen before. You can check out this video to learn more about why it’s important to use a training dataset for this AI algorithm.
- We have used an XGBoost classifier for this project, but feel free to experiment with other machine learning models and algorithms to compare their performance. To learn more about the XGBoost algorithm, check out this resource.
- The classification report shows performance metrics like precision, recall, F1-score, and support for both good and bad form exercises, as well as overall accuracy. To read more about these metrics and how to read a classification report, here is an article we recommend reading.
- (Code Block 2C) This code block saves the trained machine learning model (the XGBoost classifier) to a file so you can reuse it later without needing to retrain it. Run this code block.
Testing the Model
- (Code Block 3A) Under the
#TODOcomment in this code block, replace the placeholder with the name of your test video file. Remember, your test videos are located in theexercise_form/test_videosfolder. The code will then run pose detection on the video, saving an annotated version and a CSV file with keypoint positions to the same folder. - (Code Block 3B) This code loads the trained model, gets features from the test video’s CSV, and predicts if the form is good or bad. It then prints a message based on the result. Was your model able to tell if the exercise was good or bad form? Here are some suggestions for improving your model:
- Train the model with data from different people to help it generalize better across various body types and exercise forms, which can vary based on body proportions. This will enhance its ability to differentiate between good and bad form for more people.
- Include a wide variety of bad form examples in the training data to teach the model to recognize multiple forms of improper movement.
Ask an Expert
Global Goals
The United Nations Sustainable Development Goals (UNSDGs) are a blueprint to achieve a better and more sustainable future for all.
Variations
- Expand the project to include multiple exercises (e.g., burpees, pull-ups, push-ups)—the possibilities are endless! Use resources, like the ones in our bibliography or this channel, that is backed by peer-reviewed literature, to help you find additional exercises and learn their proper form.
- Train a model to detect different repetitions so you do not have to upload multiple videos.
- Get the model to run in real-time using input from a webcam instead of pre-recorded videos
- Run the model on a Raspberry Pi to make something smaller and more portable (easier to bring to the gym or exercise class)
- Test this project for small physical therapy movements. For example, test if the algorithm can reliably measure proper and improper small movements such as fine motor skills, like wrist flexion, extension, supination, and pronation. These movements can be challenging after immobilization due to a wrist fracture or other wrist mobility conditions such as carpel tunnel. Use medical resources to see if it can also measure if the movement is within the ideal range of wrist mobility for physical rehabilitation applications. You can learn more about how to train the YOLO Pose model to recognize hand keypoints here.
Careers
If you like this project, you might enjoy exploring these related careers:








