We don't have a Python package yet. Install from source in a Python>=3.8 environment.
pip install git+https://github.com/roboflow/sports.git
cd examples/soccer
pip install -r requirements.txt
./setup.sh
Original data comes from the DFL - Bundesliga Data Shootout Kaggle competition. This data has been processed to create new datasets, which can be downloaded from the Roboflow Universe.
use case | dataset | train model |
---|---|---|
soccer player detection | ||
soccer ball detection | ||
soccer pitch keypoint detection |
- YOLOv8 (Player Detection) - Detects players, goalkeepers, referees, and the ball in the video.
- YOLOv8 (Pitch Detection) - Identifies the soccer field boundaries and key points.
- SigLIP - Extracts features from image crops of players.
- UMAP - Reduces the dimensionality of the extracted features for easier clustering.
- KMeans - Clusters the reduced-dimension features to classify players into two teams.
-
PITCH_DETECTION
- Detects the soccer field boundaries and key points in the video. Useful for identifying and visualizing the layout of the soccer pitch.python main.py --source_video_path data/2e57b9_0.mp4 \ --target_video_path data/2e57b9_0-pitch-detection.mp4 \ --device mps --mode PITCH_DETECTION
2e57b9_0-pitch-detection.mp4
-
PLAYER_DETECTION
- Detects players, goalkeepers, referees, and the ball in the video. Essential for identifying and tracking the presence of players and other entities on the field.python main.py --source_video_path data/2e57b9_0.mp4 \ --target_video_path data/2e57b9_0-player-detection.mp4 \ --device mps --mode PLAYER_DETECTION
2e57b9_0-player-detection.mp4
-
BALL_DETECTION
- Detects the ball in the video frames and tracks its position. Useful for following ball movements throughout the match.python main.py --source_video_path data/2e57b9_0.mp4 \ --target_video_path data/2e57b9_0-ball-detection.mp4 \ --device mps --mode BALL_DETECTION
2e57b9_0-ball-detection.mp4
-
PLAYER_TRACKING
- Tracks players across video frames, maintaining consistent identification. Useful for following player movements and positions throughout the match.python main.py --source_video_path data/2e57b9_0.mp4 \ --target_video_path data/2e57b9_0-player-tracking.mp4 \ --device mps --mode PLAYER_TRACKING
2e57b9_0-player-tracking.mp4
-
TEAM_CLASSIFICATION
- Classifies detected players into their respective teams based on their visual features. Helps differentiate between players of different teams for analysis and visualization.python main.py --source_video_path data/2e57b9_0.mp4 \ --target_video_path data/2e57b9_0-team-classification.mp4 \ --device mps --mode TEAM_CLASSIFICATION
2e57b9_0-team-classification.mp4
-
RADAR
- Combines pitch detection, player detection, tracking, and team classification to generate a radar-like visualization of player positions on the soccer field. Provides a comprehensive overview of player movements and team formations on the field.python main.py --source_video_path data/2e57b9_0.mp4 \ --target_video_path data/2e57b9_0-radar.mp4 \ --device mps --mode RADAR
2e57b9_0-radar.mp4
- Add smoothing to eliminate flickering in RADAR mode.
- Add a notebook demonstrating how to save data and perform offline data analysis.
This demo integrates two main components, each with its own licensing:
- ultralytics: The object detection model used in this demo, YOLOv8, is distributed under the AGPL-3.0 license.
- sports: The analytics code that powers the sports analysis in this demo is based on the Supervision library, which is licensed under the MIT license. This makes the sports part of the code fully open source and freely usable in your projects.