File size: 7,985 Bytes
ed2222b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5988ab2
 
 
 
 
ed2222b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5988ab2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ed2222b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
"""
Configuration constants and settings for NFL Play Detection System.

This module centralizes all configuration parameters to make the system
easier to tune and maintain.
"""

import torch

# ============================================================================
# MODEL CONFIGURATION
# ============================================================================

# Video Classification Model
VIDEO_MODEL_NAME = "x3d_m"  # Options: x3d_xs, x3d_s, x3d_m, x3d_l
DEVICE = torch.device("cpu")  # Use "cuda" for GPU acceleration if available

# Audio Transcription Model
AUDIO_MODEL_NAME = "openai/whisper-medium"  # Options: whisper-base, whisper-medium, whisper-large
AUDIO_DEVICE = -1  # -1 for CPU, 0+ for GPU device index

# YOLO Object Detection Model
YOLO_MODEL_SIZE = "nano"  # Options: nano, small, medium, large, xlarge
YOLO_CONFIDENCE_THRESHOLD = 0.25  # Detection confidence threshold
YOLO_IMAGE_SIZE = 640  # Input image size for YOLO inference

# ============================================================================
# VIDEO PROCESSING PARAMETERS
# ============================================================================

# Video preprocessing settings
VIDEO_CLIP_DURATION = 2.0  # Duration in seconds for video clips
VIDEO_NUM_SAMPLES = 16     # Number of frames to sample from clip
VIDEO_SIZE = 224           # Spatial size for model input (224x224)

# Kinetics-400 label map
KINETICS_LABELS_URL = "https://dl.fbaipublicfiles.com/pyslowfast/dataset/class_names/kinetics_classnames.json"
KINETICS_LABELS_PATH = "kinetics_classnames.json"

# Video preprocessing normalization (ImageNet standards)
VIDEO_MEAN = [0.45, 0.45, 0.45]
VIDEO_STD = [0.225, 0.225, 0.225]

# ============================================================================
# PLAY DETECTION PARAMETERS
# ============================================================================

# Confidence thresholds for play state detection
PLAY_CONFIDENCE_THRESHOLD = 0.002
PLAY_BOUNDARY_WINDOW_SIZE = 3

# NFL-specific action classifications for play state detection
PLAY_START_INDICATORS = [
    "passing American football (in game)",
    "kicking field goal", 
    "side kick",
    "high kick"
]

PLAY_ACTION_INDICATORS = [
    "catching or throwing baseball",  # Often misclassified football throws
    "catching or throwing softball",
    "playing cricket",  # Sometimes catches football
    "throwing ball"
]

NON_PLAY_INDICATORS = [
    "applauding",
    "marching", 
    "sitting",
    "standing",
    "clapping",
    "cheering"
]

# ============================================================================
# AUDIO PROCESSING PARAMETERS
# ============================================================================

# Audio preprocessing settings
AUDIO_SAMPLE_RATE = 16000
AUDIO_MIN_DURATION = 0.5  # Minimum duration in seconds to process
AUDIO_MIN_AMPLITUDE = 0.01  # Minimum amplitude threshold

# FFmpeg audio filtering parameters
AUDIO_HIGHPASS_FREQ = 80    # Hz - remove low frequency noise
AUDIO_LOWPASS_FREQ = 8000   # Hz - remove high frequency noise

# Whisper generation parameters (optimized for speed and NFL content)
WHISPER_GENERATION_PARAMS = {
    "language": "en",           # Force English detection
    "task": "transcribe",       # Don't translate
    "temperature": 0.0,         # Deterministic output
    "do_sample": False,         # Greedy decoding (fastest)
    "num_beams": 1,            # Single beam (fastest)
    "length_penalty": 0.0,     # No length penalty for speed
    "early_stopping": True     # Stop as soon as possible
}

# ============================================================================
# NFL SPORTS VOCABULARY AND CORRECTIONS
# ============================================================================

