File size: 1,287 Bytes
6ebf14b |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
"""
Football Field Detection Model - Roboflow Inference Wrapper
"""
from inference import get_model
import os
class FootballFieldDetector:
"""Wrapper for Roboflow football field keypoint detection model"""
def __init__(self, api_key: str):
"""
Initialize the field detection model
Args:
api_key: Your Roboflow API key
"""
self.model_id = "football-field-detection-f07vi/14"
self.model = get_model(model_id=self.model_id, api_key=api_key)
def predict(self, image, confidence: float = 0.3):
"""
Detect field keypoints
Args:
image: Image as numpy array or path to image
confidence: Confidence threshold (0.0-1.0)
Returns:
Keypoint detection results
"""
result = self.model.infer(image, confidence=confidence)[0]
return result
# Example usage:
if __name__ == "__main__":
import os
# Set your API key
api_key = os.getenv("ROBOFLOW_API_KEY")
# Initialize detector
detector = FootballFieldDetector(api_key=api_key)
# Run inference
results = detector.predict("path/to/image.jpg", confidence=0.3)
print(f"Detected keypoints: {results}")
|