Skip to content

Workouts Monitoring using Ultralytics YOLO11

Monitoring workouts through pose estimation with Ultralytics YOLO11 enhances exercise assessment by accurately tracking key body landmarks and joints in real-time. This technology provides instant feedback on exercise form, tracks workout routines, and measures performance metrics, optimizing training sessions for users and trainers alike.



Watch: Workouts Monitoring using Ultralytics YOLO11 | Pushups, Pullups, Ab Workouts

Advantages of Workouts Monitoring?

  • Optimized Performance: Tailoring workouts based on monitoring data for better results.
  • Goal Achievement: Track and adjust fitness goals for measurable progress.
  • Personalization: Customized workout plans based on individual data for effectiveness.
  • Health Awareness: Early detection of patterns indicating health issues or over-training.
  • Informed Decisions: Data-driven decisions for adjusting routines and setting realistic goals.

Real World Applications

Workouts MonitoringWorkouts Monitoring
PushUps CountingPullUps Counting
PushUps CountingPullUps Counting

Workouts Monitoring Example

import cv2

from ultralytics import solutions

cap = cv2.VideoCapture("path/to/video/file.mp4")
assert cap.isOpened(), "Error reading video file"
w, h, fps = (int(cap.get(x)) for x in (cv2.CAP_PROP_FRAME_WIDTH, cv2.CAP_PROP_FRAME_HEIGHT, cv2.CAP_PROP_FPS))

gym = solutions.AIGym(
    model="yolo11n-pose.pt",
    show=True,
    kpts=[6, 8, 10],
)

while cap.isOpened():
    success, im0 = cap.read()
    if not success:
        print("Video frame is empty or video processing has been successfully completed.")
        break
    im0 = gym.monitor(im0)

cv2.destroyAllWindows()
import cv2

from ultralytics import solutions

cap = cv2.VideoCapture("path/to/video/file.mp4")
assert cap.isOpened(), "Error reading video file"
w, h, fps = (int(cap.get(x)) for x in (cv2.CAP_PROP_FRAME_WIDTH, cv2.CAP_PROP_FRAME_HEIGHT, cv2.CAP_PROP_FPS))

video_writer = cv2.VideoWriter("workouts.avi", cv2.VideoWriter_fourcc(*"mp4v"), fps, (w, h))

gym = solutions.AIGym(
    show=True,
    kpts=[6, 8, 10],
)

while cap.isOpened():
    success, im0 = cap.read()
    if not success:
        print("Video frame is empty or video processing has been successfully completed.")
        break
    im0 = gym.monitor(im0)
    video_writer.write(im0)

cv2.destroyAllWindows()
video_writer.release()

KeyPoints Map

keyPoints Order Ultralytics YOLO11 Pose

Arguments AIGym

NameTypeDefaultDescription
kptslistNoneList of three keypoints index, for counting specific workout, followed by keypoint Map
line_widthint2Thickness of the lines drawn.
showboolFalseFlag to display the image.
up_anglefloat145.0Angle threshold for the 'up' pose.
down_anglefloat90.0Angle threshold for the 'down' pose.
modelstrNonePath to Ultralytics YOLO Pose Model File

Arguments model.predict