# Comprehensive NFL terminology for transcription enhancement
NFL_TEAMS = [
    "Patriots", "Cowboys", "Packers", "49ers", "Chiefs", "Bills", "Ravens", "Steelers",
    "Eagles", "Giants", "Rams", "Saints", "Buccaneers", "Panthers", "Falcons", "Cardinals",
    "Seahawks", "Broncos", "Raiders", "Chargers", "Dolphins", "Jets", "Colts", "Titans",
    "Jaguars", "Texans", "Browns", "Bengals", "Lions", "Vikings", "Bears", "Commanders"
]

NFL_POSITIONS = [
    "quarterback", "QB", "running back", "wide receiver", "tight end", "offensive line",
    "defensive end", "linebacker", "cornerback", "safety", "kicker", "punter",
    "center", "guard", "tackle", "fullback", "nose tackle", "middle linebacker"
]

NFL_TERMINOLOGY = [
    "touchdown", "field goal", "first down", "second down", "third down", "fourth down",
    "punt", "fumble", "interception", "sack", "blitz", "snap", "hike", "audible",
    "red zone", "end zone", "yard line", "scrimmage", "pocket", "shotgun formation",
    "play action", "screen pass", "draw play", "bootleg", "rollout", "scramble",
    "timeout", "penalty", "flag", "holding", "false start", "offside", "encroachment",
    "pass interference", "roughing the passer", "illegal formation", "delay of game"
]

NFL_GAME_SITUATIONS = [
    "two minute warning", "overtime", "coin toss", "kickoff", "touchback", "fair catch",
    "onside kick", "safety", "conversion", "extra point", "two point conversion",
    "challenge", "replay", "incomplete", "completion", "rushing yards", "passing yards"
]

NFL_COMMENTARY_TERMS = [
    "yards to go", "first and ten", "goal line", "midfield", "hash marks",
    "pocket presence", "arm strength", "accuracy", "mobility", "coverage",
    "rush defense", "pass rush", "secondary", "offensive line", "defensive line"
]

# Combine all NFL terms for comprehensive vocabulary
NFL_SPORTS_CONTEXT = NFL_TEAMS + NFL_POSITIONS + NFL_TERMINOLOGY + NFL_GAME_SITUATIONS + NFL_COMMENTARY_TERMS

# ============================================================================
# FILE PROCESSING PARAMETERS
# ============================================================================

# Supported video file formats
SUPPORTED_VIDEO_FORMATS = ["*.mov", "*.mp4"]

# Default output file names
DEFAULT_CLASSIFICATION_FILE = "classification.json"
DEFAULT_TRANSCRIPT_FILE = "transcripts.json"
DEFAULT_PLAY_ANALYSIS_FILE = "play_analysis.json"

# ============================================================================
# DIRECTORY STRUCTURE AND PATHS
# ============================================================================
# 
# All directory paths are centrally configured here. This provides:
# - Consistent paths across all modules
# - Easy customization for different deployment scenarios
# - Clear separation between input, output, cache, and temporary directories
# - Support for both relative and absolute paths
#
# To customize directories, modify the values below or set environment variables
# before importing this module.

# Input directories
DEFAULT_DATA_DIR = "data"                    # Default video clips directory
DEFAULT_SEGMENTS_DIR = "segments"            # Screen capture segments directory
DEFAULT_YOLO_OUTPUT_DIR = "segments/yolo"    # YOLO processed clips output

# Cache and temporary directories (None = use system defaults)
DEFAULT_CACHE_DIR = None                     # General cache (~/.cache)
DEFAULT_TEMP_DIR = None                      # Temporary files (/tmp)

# Model storage paths (None = use default locations)
TORCH_HUB_CACHE_DIR = None                   # PyTorch hub models (~/.cache/torch/hub)
HUGGINGFACE_CACHE_DIR = None                 # HuggingFace models (~/.cache/huggingface)

# Progress saving intervals
VIDEO_SAVE_INTERVAL = 5   # Save video results every N clips
AUDIO_SAVE_INTERVAL = 3   # Save audio results every N clips

# ============================================================================
# LOGGING AND DEBUG SETTINGS
# ============================================================================

# Debug output control
ENABLE_DEBUG_PRINTS = False
ENABLE_FRAME_SHAPE_DEBUG = False  # Can be expensive for large batches

# Progress reporting
ENABLE_PROGRESS_BARS = True
ENABLE_PERFORMANCE_TIMING = True