Giter Club home page Giter Club logo

football_analysis_yolo's Introduction

Football Analysis System

This project uses machine learning, computer vision, and deep learning techniques to create a football analysis system. The main goals are:

  1. Detect and track players, referees, and the ball across video frames using object detection and tracking algorithms.
  2. Train a custom object detector to enhance the output of state-of-the-art models.
  3. Assign players to teams based on the color of their jerseys using K-means clustering for pixel segmentation.
  4. Analyze ball possession and control by assigning the ball to the closest player.
  5. Annotate output video with player IDs, teams, ball possession, and other relevant information.

Example output : Example

Installation & Setup

  1. Clone the repository
  2. Install required dependencies: pip install -r requirements.txt
  3. Train your model using the training notebook provided
  4. Download the model pt file and store in models folder
  5. Store the video to be analysed in the input folder

Usage

To run the analysis pipeline:

python main.py

This will process the specified input video, perform analysis, and generate an annotated output video in the output folder. If the video has been processed before, the code will use the previously generated pickle file to save time, instead of reprocessing the video from scratch.

Project Structure

  • main.py: The main entry point that orchestrates the analysis pipeline.
  • utils/: Contains utility functions for reading/writing videos and analysing them.
    • bbox_utils.py
    • helper.py
    • video.py
  • tracking/: Contains implementation of object tracking algorithms.
    • tracker.py
  • player_ball_assigner/: Contains logic for assigning the ball to the closest player.
    • player_ball_assigner.py
  • team_assigner/: Contains algorithms for assigning players to teams based on jersey color.
    • team_assigner.py
  • input/: Directory for input video files.
  • output/: Directory for annotated output videos.
  • models/: Directory for storing trained models.
  • stubs/: Directory for storing pre-computed tracking data. This is where the pkl files generated for a video are stored. If a new input with same filename is given, instead of computing the tracking data again, it uses the pkl files. (Can be turned off by setting "read_from_stub=False" in main.py)
  • development_and_analysis/: Contains notebooks for testing and analysis.
    • color_assignment.ipynb
  • training/: Contains model training notebook to be used separately from the project to generate weights of the model.
    • football_training.ipynb

Pipeline Overview

  1. Object Detection and Tracking: The Tracker class utilizes a pre-trained object detection model to detect players, referees, and the ball in each frame. It then tracks these objects across frames using tracking algorithms.

  2. Ball Interpolation: The ball might not be detected in some of the frames, hence, the missing ball positions are interpolated using the interpolate_ball_positions method to ensure smooth tracking throughout the video.

  3. Team Assignment: The TeamAssigner class segments player jersey colours using K-means clustering and assigns players to teams based on their jersey colours.

  4. Ball Assignment: The PlayerBallAssigner class determines the player closest to the ball and assigns ball possession accordingly.

  5. Annotation and Output: The processed frames are annotated with player IDs, teams, ball possession, and other relevant information. The annotated frames are then compiled into an output video file.

Acknowledgments

football_analysis_yolo's People

Contributors

kaustubh285 avatar

Stargazers

Mohamed Mandor avatar Karthik Pillai avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.