Views
No views yet

| Class ID | Object Type | Description | Use Case |
|---|---|---|---|
| 0 | Player | Soccer players from both teams including goalkeepers | Primary tracking target, team assignment, tactical analysis |
| 1 | Ball | Soccer ball in various states (rolling, airborne, stationary) | Possession tracking, game flow analysis, event detection |
| 2 | Referee | Match officials including referees and linesmen | Contextual differentiation, avoiding tracking confusion |
1# Core Training Parameters
2epochs = 200 # Extended training for convergence
3img_size = 1280 # High-resolution input (1280x1280)
4batch_size = 32 # Optimal batch size for 1280 resolution
5workers = 8 # Multi-threaded data loading
6
7# Learning Rate Schedule
8lr0 = 0.01 # Initial learning rate
9lrf = 0.01 # Final learning rate (no decay)
10momentum = 0.937 # SGD momentum
11weight_decay = 0.0005 # L2 regularization
12
13# Regularization & Augmentation
14dropout = 0.3 # Dropout rate for overfitting prevention
15augmentation_probability = 0.5 # Data augmentation frequency1# Photometric Augmentations
2hsv_h = 0.015 # Hue augmentation range
3hsv_s = 0.7 # Saturation augmentation range
4hsv_v = 0.4 # Value augmentation range
5
6# Geometric Augmentations
7degrees = 0.0 # Rotation range (disabled for sports)
8translate = 0.1 # Translation augmentation
9scale = 0.5 # Scale augmentation range
10shear = 0.0 # Shear transformation (disabled)
11
12# Advanced Augmentations
13mosaic = 1.0 # Mosaic augmentation probability
14mixup = 0.0 # Mixup augmentation (disabled)
15copy_paste = 0.0 # Copy-paste augmentation (disabled)1# Detection Loss Components
2box_loss_gain = 0.05 # Bounding box loss weight
3cls_loss_gain = 0.5 # Classification loss weight
4dfl_loss_gain = 1.5 # Distribution focal loss weight
5
6# Focal Loss Parameters
7fl_gamma = 0.0 # Focal loss gamma (disabled)
8label_smoothing = 0.0 # Label smoothing factor1optimizer = "SGD" # Stochastic Gradient Descent
2nbs = 64 # Nominal batch size for scaling
3warmup_epochs = 3.0 # Learning rate warmup period
4warmup_momentum = 0.8 # Warmup momentum
5warmup_bias_lr = 0.1 # Warmup bias learning rate1depth_multiple = 0.33 # Model depth scaling factor (nano)
2width_multiple = 0.25 # Model width scaling factor (nano)
3max_channels = 1024 # Maximum channel count1anchors = None # Anchor-free detection
2nc = 3 # Number of classes (Player, Ball, Referee)
3conf_threshold = 0.25 # Confidence threshold for detection
4iou_threshold = 0.45 # IoU threshold for NMS
5max_det = 300 # Maximum detections per image1device = "cuda" # GPU acceleration
2multi_gpu = True # Multi-GPU training support
3amp = True # Automatic Mixed Precision
4half = False # FP16 inference (disabled during training)1cache = "ram" # Dataset caching strategy
2save_memory = False # Memory optimization mode
3rect = False # Rectangular training (disabled)player_detection/)1from player_detection import load_detection_model, get_detections
2import supervision as sv
3
4# Load the trained model
5model = load_detection_model("Models/Trained/yolov11_sahi_1280/Model/weights/best.pt")
6
7# Perform detection on a frame
8player_detections, ball_detections, referee_detections = get_detections(model, frame)
9
10# Results are returned as supervision.Detections objects with:
11# - Bounding boxes in [x1, y1, x2, y2] format
12# - Confidence scores for each detection
13# - Class IDs (0=Player, 1=Ball, 2=Referee)pipelines/detection_pipeline.py)1from pipelines import DetectionPipeline
2
3# Initialize detection pipeline
4pipeline = DetectionPipeline(model_path)
5
6# Video-based detection
7pipeline.detect_in_video("input.mp4", "output_detected.mp4", frame_count=300)
8
9# Real-time detection
10pipeline.detect_realtime("input.mp4") # or webcam index: 0
11
12# Frame-level detection
13player_det, ball_det, ref_det = pipeline.detect_frame_objects(frame)
14annotated_frame = pipeline.annotate_detections(frame, player_det, ball_det, ref_det)