Adit-jain commited on
Commit
21dfd12
Β·
verified Β·
1 Parent(s): c64a721

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +215 -43
README.md CHANGED
@@ -20,23 +20,27 @@ datasets:
20
 
21
  # ⚽ SoccerNet Object Detection Model (YOLOv8)
22
 
23
- This repository hosts a **YOLOv8-based object detection model** trained on a curated and segmented dataset derived from SoccerNet and other public football datasets. The model is designed to detect key entities in a football game β€” **players**, **referees**, and the **ball** β€” with high accuracy, even in challenging scenes.
 
 
 
 
24
 
25
  ---
26
 
27
- ## πŸš€ Overview
 
 
 
 
 
 
 
 
 
 
 
28
 
29
- - **Architecture**: YOLOv8n + SAHI (Sliced Aided Hyper Inference)
30
- - **Input Size**: 1280x1280
31
- - **Epochs Trained**: 200
32
- - **Batch Size**: 32
33
- - **Classes**:
34
- - Player
35
- - Referee
36
- - Ball
37
- - **Formats**:
38
- - [βœ“] YOLOv8 format (Ultralytics)
39
- - [βœ“] COCO format (JSON)
40
 
41
  ---
42
 
@@ -51,44 +55,212 @@ Note : This sample uses Kmeans, UMAP and SIGLIP for team assignment. This does n
51
 
52
  ---
53
 
54
- ## 🧠 Capabilities
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
55
 
56
- - **Robust detection** of small objects like the ball across varied resolutions (160x160 to 1280x1080).
57
- - Works well on both standard game footage and camera-angled shots.
58
- - Can be **paired with**:
59
- - ⚽ **KMeans clustering** for team classification (with jersey color embeddings from SIGLIP).
60
- - πŸ“ˆ **Ball interpolation** for smooth ball trajectory tracking.
61
- - 🧠 Future integration with ByteTrack or BoT-SORT for player tracking.
 
 
 
 
 
 
 
 
 
 
62
 
63
  ---
64
 
65
- ## πŸ“¦ Training Details
66
-
67
- | Parameter | Value |
68
- |------------------|------------------|
69
- | Epochs | 200 |
70
- | Batch Size | 32 |
71
- | Image Size | 1280 |
72
- | Optimizer | Auto |
73
- | Pretrained | True |
74
- | Seed | 44 |
75
- | Det. Inference | True |
76
- | Dropout | 0.3 |
77
- | Patience | 100 (early stop) |
78
- | iOU Threshold | 0.7 |
79
- | Augmentations | RandAugment + Erasing |
80
- | AutoAugment | Enabled |
81
- | Mosaic | On |
82
- | Flip LR | 50% |
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
83
 
84
  ---
85
 
