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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
language: en
|
| 3 |
+
license: mit
|
| 4 |
+
tags:
|
| 5 |
+
- yolo
|
| 6 |
+
- yolov11
|
| 7 |
+
- object-detection
|
| 8 |
+
- tennis
|
| 9 |
+
- racket
|
| 10 |
+
- sports
|
| 11 |
+
- computer-vision
|
| 12 |
+
- pytorch
|
| 13 |
+
- ultralytics
|
| 14 |
+
datasets:
|
| 15 |
+
- custom
|
| 16 |
+
metrics:
|
| 17 |
+
- precision
|
| 18 |
+
- recall
|
| 19 |
+
- mAP
|
| 20 |
+
library_name: ultralytics
|
| 21 |
+
pipeline_tag: object-detection
|
| 22 |
+
---
|
| 23 |
+
|
| 24 |
+
# YOLOv11 Tennis Racket Detection 🎾
|
| 25 |
+
|
| 26 |
+
Fine-tuned YOLOv11n model for detecting tennis rackets in images and videos.
|
| 27 |
+
|
| 28 |
+
## Model Details
|
| 29 |
+
|
| 30 |
+
- **Model Type**: Object Detection
|
| 31 |
+
- **Architecture**: YOLOv11 Nano (n)
|
| 32 |
+
- **Framework**: Ultralytics YOLOv11
|
| 33 |
+
- **Parameters**: 2.6M
|
| 34 |
+
- **Input Size**: 640x640
|
| 35 |
+
- **Classes**: 1 (`racket`)
|
| 36 |
+
|
| 37 |
+
## Performance Metrics
|
| 38 |
+
|
| 39 |
+
Evaluated on validation set (66 images):
|
| 40 |
+
|
| 41 |
+
| Metric | Value |
|
| 42 |
+
|--------|-------|
|
| 43 |
+
| **mAP@50** | **66.67%** |
|
| 44 |
+
| **mAP@50-95** | 33.33% |
|
| 45 |
+
| **Precision** | ~71% (estimated) |
|
| 46 |
+
| **Recall** | ~44% (estimated) |
|
| 47 |
+
| **Inference Speed** (M4 Pro) | ~10ms |
|
| 48 |
+
|
| 49 |
+
## Training Details
|
| 50 |
+
|
| 51 |
+
### Dataset
|
| 52 |
+
- **Training images**: 582
|
| 53 |
+
- **Validation images**: 66
|
| 54 |
+
- **Test images**: 55
|
| 55 |
+
- **Total**: 703 annotated images
|
| 56 |
+
- **Annotation format**: YOLO format (bounding boxes)
|
| 57 |
+
|
| 58 |
+
### Training Configuration
|
| 59 |
+
```yaml
|
| 60 |
+
Model: YOLOv11n (nano)
|
| 61 |
+
Epochs: 100
|
| 62 |
+
Batch size: 16
|
| 63 |
+
Image size: 640x640
|
| 64 |
+
Device: Apple M4 Pro (MPS)
|
| 65 |
+
Optimizer: AdamW
|
| 66 |
+
Learning rate: 0.001 → 0.01
|
| 67 |
+
Training time: ~26 minutes
|
| 68 |
+
```
|
| 69 |
+
|
| 70 |
+
### Augmentation
|
| 71 |
+
- HSV color jitter (h=0.015, s=0.7, v=0.4)
|
| 72 |
+
- Random horizontal flip (p=0.5)
|
| 73 |
+
- Translation (±10%)
|
| 74 |
+
- Scaling (±50%)
|
| 75 |
+
- Mosaic augmentation
|
| 76 |
+
|
| 77 |
+
### Loss Weights
|
| 78 |
+
- Box loss: 7.5
|
| 79 |
+
- Class loss: 0.5
|
| 80 |
+
- DFL loss: 1.5
|
| 81 |
+
|
| 82 |
+
## Usage
|
| 83 |
+
|
| 84 |
+
### Installation
|
| 85 |
+
|
| 86 |
+
```bash
|
| 87 |
+
pip install ultralytics
|
| 88 |
+
```
|
| 89 |
+
|
| 90 |
+
### Python API
|
| 91 |
+
|
| 92 |
+
```python
|
| 93 |
+
from ultralytics import YOLO
|
| 94 |
+
from PIL import Image
|
| 95 |
+
|
| 96 |
+
# Load model
|
| 97 |
+
model = YOLO('path/to/raquette_subset_best.pt')
|
| 98 |
+
|
| 99 |
+
# Predict on image
|
| 100 |
+
results = model.predict('tennis_match.jpg', conf=0.4)
|
| 101 |
+
|
| 102 |
+
# Display results
|
| 103 |
+
results[0].show()
|
| 104 |
+
|
| 105 |
+
# Get bounding boxes
|
| 106 |
+
for box in results[0].boxes:
|
| 107 |
+
x1, y1, x2, y2 = box.xyxy[0]
|
| 108 |
+
confidence = box.conf[0]
|
| 109 |
+
print(f"Racket detected at [{x1:.0f}, {y1:.0f}, {x2:.0f}, {y2:.0f}] with {confidence:.2%} confidence")
|
| 110 |
+
```
|
| 111 |
+
|
| 112 |
+
### Video Processing
|
| 113 |
+
|
| 114 |
+
```python
|
| 115 |
+
from ultralytics import YOLO
|
| 116 |
+
|
| 117 |
+
model = YOLO('path/to/raquette_subset_best.pt')
|
| 118 |
+
|
| 119 |
+
# Process video
|
| 120 |
+
results = model.predict(
|
| 121 |
+
source='tennis_match.mp4',
|
| 122 |
+
conf=0.4,
|
| 123 |
+
save=True,
|
| 124 |
+
save_txt=True
|
| 125 |
+
)
|
| 126 |
+
|
| 127 |
+
# Track rackets across frames
|
| 128 |
+
results = model.track(
|
| 129 |
+
source='tennis_match.mp4',
|
| 130 |
+
conf=0.4,
|
| 131 |
+
tracker='bytetrack.yaml'
|
| 132 |
+
)
|
| 133 |
+
```
|
| 134 |
+
|
| 135 |
+
### Command Line
|
| 136 |
+
|
| 137 |
+
```bash
|
| 138 |
+
# Predict on image
|
| 139 |
+
yolo detect predict model=raquette_subset_best.pt source=image.jpg conf=0.4
|
| 140 |
+
|
| 141 |
+
# Predict on video
|
| 142 |
+
yolo detect predict model=raquette_subset_best.pt source=video.mp4 conf=0.4 save=True
|
| 143 |
+
|
| 144 |
+
# Track rackets in video
|
| 145 |
+
yolo detect track model=raquette_subset_best.pt source=video.mp4 conf=0.4
|
| 146 |
+
|
| 147 |
+
# Validate model
|
| 148 |
+
yolo detect val model=raquette_subset_best.pt data=dataset.yaml
|
| 149 |
+
```
|
| 150 |
+
|
| 151 |
+
## Recommended Hyperparameters
|
| 152 |
+
|
| 153 |
+
### Inference Settings
|
| 154 |
+
|
| 155 |
+
```python
|
| 156 |
+
# Balanced (recommended)
|
| 157 |
+
conf_threshold = 0.40 # Confidence threshold
|
| 158 |
+
iou_threshold = 0.45 # NMS IoU threshold
|
| 159 |
+
max_det = 10 # Maximum detections per image (usually 2-4 rackets)
|
| 160 |
+
|
| 161 |
+
# High precision (fewer false positives)
|
| 162 |
+
conf_threshold = 0.55
|
| 163 |
+
iou_threshold = 0.45
|
| 164 |
+
max_det = 8
|
| 165 |
+
|
| 166 |
+
# High recall (detect more rackets, more false positives)
|
| 167 |
+
conf_threshold = 0.30
|
| 168 |
+
iou_threshold = 0.40
|
| 169 |
+
max_det = 15
|
| 170 |
+
```
|
| 171 |
+
|
| 172 |
+
## Limitations
|
| 173 |
+
|
| 174 |
+
- **Motion blur**: Rackets in very fast motion may be harder to detect
|
| 175 |
+
- **Occlusion**: Partially hidden rackets (behind player, net, etc.) may not be detected
|
| 176 |
+
- **Angles**: Extreme viewing angles may reduce detection accuracy
|
| 177 |
+
- **Racket types**: Trained on standard tennis rackets, may not generalize to unusual designs
|
| 178 |
+
- **Similar objects**: May occasionally detect similar elongated objects
|
| 179 |
+
|
| 180 |
+
## Model Biases
|
| 181 |
+
|
| 182 |
+
- Trained on professional and amateur match footage
|
| 183 |
+
- Better performance on standard racket designs and colors
|
| 184 |
+
- Dataset may have court-type or player-level biases
|
| 185 |
+
- Optimized for typical tennis camera angles
|
| 186 |
+
|
| 187 |
+
## Use Cases
|
| 188 |
+
|
| 189 |
+
✅ **Recommended:**
|
| 190 |
+
- Tennis match analysis
|
| 191 |
+
- Player technique analysis
|
| 192 |
+
- Swing detection and tracking
|
| 193 |
+
- Automated coaching feedback
|
| 194 |
+
- Sports analytics and statistics
|
| 195 |
+
- Training video analysis
|
| 196 |
+
|
| 197 |
+
⚠️ **Not Recommended:**
|
| 198 |
+
- Real-time officiating decisions
|
| 199 |
+
- Safety-critical applications
|
| 200 |
+
- Detection of non-tennis rackets without fine-tuning
|
| 201 |
+
|
| 202 |
+
## Example Results
|
| 203 |
+
|
| 204 |
+
### Sample Detections
|
| 205 |
+
|
| 206 |
+
**mAP@50: 66.67%** - Good detection performance on typical tennis scenes
|
| 207 |
+
**Precision: ~71%** - When detected, about 7 out of 10 detections are correct
|
| 208 |
+
|
| 209 |
+
### Confidence Interpretation
|
| 210 |
+
|
| 211 |
+
| Confidence Range | Interpretation |
|
| 212 |
+
|------------------|----------------|
|
| 213 |
+
| > 0.7 | High confidence - very likely a tennis racket |
|
| 214 |
+
| 0.5 - 0.7 | Medium confidence - probably a tennis racket |
|
| 215 |
+
| 0.4 - 0.5 | Low confidence - possible tennis racket |
|
| 216 |
+
| < 0.4 | Very low confidence - likely false positive |
|
| 217 |
+
|
| 218 |
+
## Integration with Tennis Ball Detection
|
| 219 |
+
|
| 220 |
+
This model works well in combination with the Tennis Ball Detection model:
|
| 221 |
+
|
| 222 |
+
```python
|
| 223 |
+
from ultralytics import YOLO
|
| 224 |
+
|
| 225 |
+
# Load both models
|
| 226 |
+
model_racket = YOLO('raquette_subset_best.pt')
|
| 227 |
+
model_ball = YOLO('tennis_ball_subset_best.pt')
|
| 228 |
+
|
| 229 |
+
# Detect both in same image
|
| 230 |
+
racket_results = model_racket.predict('match.jpg', conf=0.4)
|
| 231 |
+
ball_results = model_ball.predict('match.jpg', conf=0.3)
|
| 232 |
+
|
| 233 |
+
# Combine detections for analysis
|
| 234 |
+
print(f"Rackets: {len(racket_results[0].boxes)}")
|
| 235 |
+
print(f"Balls: {len(ball_results[0].boxes)}")
|
| 236 |
+
```
|
| 237 |
+
|
| 238 |
+
## Advanced Usage
|
| 239 |
+
|
| 240 |
+
### Detect Player Actions
|
| 241 |
+
|
| 242 |
+
```python
|
| 243 |
+
from ultralytics import YOLO
|
| 244 |
+
import cv2
|
| 245 |
+
|
| 246 |
+
model = YOLO('raquette_subset_best.pt')
|
| 247 |
+
video = cv2.VideoCapture('match.mp4')
|
| 248 |
+
|
| 249 |
+
frame_count = 0
|
| 250 |
+
racket_positions = []
|
| 251 |
+
|
| 252 |
+
while True:
|
| 253 |
+
ret, frame = video.read()
|
| 254 |
+
if not ret:
|
| 255 |
+
break
|
| 256 |
+
|
| 257 |
+
# Detect rackets
|
| 258 |
+
results = model.predict(frame, conf=0.4, verbose=False)
|
| 259 |
+
|
| 260 |
+
# Track racket movement
|
| 261 |
+
for box in results[0].boxes:
|
| 262 |
+
x1, y1, x2, y2 = box.xyxy[0]
|
| 263 |
+
center_x = (x1 + x2) / 2
|
| 264 |
+
center_y = (y1 + y2) / 2
|
| 265 |
+
racket_positions.append((frame_count, center_x, center_y))
|
| 266 |
+
|
| 267 |
+
frame_count += 1
|
| 268 |
+
|
| 269 |
+
# Analyze swing patterns
|
| 270 |
+
print(f"Total racket detections: {len(racket_positions)}")
|
| 271 |
+
```
|
| 272 |
+
|
| 273 |
+
## Model Card Authors
|
| 274 |
+
|
| 275 |
+
- **Developed by**: Vuong
|
| 276 |
+
- **Model date**: November 2024
|
| 277 |
+
- **Model version**: 1.0
|
| 278 |
+
- **Model type**: Object Detection (YOLOv11)
|
| 279 |
+
|
| 280 |
+
## Citation
|
| 281 |
+
|
| 282 |
+
If you use this model, please cite:
|
| 283 |
+
|
| 284 |
+
```bibtex
|
| 285 |
+
@misc{yolov11_tennis_racket_2024,
|
| 286 |
+
title={YOLOv11 Tennis Racket Detection},
|
| 287 |
+
author={Vuong},
|
| 288 |
+
year={2024},
|
| 289 |
+
publisher={Hugging Face},
|
| 290 |
+
howpublished={\url{https://huggingface.co/...}}
|
| 291 |
+
}
|
| 292 |
+
```
|
| 293 |
+
|
| 294 |
+
## License
|
| 295 |
+
|
| 296 |
+
MIT License - Free for commercial and academic use.
|
| 297 |
+
|
| 298 |
+
## Acknowledgments
|
| 299 |
+
|
| 300 |
+
- Built with [Ultralytics YOLOv11](https://github.com/ultralytics/ultralytics)
|
| 301 |
+
- Trained on custom annotated tennis dataset
|
| 302 |
+
- Part of the Tennis Analysis project
|
| 303 |
+
|
| 304 |
+
## Contact & Support
|
| 305 |
+
|
| 306 |
+
For questions, issues, or collaboration:
|
| 307 |
+
- GitHub Issues: [tennis_analysis/issues](https://github.com/...)
|
| 308 |
+
- Model Updates: Check for newer versions on Hugging Face
|
| 309 |
+
|
| 310 |
+
## Related Models
|
| 311 |
+
|
| 312 |
+
- [YOLOv11 Tennis Ball Detection](https://huggingface.co/...) - Companion model for ball detection
|
| 313 |
+
|
| 314 |
+
## Common Issues & Solutions
|
| 315 |
+
|
| 316 |
+
### Issue: Low Recall
|
| 317 |
+
**Solution**: Lower confidence threshold to 0.30-0.35
|
| 318 |
+
|
| 319 |
+
### Issue: Too Many False Positives
|
| 320 |
+
**Solution**: Increase confidence threshold to 0.50-0.55
|
| 321 |
+
|
| 322 |
+
### Issue: Missed Rackets in Motion
|
| 323 |
+
**Solution**: Use model tracking (`model.track()`) instead of simple prediction
|
| 324 |
+
|
| 325 |
+
### Issue: Multiple Detections per Racket
|
| 326 |
+
**Solution**: Increase NMS IoU threshold to 0.50-0.55
|
| 327 |
+
|
| 328 |
+
## Model Changelog
|
| 329 |
+
|
| 330 |
+
### v1.0 (2024-11-20)
|
| 331 |
+
- Initial release
|
| 332 |
+
- YOLOv11n architecture
|
| 333 |
+
- mAP@50: 66.67%
|
| 334 |
+
- 703 training images
|
| 335 |
+
|
| 336 |
+
---
|
| 337 |
+
|
| 338 |
+
**Model Size**: 5.4 MB
|
| 339 |
+
**Inference Speed**: 10-65ms (device dependent)
|
| 340 |
+
**Supported Formats**: PyTorch (.pt), ONNX, TensorRT, CoreML
|
| 341 |
+
|
| 342 |
+
🎾 Ready for production use in tennis analysis applications!
|
config.txt
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Configuration
|
| 2 |
+
model_name: tennis-racket-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-racket-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-racket-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:4ee842b864d5c4e5baae8239889ed416a29b6550a7a1b2cc2f4774550194e35b
|
| 3 |
+
size 5453978
|
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
|