""" 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