86
- ## 🧾 How to Use
87
- A detailed guide and code can be found at [github](https://github.com/Adit-jain/Soccer_Analysis)
88
 
89
- ## 🧊 Notes
90
- Model supports sliced image inference using SAHI, optimized for high-resolution input.
91
- Ideal for sports analytics, heatmaps, player positioning, and advanced tracking systems.
92
 
93
 
94
 
 
20
 
21
  # ⚽ SoccerNet Object Detection Model (YOLOv8)
22
 
23
+ 1. [Introduction](#introduction)
24
+ 2. [Demo](#demo)
25
+ 3. [Model Capabilities](#model-capabilities)
26
+ 4. [Architecture & Technical Specifications](#architecture--technical-specifications)
27
+ 5. [Implementation & Usage](#implementation--usage)
28
 
29
  ---
30
 
31
+ ## Introduction
32
+
33
+ The **Soccer Object Detection Model** is a computer vision solution specifically designed for comprehensive soccer video analysis. Built upon the **YOLOv11n** architecture and trained on a meticulously curated multi-source dataset, this model provides real-time detection of players, balls, and referees in soccer videos across diverse conditions and environments.
34
+
35
+ This model serves as the foundation for the complete Soccer Analysis Pipeline, enabling advanced capabilities such as player tracking, team assignment, tactical analysis, and performance metrics extraction.
36
+
37
+ ### Key Features
38
+ - **Multi-class Detection**: Simultaneous detection of players, balls, and referees
39
+ - **Real-time Performance**: Optimized for live video analysis (30+ FPS)
40
+ - **Scale-Invariant**: Effective detection across different camera distances and angles
41
+ - **Robust Performance**: Trained on diverse datasets with varying lighting, weather, and field conditions
42
+ - **EdgeCase-Optimized**: Specifically fine-tuned for soccer scenarios and edge cases
43
 
 
 
 
 
 
 
 
 
 
 
 
44
 
45
  ---
46
 
 
55
 
56
  ---
57
 
58
+ ## Model Capabilities
59
+
60
+ ### Detection Classes
61
+ The model is trained to detect three primary object classes with high accuracy:
62
+
63
+ | Class ID | Object Type | Description | Use Case |
64
+ |----------|-------------|-------------|----------|
65
+ | **0** | **Player** | Soccer players from both teams including goalkeepers | Primary tracking target, team assignment, tactical analysis |
66
+ | **1** | **Ball** | Soccer ball in various states (rolling, airborne, stationary) | Possession tracking, game flow analysis, event detection |
67
+ | **2** | **Referee** | Match officials including referees and linesmen | Contextual differentiation, avoiding tracking confusion |
68
+
69
+ ### Multi-Scale Detection
70
+ - **Close-up Shots**: High-precision detection in detailed player views
71
+ - **Medium Shots**: Balanced detection for tactical analysis
72
+ - **Wide-angle Views**: Full-field coverage with consistent detection quality
73
+ - **Aerial Views**: Drone and elevated camera perspectives
74
 
75
+ ### Environmental Robustness
76
+ - **Lighting Conditions**: Day games, evening matches, indoor venues, stadium lighting
77
+ - **Weather Conditions**: Clear weather, rain, snow, fog conditions
78
+ - **Field Surfaces**: Natural grass, artificial turf, different field conditions
79
+ - **Camera Angles**: Sideline, goal-line, elevated, broadcast standard angles
80
+
81
+ ### Real-world Scenarios
82
+ - **Crowded Scenes**: Penalty area situations with multiple overlapping players
83
+ - **Occlusion Handling**: Partially visible players and objects
84
+ - **Motion Blur**: Fast-moving players and ball tracking
85
+ - **Scale Variation**: Players at different distances from camera
86
+
87
+ ### Performance Characteristics
88
+ - **Detection Accuracy**: High precision with minimal false positives
89
+ - **Processing Speed**: Real-time capable (30+ FPS on modern GPUs)
90
+ - **Memory Efficiency**: Optimized for continuous video processing
91
 
92
  ---
93
 
94
+ ## Architecture & Technical Specifications
95
+
96
+ ### Base Architecture: YOLOv11n
97
+
98
+ **YOLOv11n** (You Only Look Once version 11, nano variant) serves as the foundation architecture, providing an optimal balance between accuracy and computational efficiency.
99
+
100
+ ### Dataset
101
+ [Soccana_player_ball_detection_v1](https://huggingface.co/datasets/Adit-jain/Soccana_player_ball_detection_v1)
102
+
103
+ The dataset covers various Edge cases like:
104
+ - Occlusions
105
+ - Close up shots
106
+ - Behind the goalpost scenes
107
+ - Camera overlay scenes
108
+ - Low and High angle shots
109
+ - Various Resolution shots (160, 320, 540, 1280)
110
+
111
+ ### Training Configuration
112
+
113
+ The model training follows an optimized configuration designed for soccer-specific detection tasks:
114
+
115
+ ```python
116
+ # Core Training Parameters
117
+ epochs = 200 # Extended training for convergence
118
+ img_size = 1280 # High-resolution input (1280x1280)
119
+ batch_size = 32 # Optimal batch size for 1280 resolution
120
+ workers = 8 # Multi-threaded data loading
121
+
122
+ # Learning Rate Schedule
123
+ lr0 = 0.01 # Initial learning rate
124
+ lrf = 0.01 # Final learning rate (no decay)
125
+ momentum = 0.937 # SGD momentum
126
+ weight_decay = 0.0005 # L2 regularization
127
+
128
+ # Regularization & Augmentation
129
+ dropout = 0.3 # Dropout rate for overfitting prevention
130
+ augmentation_probability = 0.5 # Data augmentation frequency
131
+ ```
132
+
133
+ ### Advanced Training Settings
134
+
135
+ #### **Augmentation Strategy**
136
+ ```python
137
+ # Photometric Augmentations
138
+ hsv_h = 0.015 # Hue augmentation range
139
+ hsv_s = 0.7 # Saturation augmentation range
140
+ hsv_v = 0.4 # Value augmentation range
141
+
142
+ # Geometric Augmentations
143
+ degrees = 0.0 # Rotation range (disabled for sports)
144
+ translate = 0.1 # Translation augmentation
145
+ scale = 0.5 # Scale augmentation range
146
+ shear = 0.0 # Shear transformation (disabled)
147
+
148
+ # Advanced Augmentations
149
+ mosaic = 1.0 # Mosaic augmentation probability
150
+ mixup = 0.0 # Mixup augmentation (disabled)
151
+ copy_paste = 0.0 # Copy-paste augmentation (disabled)
152
+ ```
153
+
154
+ #### **Loss Function Configuration**
155
+ ```python
156
+ # Detection Loss Components
157
+ box_loss_gain = 0.05 # Bounding box loss weight
158
+ cls_loss_gain = 0.5 # Classification loss weight
159
+ dfl_loss_gain = 1.5 # Distribution focal loss weight
160
+
161
+ # Focal Loss Parameters
162
+ fl_gamma = 0.0 # Focal loss gamma (disabled)
163
+ label_smoothing = 0.0 # Label smoothing factor
164
+ ```
165
+
166
+ #### **Optimizer Settings**
167
+ ```python
168
+ optimizer = "SGD" # Stochastic Gradient Descent
169
+ nbs = 64 # Nominal batch size for scaling
170
+ warmup_epochs = 3.0 # Learning rate warmup period
171
+ warmup_momentum = 0.8 # Warmup momentum
172
+ warmup_bias_lr = 0.1 # Warmup bias learning rate
173
+ ```
174
+
175
+ ### Model Architecture Parameters
176
+
177
+ #### **Backbone Configuration**
178
+ ```python
179
+ depth_multiple = 0.33 # Model depth scaling factor (nano)
180
+ width_multiple = 0.25 # Model width scaling factor (nano)
181
+ max_channels = 1024 # Maximum channel count
182
+ ```
183
+
184
+ #### **Detection Head Settings**
185
+ ```python
186
+ anchors = None # Anchor-free detection
187
+ nc = 3 # Number of classes (Player, Ball, Referee)
188
+ conf_threshold = 0.25 # Confidence threshold for detection
189
+ iou_threshold = 0.45 # IoU threshold for NMS
190
+ max_det = 300 # Maximum detections per image
191
+ ```
192
+
193
+ ### Hardware Optimization
194
+
195
+ #### **GPU Configuration**
196
+ ```python
197
+ device = "cuda" # GPU acceleration
198
+ multi_gpu = True # Multi-GPU training support
199
+ amp = True # Automatic Mixed Precision
200
+ half = False # FP16 inference (disabled during training)
201
+ ```
202
+
203
+ #### **Memory Management**
204
+ ```python
205
+ cache = "ram" # Dataset caching strategy
206
+ save_memory = False # Memory optimization mode
207
+ rect = False # Rectangular training (disabled)
208
+ ```
209
+
210
+ ---
211
+
212
+ ## Implementation & Usage
213
+
214
+ ### Model Integration Points
215
+
216
+ The Soccer Object Detection Model is seamlessly integrated throughout the Soccer Analysis Pipeline:
217
+
218
+ #### **Core Detection Module** (`player_detection/`)
219
+
220
+ ```python
221
+ from player_detection import load_detection_model, get_detections
222
+ import supervision as sv
223
+
224
+ # Load the trained model
225
+ model = load_detection_model("Models/Trained/yolov11_sahi_1280/Model/weights/best.pt")
226
+
227
+ # Perform detection on a frame
228
+ player_detections, ball_detections, referee_detections = get_detections(model, frame)
229
+
230
+ # Results are returned as supervision.Detections objects with:
231
+ # - Bounding boxes in [x1, y1, x2, y2] format
232
+ # - Confidence scores for each detection
233
+ # - Class IDs (0=Player, 1=Ball, 2=Referee)
234
+ ```
235
+
236
+ #### **Pipeline Integration** (`pipelines/detection_pipeline.py`)
237
+
238
+ ```python
239
+ from pipelines import DetectionPipeline
240
+
241
+ # Initialize detection pipeline
242
+ pipeline = DetectionPipeline(model_path)
243
+
244
+ # Video-based detection
245
+ pipeline.detect_in_video("input.mp4", "output_detected.mp4", frame_count=300)
246
+
247
+ # Real-time detection
248
+ pipeline.detect_realtime("input.mp4") # or webcam index: 0
249
+
250
+ # Frame-level detection
251
+ player_det, ball_det, ref_det = pipeline.detect_frame_objects(frame)
252
+ annotated_frame = pipeline.annotate_detections(frame, player_det, ball_det, ref_det)
253
+ ```
254
+
255
+ ### A detailed guide and code can be found at **[github](https://github.com/Adit-jain/Soccer_Analysis)**
256
 
257
  ---
258
 
259
+ *Quick Links*
 
260
 
261
+ **πŸ”— Repository**: [https://github.com/Adit-jain/Soccer_Analysis](https://github.com/Adit-jain/Soccer_Analysis)
262
+ **πŸ“Š Dataset**: [https://huggingface.co/datasets/Adit-jain/Soccana_player_ball_detection_v1](https://huggingface.co/datasets/Adit-jain/Soccana_player_ball_detection_v1)
263
+ **πŸ€– Model**: [https://huggingface.co/Adit-jain/soccana](https://huggingface.co/Adit-jain/soccana)
264
 
265
 
266