Davidsv commited on
Commit
6dd116b
·
verified ·
1 Parent(s): b7e38e6

Upload folder using huggingface_hub

Browse files
Files changed (5) hide show
  1. README.md +260 -0
  2. config.txt +5 -0
  3. example.py +17 -0
  4. model.pt +3 -0
  5. requirements.txt +5 -0
README.md ADDED
@@ -0,0 +1,260 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language: en
3
+ license: mit
4
+ tags:
5
+ - yolo
6
+ - yolov11
7
+ - object-detection
8
+ - tennis
9
+ - sports
10
+ - computer-vision
11
+ - pytorch
12
+ - ultralytics
13
+ datasets:
14
+ - custom
15
+ metrics:
16
+ - precision
17
+ - recall
18
+ - mAP
19
+ library_name: ultralytics
20
+ pipeline_tag: object-detection
21
+ ---
22
+
23
+ # YOLOv11 Tennis Ball Detection 🎾
24
+
25
+ Fine-tuned YOLOv11n model for detecting tennis balls in images and videos.
26
+
27
+ ## Model Details
28
+
29
+ - **Model Type**: Object Detection
30
+ - **Architecture**: YOLOv11 Nano (n)
31
+ - **Framework**: Ultralytics YOLOv11
32
+ - **Parameters**: 2.6M
33
+ - **Input Size**: 640x640
34
+ - **Classes**: 1 (`tennis_ball`)
35
+
36
+ ## Performance Metrics
37
+
38
+ Evaluated on validation set (62 images):
39
+
40
+ | Metric | Value |
41
+ |--------|-------|
42
+ | **mAP@50** | **67.87%** |
43
+ | **mAP@50-95** | 24.93% |
44
+ | **Precision** | 84.3% |
45
+ | **Recall** | 59.5% |
46
+ | **Inference Speed** (M4 Pro) | 10.3ms |
47
+
48
+ ## Training Details
49
+
50
+ ### Dataset
51
+ - **Training images**: 408
52
+ - **Validation images**: 62
53
+ - **Test images**: 50
54
+ - **Total**: 520 annotated images
55
+ - **Annotation format**: YOLO format (bounding boxes)
56
+
57
+ ### Training Configuration
58
+ ```yaml
59
+ Model: YOLOv11n (nano)
60
+ Epochs: 100
61
+ Batch size: 16
62
+ Image size: 640x640
63
+ Device: Apple M4 Pro (MPS)
64
+ Optimizer: AdamW
65
+ Learning rate: 0.001 → 0.01
66
+ Training time: ~23 minutes
67
+ ```
68
+
69
+ ### Augmentation
70
+ - HSV color jitter (h=0.015, s=0.7, v=0.4)
71
+ - Random horizontal flip (p=0.5)
72
+ - Translation (±10%)
73
+ - Scaling (±50%)
74
+ - Mosaic augmentation
75
+
76
+ ### Loss Weights
77
+ - Box loss: 7.5
78
+ - Class loss: 0.5
79
+ - DFL loss: 1.5
80
+
81
+ ## Usage
82
+
83
+ ### Installation
84
+
85
+ ```bash
86
+ pip install ultralytics
87
+ ```
88
+
89
+ ### Python API
90
+
91
+ ```python
92
+ from ultralytics import YOLO
93
+ from PIL import Image
94
+
95
+ # Load model
96
+ model = YOLO('path/to/tennis_ball_subset_best.pt')
97
+
98
+ # Predict on image
99
+ results = model.predict('tennis_match.jpg', conf=0.3)
100
+
101
+ # Display results
102
+ results[0].show()
103
+
104
+ # Get bounding boxes
105
+ for box in results[0].boxes:
106
+ x1, y1, x2, y2 = box.xyxy[0]
107
+ confidence = box.conf[0]
108
+ print(f"Ball detected at [{x1:.0f}, {y1:.0f}, {x2:.0f}, {y2:.0f}] with {confidence:.2%} confidence")
109
+ ```
110
+
111
+ ### Video Processing
112
+
113
+ ```python
114
+ from ultralytics import YOLO
115
+
116
+ model = YOLO('path/to/tennis_ball_subset_best.pt')
117
+
118
+ # Process video
119
+ results = model.predict(
120
+ source='tennis_match.mp4',
121
+ conf=0.3,
122
+ save=True,
123
+ save_txt=True
124
+ )
125
+ ```
126
+
127
+ ### Command Line
128
+
129
+ ```bash
130
+ # Predict on image
131
+ yolo detect predict model=tennis_ball_subset_best.pt source=image.jpg conf=0.3
132
+
133
+ # Predict on video
134
+ yolo detect predict model=tennis_ball_subset_best.pt source=video.mp4 conf=0.3 save=True
135
+
136
+ # Validate model
137
+ yolo detect val model=tennis_ball_subset_best.pt data=dataset.yaml
138
+ ```
139
+
140
+ ## Recommended Hyperparameters
141
+
142
+ ### Inference Settings
143
+
144
+ ```python
145
+ # Balanced (recommended)
146
+ conf_threshold = 0.30 # Confidence threshold
147
+ iou_threshold = 0.45 # NMS IoU threshold
148
+ max_det = 50 # Maximum detections per image
149
+
150
+ # High precision (fewer false positives)
151
+ conf_threshold = 0.50
152
+ iou_threshold = 0.45
153
+ max_det = 30
154
+
155
+ # High recall (detect more balls, more false positives)
156
+ conf_threshold = 0.20
157
+ iou_threshold = 0.40
158
+ max_det = 100
159
+ ```
160
+
161
+ ## Limitations
162
+
163
+ - **Small objects**: Performance may degrade for tennis balls that are very far from the camera (< 20px)
164
+ - **Motion blur**: Fast-moving balls may be harder to detect
165
+ - **Occlusion**: Partially hidden balls may not be detected
166
+ - **Similar objects**: May occasionally detect other small round objects
167
+ - **Lighting**: Optimized for outdoor tennis lighting conditions
168
+
169
+ ## Model Biases
170
+
171
+ - Trained primarily on standard yellow tennis balls
172
+ - Dataset includes various court types but may have dataset-specific biases
173
+ - Better performance on professional match footage vs amateur recordings
174
+
175
+ ## Use Cases
176
+
177
+ ✅ **Recommended:**
178
+ - Tennis match analysis
179
+ - Automated highlight generation
180
+ - Player training and coaching
181
+ - Sports analytics
182
+ - Ball tracking for statistics
183
+
184
+ ⚠️ **Not Recommended:**
185
+ - Real-time umpiring decisions (use as assistance only)
186
+ - Safety-critical applications
187
+ - Detection of non-yellow tennis balls without fine-tuning
188
+
189
+ ## Example Results
190
+
191
+ ### Sample Detections
192
+
193
+ **Precision: 84.3%** - When the model detects a ball, it's correct 84% of the time
194
+ **Recall: 59.5%** - The model detects approximately 6 out of 10 tennis balls
195
+
196
+ ### Confidence Interpretation
197
+
198
+ | Confidence Range | Interpretation |
199
+ |------------------|----------------|
200
+ | > 0.7 | High confidence - very likely a tennis ball |
201
+ | 0.5 - 0.7 | Medium confidence - probably a tennis ball |
202
+ | 0.3 - 0.5 | Low confidence - possible tennis ball |
203
+ | < 0.3 | Very low confidence - likely false positive |
204
+
205
+ ## Model Card Authors
206
+
207
+ - **Developed by**: Vuong
208
+ - **Model date**: November 2024
209
+ - **Model version**: 1.0
210
+ - **Model type**: Object Detection (YOLOv11)
211
+
212
+ ## Citation
213
+
214
+ If you use this model, please cite:
215
+
216
+ ```bibtex
217
+ @misc{yolov11_tennis_ball_2024,
218
+ title={YOLOv11 Tennis Ball Detection},
219
+ author={Vuong},
220
+ year={2024},
221
+ publisher={Hugging Face},
222
+ howpublished={\url{https://huggingface.co/...}}
223
+ }
224
+ ```
225
+
226
+ ## License
227
+
228
+ MIT License - Free for commercial and academic use.
229
+
230
+ ## Acknowledgments
231
+
232
+ - Built with [Ultralytics YOLOv11](https://github.com/ultralytics/ultralytics)
233
+ - Trained on custom annotated tennis dataset
234
+ - Part of the Tennis Analysis project
235
+
236
+ ## Contact & Support
237
+
238
+ For questions, issues, or collaboration:
239
+ - GitHub Issues: [tennis_analysis/issues](https://github.com/...)
240
+ - Model Updates: Check for newer versions on Hugging Face
241
+
242
+ ## Related Models
243
+
244
+ - [YOLOv11 Tennis Racket Detection](https://huggingface.co/...) - Companion model for racket detection
245
+
246
+ ## Model Changelog
247
+
248
+ ### v1.0 (2024-11-20)
249
+ - Initial release
250
+ - YOLOv11n architecture
251
+ - mAP@50: 67.87%
252
+ - 520 training images
253
+
254
+ ---
255
+
256
+ **Model Size**: 5.4 MB
257
+ **Inference Speed**: 10-65ms (device dependent)
258
+ **Supported Formats**: PyTorch (.pt), ONNX, TensorRT, CoreML
259
+
260
+ 🎾 Ready for production use in tennis analysis applications!
config.txt ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ # Configuration
2
+ model_name: tennis-ball-yolov11
3
+ framework: ultralytics
4
+ architecture: yolov11n
5
+ task: object-detection
example.py ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python
2
+ # Example usage for tennis-ball-yolov11
3
+
4
+ from ultralytics import YOLO
5
+
6
+ # Load model from local file
7
+ model = YOLO('model.pt')
8
+
9
+ # Or download from Hugging Face (after upload)
10
+ # model = YOLO('hf://YOUR_USERNAME/tennis-ball-yolov11/model.pt')
11
+
12
+ # Predict on image
13
+ results = model.predict('image.jpg', conf=0.3)
14
+ results[0].show()
15
+
16
+ # Predict on video
17
+ results = model.predict('video.mp4', conf=0.3, save=True)
model.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b780710e6b2b6a21b38d034dc42e5418d50f4c94abd733e7ba7da63322cb4785
3
+ size 5455194
requirements.txt ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ ultralytics>=8.0.0
2
+ torch>=2.0.0
3
+ opencv-python>=4.0.0
4
+ pillow>=9.0.0
5
+ numpy>=1.20.0