ArgumentTypeDefaultDescription
sourcestr'ultralytics/assets'Specifies the data source for inference. Can be an image path, video file, directory, URL, or device ID for live feeds. Supports a wide range of formats and sources, enabling flexible application across different types of input.
conffloat0.25Sets the minimum confidence threshold for detections. Objects detected with confidence below this threshold will be disregarded. Adjusting this value can help reduce false positives.
ioufloat0.7Intersection Over Union (IoU) threshold for Non-Maximum Suppression (NMS). Lower values result in fewer detections by eliminating overlapping boxes, useful for reducing duplicates.
imgszint or tuple640Defines the image size for inference. Can be a single integer 640 for square resizing or a (height, width) tuple. Proper sizing can improve detection accuracy and processing speed.
halfboolFalseEnables half-precision (FP16) inference, which can speed up model inference on supported GPUs with minimal impact on accuracy.
devicestrNoneSpecifies the device for inference (e.g., cpu, cuda:0 or 0). Allows users to select between CPU, a specific GPU, or other compute devices for model execution.
max_detint300Maximum number of detections allowed per image. Limits the total number of objects the model can detect in a single inference, preventing excessive outputs in dense scenes.
vid_strideint1Frame stride for video inputs. Allows skipping frames in videos to speed up processing at the cost of temporal resolution. A value of 1 processes every frame, higher values skip frames.
stream_bufferboolFalseDetermines whether to queue incoming frames for video streams. If False, old frames get dropped to accomodate new frames (optimized for real-time applications). If `True', queues new frames in a buffer, ensuring no frames get skipped, but will cause latency if inference FPS is lower than stream FPS.
visualizeboolFalseActivates visualization of model features during inference, providing insights into what the model is "seeing". Useful for debugging and model interpretation.
augmentboolFalseEnables test-time augmentation (TTA) for predictions, potentially improving detection robustness at the cost of inference speed.
agnostic_nmsboolFalseEnables class-agnostic Non-Maximum Suppression (NMS), which merges overlapping boxes of different classes. Useful in multi-class detection scenarios where class overlap is common.
classeslist[int]NoneFilters predictions to a set of class IDs. Only detections belonging to the specified classes will be returned. Useful for focusing on relevant objects in multi-class detection tasks.
retina_masksboolFalseUses high-resolution segmentation masks if available in the model. This can enhance mask quality for segmentation tasks, providing finer detail.
embedlist[int]NoneSpecifies the layers from which to extract feature vectors or embeddings. Useful for downstream tasks like clustering or similarity search.
projectstrNoneName of the project directory where prediction outputs are saved if save is enabled.
namestrNoneName of the prediction run. Used for creating a subdirectory within the project folder, where prediction outputs are stored if save is enabled.

Arguments model.track

ArgumentTypeDefaultDescription
sourcestrNoneSpecifies the source directory for images or videos. Supports file paths and URLs.
persistboolFalseEnables persistent tracking of objects between frames, maintaining IDs across video sequences.
trackerstrbotsort.yamlSpecifies the tracking algorithm to use, e.g., bytetrack.yaml or botsort.yaml.
conffloat0.3Sets the confidence threshold for detections; lower values allow more objects to be tracked but may include false positives.
ioufloat0.5Sets the Intersection over Union (IoU) threshold for filtering overlapping detections.
classeslistNoneFilters results by class index. For example, classes=[0, 2, 3] only tracks the specified classes.
verboseboolTrueControls the display of tracking results, providing a visual output of tracked objects.

FAQ

How do I monitor my workouts using Ultralytics YOLO11?

To monitor your workouts using Ultralytics YOLO11, you can utilize the pose estimation capabilities to track and analyze key body landmarks and joints in real-time. This allows you to receive instant feedback on your exercise form, count repetitions, and measure performance metrics. You can start by using the provided example code for pushups, pullups, or ab workouts as shown:

import cv2

from ultralytics import solutions

cap = cv2.VideoCapture("path/to/video/file.mp4")
assert cap.isOpened(), "Error reading video file"
w, h, fps = (int(cap.get(x)) for x in (cv2.CAP_PROP_FRAME_WIDTH, cv2.CAP_PROP_FRAME_HEIGHT, cv2.CAP_PROP_FPS))

gym = solutions.AIGym(
    line_width=2,
    show=True,
    kpts=[6, 8, 10],
)

while cap.isOpened():
    success, im0 = cap.read()
    if not success:
        print("Video frame is empty or video processing has been successfully completed.")
        break
    im0 = gym.monitor(im0)

cv2.destroyAllWindows()

For further customization and settings, you can refer to the AIGym section in the documentation.

What are the benefits of using Ultralytics YOLO11 for workout monitoring?

Using Ultralytics YOLO11 for workout monitoring provides several key benefits:

  • Optimized Performance: By tailoring workouts based on monitoring data, you can achieve better results.
  • Goal Achievement: Easily track and adjust fitness goals for measurable progress.
  • Personalization: Get customized workout plans based on your individual data for optimal effectiveness.
  • Health Awareness: Early detection of patterns that indicate potential health issues or over-training.
  • Informed Decisions: Make data-driven decisions to adjust routines and set realistic goals.

You can watch a YouTube video demonstration to see these benefits in action.

How accurate is Ultralytics YOLO11 in detecting and tracking exercises?

Ultralytics YOLO11 is highly accurate in detecting and tracking exercises due to its state-of-the-art pose estimation capabilities. It can accurately track key body landmarks and joints, providing real-time feedback on exercise form and performance metrics. The model's pretrained weights and robust architecture ensure high precision and reliability. For real-world examples, check out the real-world applications section in the documentation, which showcases pushups and pullups counting.

Can I use Ultralytics YOLO11 for custom workout routines?

Yes, Ultralytics YOLO11 can be adapted for custom workout routines. The AIGym class supports different pose types such as "pushup", "pullup", and "abworkout." You can specify keypoints and angles to detect specific exercises. Here is an example setup:

from ultralytics import solutions

gym = solutions.AIGym(
    line_width=2,
    show=True,
    kpts=[6, 8, 10],
)

For more details on setting arguments, refer to the Arguments AIGym section. This flexibility allows you to monitor various exercises and customize routines based on your needs.

How can I save the workout monitoring output using Ultralytics YOLO11?

To save the workout monitoring output, you can modify the code to include a video writer that saves the processed frames. Here's an example:

import cv2

from ultralytics import solutions

cap = cv2.VideoCapture("path/to/video/file.mp4")
assert cap.isOpened(), "Error reading video file"
w, h, fps = (int(cap.get(x)) for x in (cv2.CAP_PROP_FRAME_WIDTH, cv2.CAP_PROP_FRAME_HEIGHT, cv2.CAP_PROP_FPS))

video_writer = cv2.VideoWriter("workouts.avi", cv2.VideoWriter_fourcc(*"mp4v"), fps, (w, h))

gym = solutions.AIGym(
    line_width=2,
    show=True,
    kpts=[6, 8, 10],
)

while cap.isOpened():
    success, im0 = cap.read()
    if not success:
        print("Video frame is empty or video processing has been successfully completed.")
        break
    im0 = gym.monitor(im0)
    video_writer.write(im0)

cv2.destroyAllWindows()
video_writer.release()

This setup writes the monitored video to an output file. For more details, refer to the Workouts Monitoring with Save Output section.

📅 Created 10 months ago ✏️ Updated 9 days ago

Comments