Giter Site home page Giter Site logo

yskaaks / soccer-video-preprocess Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 1.46 GB

Given a full length soccer match video, this model gets rid of all frames that are not soccer game itself. Leaving only soccer playing frames ready for potential model training

Python 100.00%

soccer-video-preprocess's Introduction

Soccer Preprocessing Guide

This document outlines the setup and steps required to preprocess soccer match videos by removing unwanted segments, extracting relevant frames, and preparing data for model training

Environment Setup

  1. Create a Conda Environment
    Start by creating a new Conda environment named soccer-preprocess with Python 3.11 installed.

    conda create -n soccer-preprocess python=3.11 -y
    

    Activate the environment:

    conda activate soccer-preprocess
    
  2. Install PyTorch
    Install PyTorch, torchvision, torchaudio, and the corresponding CUDA toolkit version (e.g., for CUDA 11.7) using the commands below. Adjust the CUDA version based on your system's specifications.

    conda install pytorch==2.0.1 torchvision==0.15.2 torchaudio==2.0.2 pytorch-cuda=11.7 -c pytorch -c nvidia
    

    For different CUDA versions, refer to PyTorch's previous versions for guidance.

  3. Additional Dependencies
    Install other necessary Python packages:

    pip install ultralytics supervision moviepy scikit-learn
    

Video Preprocessing

  1. Trim Videos
    Remove pre-match programs and halftime advertisements by keeping only the match segments. For example, if the match is from 00:15:00 to 00:50:00 and 01:05:00 to 01:40:00, these segments are retained:

    python trim_videos.py /path/to/your/video.mp4 00:15:00-00:50:00 01:05:00-01:40:00
    

    Alternatively, you can use video editing software for this step. Store the trimmed videos in the initial-trimmed-videos directory.

  2. Extract Frames
    To extract frames from the videos, adjust the VIDEO_DIR_PATH and IMAGES_DIR_PATH in get_video_frames.py and run:

    python get_video_frames.py
    

    This saves every 300th frame, producing approximately 2000 images (~1000 images per video).

  3. Organize Frames
    Manually categorize the frames into relevant and irrelevant folders within a Data directory. Typically, use around 650 irrelevant frames and 950 relevant frames.

Data Preparation for Model Training

  1. Prepare Training Data
    Update the paths in prepare_training_data.py and execute it to split the data into training, testing, and validation sets.

  2. Model Training
    Navigate to the "Model Training" directory and initiate the training process:

    cd "Model Training"
    python train.py
    

Post-Training Processing

  1. Remove Irrelevant Frames
    Inside the Remove Irrelevant Frames directory, adjust the paths in script.py and run it to segregate videos into relevant and irrelevant frames.

  2. Remove Replays
    Manually record replay timestamps in text files (see Replay Timestamps folder for examples). Execute the following command to remove replays from videos:

    python remove_replays.py input_video_path output_video_path timestamps_file_path
    

This guide provides a comprehensive walkthrough for preprocessing soccer match videos, from environment setup to data preparation and model training. Follow each step carefully to ensure the successful completion of the process.

soccer-video-preprocess's People

Contributors

yskaaks 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.