How ankitk75/football-player-reid works
Project Type and Purpose
• This is a computer‐vision pipeline for video analytics: it ingests football broadcast footage, runs object detection (players, referees, ball) using a fine-tuned YOLOv8 model, and performs visual re-identification to maintain consistent player IDs across frames.
• Key use cases: real-time frame processing, detection visualization, identity tracking across occlusions, and output generation.
File Structure
• Top-level scripts:
• detect.py – runs detection and outputs annotated frames/video
• track_with_global_reid.py – runs re-identification and tracking
• assets/ – input video(s) and model weights (best.pt)
• output/ – stores detected_frames/, detected_video_custom_resize.mp4, tracked_frames/, tracked_video_reid_final_resize.mp4
• requirements.txt – lists dependencies (OpenCV, Ultralytics YOLO, Torch, Torchreid, etc.)
README for Additional Insights
• Detection threshold and fallback to CPU if no GPU.
• Pipeline stages: Load model → Detect objects → Extract feature embeddings → Compute cosine similarities → Associate IDs → Render outputs.
Main Components
a. Video Input Component
• Source: assets/15sec_input_720p.mp4
• Preprocessor: OpenCV frame extraction
b. Object Detection Component
• YOLOv8 model (best.pt) loaded via Ultralytics
c. Feature Embedding / Re-ID Component
• Torchreid module computes feature vectors per detection
• Cosine similarity metric from scikit-learn
d. Tracking & Association Component
• Global tracker that maintains ID assignments across frames
• Handles occlusion, re-entry
e. Output Rendering & Storage
• Annotated frames → output/detected_frames or tracked_frames
• Compiled videos → output/detected_video_custom_resize.mp4, output/tracked_video_reid_final_resize.mp4
Relationships & Data Flow
• Optionally, loop back for next frame processing until end of video
Architectural Patterns & Principles
• Pipeline model: Each stage is a separate processing module
• Modularity: detection and re-ID are independent stages for easy replacement or upgrade
• GPU acceleration fallback: conditional execution path
Technologies, Frameworks, Libraries
• OpenCV for video I/O and frame handling
• Ultralytics YOLOv8 for detection
• PyTorch & TorchVision for model inference
• Torchreid for feature extraction
• scikit-learn for similarity computation
• Pillow, NumPy for image manipulation
Final Touches
• Every component is labeled, no overlaps