Upload README.md with huggingface_hub
Browse files
README.md
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
tags:
|
| 3 |
+
- keypoint-detection
|
| 4 |
+
- sports
|
| 5 |
+
- football
|
| 6 |
+
- soccer
|
| 7 |
+
- roboflow
|
| 8 |
+
- yolov8
|
| 9 |
+
license: mit
|
| 10 |
+
---
|
| 11 |
+
|
| 12 |
+
# Football Field Keypoint Detection (Roboflow)
|
| 13 |
+
|
| 14 |
+
YOLOv8 keypoint detection model for identifying field lines and key points on a football/soccer pitch.
|
| 15 |
+
|
| 16 |
+
## Model Details
|
| 17 |
+
|
| 18 |
+
- **Model ID**: `football-field-detection-f07vi/14`
|
| 19 |
+
- **Platform**: Roboflow
|
| 20 |
+
- **Architecture**: YOLOv8 Pose
|
| 21 |
+
- **Task**: Keypoint detection
|
| 22 |
+
|
| 23 |
+
## Quick Start
|
| 24 |
+
|
| 25 |
+
### Installation
|
| 26 |
+
|
| 27 |
+
```bash
|
| 28 |
+
pip install inference-gpu # or inference for CPU
|
| 29 |
+
pip install supervision
|
| 30 |
+
```
|
| 31 |
+
|
| 32 |
+
### Basic Usage
|
| 33 |
+
|
| 34 |
+
```python
|
| 35 |
+
from inference import get_model
|
| 36 |
+
import supervision as sv
|
| 37 |
+
|
| 38 |
+
# Initialize model
|
| 39 |
+
api_key = "YOUR_ROBOFLOW_API_KEY"
|
| 40 |
+
model = get_model(
|
| 41 |
+
model_id="football-field-detection-f07vi/14",
|
| 42 |
+
api_key=api_key
|
| 43 |
+
)
|
| 44 |
+
|
| 45 |
+
# Run inference
|
| 46 |
+
result = model.infer("image.jpg", confidence=0.3)[0]
|
| 47 |
+
key_points = sv.KeyPoints.from_inference(result)
|
| 48 |
+
|
| 49 |
+
print(f"Detected {len(key_points.xy[0])} keypoints")
|
| 50 |
+
```
|
| 51 |
+
|
| 52 |
+
### Using the Wrapper
|
| 53 |
+
|
| 54 |
+
```python
|
| 55 |
+
from field_inference import FootballFieldDetector
|
| 56 |
+
import os
|
| 57 |
+
|
| 58 |
+
detector = FootballFieldDetector(api_key=os.getenv("ROBOFLOW_API_KEY"))
|
| 59 |
+
results = detector.predict("image.jpg", confidence=0.3)
|
| 60 |
+
```
|
| 61 |
+
|
| 62 |
+
## Applications
|
| 63 |
+
|
| 64 |
+
- **Homography Estimation**: Map player positions to tactical view
|
| 65 |
+
- **Camera Calibration**: Align multiple camera views
|
| 66 |
+
- **Tactical Analysis**: Project player movements on 2D pitch
|
| 67 |
+
- **AR Overlays**: Augmented reality graphics on field
|
| 68 |
+
- **Voronoi Diagrams**: Team possession and control analysis
|
| 69 |
+
|
| 70 |
+
## Example: View Transformation
|
| 71 |
+
|
| 72 |
+
```python
|
| 73 |
+
import numpy as np
|
| 74 |
+
from sports.common.view import ViewTransformer
|
| 75 |
+
from sports.configs.soccer import SoccerPitchConfiguration
|
| 76 |
+
|
| 77 |
+
# Get field keypoints
|
| 78 |
+
result = model.infer(frame, confidence=0.3)[0]
|
| 79 |
+
key_points = sv.KeyPoints.from_inference(result)
|
| 80 |
+
|
| 81 |
+
# Filter confident keypoints
|
| 82 |
+
filter = key_points.confidence[0] > 0.5
|
| 83 |
+
frame_points = key_points.xy[0][filter]
|
| 84 |
+
|
| 85 |
+
# Create transformer
|
| 86 |
+
config = SoccerPitchConfiguration()
|
| 87 |
+
pitch_points = np.array(config.vertices)[filter]
|
| 88 |
+
|
| 89 |
+
transformer = ViewTransformer(
|
| 90 |
+
source=frame_points,
|
| 91 |
+
target=pitch_points
|
| 92 |
+
)
|
| 93 |
+
|
| 94 |
+
# Transform player positions to pitch coordinates
|
| 95 |
+
pitch_xy = transformer.transform_points(player_xy)
|
| 96 |
+
```
|
| 97 |
+
|
| 98 |
+
## API Key
|
| 99 |
+
|
| 100 |
+
You need a Roboflow API key to use this model. Get one at [roboflow.com](https://roboflow.com).
|
| 101 |
+
|
| 102 |
+
## Citation
|
| 103 |
+
|
| 104 |
+
```
|
| 105 |
+
@misc{football-field-detection,
|
| 106 |
+
title={Football Field Detection},
|
| 107 |
+
author={Roboflow},
|
| 108 |
+
year={2024},
|
| 109 |
+
url={https://universe.roboflow.com/roboflow-jvuqo/football-field-detection-f07vi}
|
| 110 |
+
}
|
| 111 |
+
```
|