/soccer

Soccer AI leverages cutting-edge computer vision and deep learning models to analyze soccer matches, detecting players, tracking ball movements, and identifying pitch boundaries, all while offering team classification and visual insights.

Primary LanguagePython


Soccer AI 🧠

Demo

Image 1 Image 2 Image 3 Image 4

Link to the Demo

📝 Overview

Research and development of AI models for soccer analytics and insights. This project aims to provide tools for detecting players, goalkeepers, referees, and the ball in soccer videos. It also includes features for tracking player movements, classifying players into teams, and visualizing player positions on the soccer field.

Train ball detectors

Train Results

Train Results

Confusion Matrix

Confusion Matrix

Result for Validation

Result for Validation

Train player detectors

Train Results

Train Results

Confusion Matrix

Confusion Matrix

Result for Validation

Result for Validation

train pitch keypoint detectors

Train Results

Train Results

Result for Validation

Result for Validation

  • Developed and integrated Soccer AI using YOLOv8, achieving over 95% precision and 85% recall in player detection, and 99% precision and recall in keypoint detection for real-time soccer game analysis.

💻 Installation Guide

We don't have a Python package yet, but you can install from the source in a Python>=3.8 environment. Follow the steps below:

pip install https://github.com/A7medM0sta/soccer.git
pip install -r requirements.txt
./setup.sh

⚙️ Modes

🏟️ 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

🧑‍🤝‍🧑 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

⚽ 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

🏃‍♂️ 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

🏳️‍ 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

🎯 Radar Mode

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.

python main.py --source_video_path data/2e57b9_0.mp4 --target_video_path data/2e57b9_0-radar.mp4 --device mps --mode RADAR

References