The AI Football Coach for Amateur Teams β 100% Private, 100% Offline, $0 Cost
π Current state: 100+ services, 8 external data sources, 4500+ unit tests, full Arabic+English support. π§ Status: Production-aiming. See STATUS.md for the full report.
- Detects & tracks players + ball using YOLOv11/YOLO26 + BoT-SORT/Norfair with smart filters
- YOLO-pose for activity classification, fall detection, and player orientation
- Team color clustering auto-assigns home/away (no manual labels)
- Jersey number recognition via OCR for player identification
- Face recognition with InsightFace for re-identification
- Camera calibration (homography) β 4 pitch corners β real meters
- Computes statistics in meters: possession %, passes, distance, sprints, xG, xT, PPDA
- Advanced metrics: pressure, physical load, set-piece detection, progressive actions
- Detects formations: 4-3-3, 4-4-2, 4-2-3-1, 3-5-2, 5-3-2, 4-1-4-1, etc.
- Native services: PsychologyService, FootballRulesService, CardDetectionService, WeatherService
- External data: football-data.org, Bzzoiro, TheSportsDB, API-Football, EasySoccerData, StatsBomb, OpenFootball, RoboFlow Sports
- Algorithm ports: Kabsch (rigid alignment), Hungarian (optimal assignment), SpatialHash (O(1) neighbor lookup)
- Bilingual reports in English or Arabic via local LLM (Ollama)
- Tactical pattern knowledge base of 22+ rules and 19+ drills
- Tactical sandbox with matter.js for interactive formation play
- Set-piece simulator with MuJoCo-style physics for free-kick analysis
- Video weather detection with TobyBreckon-style raindrop sliding window
- Generates 4-week training plans with progressive overload
This project is under active development toward production quality.
- 100+ backend services, 4500+ unit tests, full Arabic+English UI
- Multi-phase roadmap: β Phase 1 (test coverage), π§ Phase 2 (real-time), Phase 3 (pro analytics), Phase 4 (UX polish)
What works:
- β Desktop app launches and shows the UI
- β 50+ services initialize and operate
- β YOLO + Norfair tracking on broadcast-quality footage
- β YOLO26-pose for activity/fall/orientation
- β Face recognition + jersey OCR
- β 8 external data sources (free tiers)
- β LLM generates coach reports in EN/AR
- β 22+ rules + 19+ drills knowledge base
- β Weather video detection (TobyBreckon-style)
- β Football rules classifier (17 IFAB Laws)
- β Set-piece simulator (MuJoCo + analytical fallback)
- β Matter.js tactical sandbox
- β 4-week training plan generator
- β PyInstaller .exe builds (~1.75 GB bundle)
Known limitations (honest):
β οΈ Tracking fragmentation: 91 tracks for 22 players (target: <30). Real amateur footage will be worse.β οΈ No homography by default: All spatial stats are in pixel space, not meters. Coach must calibrate first.β οΈ Jersey OCR is unreliable: 8-20px numbers on amateur footage are very hard to read.β οΈ No validation with real coaches: Everything is theoretical until tested in the wild.β οΈ Bundle is 1.75 GB: Way too big for amateur adoption.
Read STATUS.md for the full honest assessment.
Evaluated on 15min broadcast clip (france_sweden_15min.mp4, 3600 frames) using pseudo-ground-truth (YOLO at conf>0.5) vs pipeline (YOLO at conf>0.4 + ByteTrack):
| Metric | Value |
|---|---|
| MOTA | 0.538 |
| Precision | 92.5% |
| Recall | 58.6% |
| F1 | 0.717 |
Precision is strong (pipeline rarely hallucinates players). Recall bottleneck is broadcast camerawork (frequent cuts, close-ups), not detector quality. Amateur footage untested β see known limitations.
- Windows 10/11 (also works on macOS/Linux)
- Python 3.12+ (we recommend uv)
- NVIDIA GPU with 8GB+ VRAM (RTX 3060+, RTX 4070 recommended)
- 8GB+ RAM
- Ollama for local LLM: ollama.com/download
- FFmpeg for video processing
# 1. Install uv (fast Python package manager)
winget install astral-sh.uv
# 2. Install Ollama
winget install Ollama.Ollama
# 3. Install FFmpeg
winget install Gyan.FFmpeg
# 4. Clone this repository
git clone https://github.com/jraya106/kawkab-ai.git
cd kawkab-ai
# 5. Install dependencies (includes qasync for Qt+asyncio bridge)
uv sync --extra gpu --extra audio --extra tactical --extra dev
# 6. Install CUDA-enabled PyTorch (CRITICAL for GPU)
uv pip install torch torchvision --index-url https://download.pytorch.org/whl/cu121 --reinstall
# 7. Pull a local LLM (8-9 GB)
ollama pull ministral-3:14b
# Alternatives: qwen3:14b, gemma4:12b# Verify everything is set up
uv run python scripts/verify_system.py
# Test tracking quality (v0.12.0)
uv run python scripts/test_tracking_v2.py --video path/to/match.mp4
# Test homography integration (v0.12.0)
uv run python scripts/test_homography.py
# Launch the desktop app
uv run python -m kawkab- Drop a match video in the app
- Click "Analyze" β YOLO tracks 28 players (close to actual 22), K-means assigns teams by color
- Click 4 pitch corners β calibration saved as homography matrix (in meters)
- Re-analyze with homography β distance/formations/line height now in real meters
- Generate coach report β LLM produces tactical narrative with evidence
| Feature | Status | Notes |
|---|---|---|
| YOLOv11 + BoT-SORT + Top-N filter | β Working | Precision 92.5%, Recall 58.6% (pseudo-GT) |
| Homography UI + integration | β Working | Real meters for distance/formations |
| Team color clustering | β Working | K-means auto home/away |
| SQLite storage | β Working | Tested with SQLite |
| LLM (Ollama) | β Working | EN + AR, with retry logic |
| Knowledge base | β Working | 22 rules + 19 drills, YAML loader |
| Desktop app | β Launches | PySide6 + QWebChannel bridge |
| PyInstaller | β Builds | 1.75 GB bundle |
| Feature | Status | Risk |
|---|---|---|
| Tracking on amateur footage | Real amateur footage untested | |
| Homography | β Manual only | Coach must click 4 pitch corners per match |
| xG / xT | β In meters | Need homography applied |
| Formations | β 4-4-3 / 3-3-2 realistic | In meters with homography |
| Jersey OCR | 8-20px numbers on amateur footage | |
| Reasoning | Rules fire on patterns we don't measure yet | |
| LLM reports | Need real coach feedback |
| Feature | Plan | Status |
|---|---|---|
| Auto keypoint detection | Homography | β |
| SoccerNet/tracklab integration | Better ReID | β |
| Lazy model loading | 50 MB launcher | β |
| Validation with 5+ amateur coaches | Quality | β |
| Documentation videos | Adoption | β |
| Freemium model (Lemon Squeezy) | Monetization | β |
Kawkab AI Desktop (1.75 GB bundle, 66 MB exe)
β
βββ Core Services
β βββ CVService (YOLOv11l + BoT-SORT + top-N filter + pitch mask)
β βββ HomographyService (manual 4-corner calibration, meters-based)
β βββ LightGlueHomographyService (auto keypoint detection)
β βββ VRAMManager (sequential model loading, GPU budget)
β βββ EnhancementService (FFmpeg filters)
β βββ AnalysisService (formations, PPDA, xG, xT in meters)
β βββ CameraCutDetector (shot boundary detection)
β βββ ReasoningService (22-rule tactical diagnosis)
β βββ TrainingPlanGenerator (4-week progressive plans)
β βββ ClipExtractionService (FFmpeg evidence clips)
β βββ KnowledgeService (22 rules + 19 drills)
β βββ LLMService (Ollama local, EN+AR)
β βββ AudioService (Whisper, whistle)
β βββ StorageService (SQLite)
β
βββ GPU: RTX 4070 (CUDA 12.1, PyTorch 2.5.1)
βββ LLM: Ollama + Ministral/Qwen/Gemma (local, free)
βββ Distribution: PyInstaller β GitHub Releases
- Ultralytics YOLOv11 β Object detection
- SoccerNet β Football CV (we should integrate SoccerNet/tracklab next)
- boxmot β Multi-tracker library (next integration)
- socceraction β Action valuation
- Ollama β Local LLM runner
- FFmpeg β Video preprocessing
- mplsoccer β Pitch visualizations
- Kloppy β Sports data standardization
- PySide6 β Desktop UI framework
- qasync β Qt + asyncio bridge β NEW
kawkab-ai/
βββ src/kawkab/
β βββ app.py # Main PySide6 window
β βββ core/ # Config, logging, paths
β βββ services/ # 100+ async services
β β βββ cv_service.py # YOLO + BoT-SORT (v2: smart filters)
β β βββ homography_service.py # β NEW: pixel->pitch conversion
β β βββ vram_manager.py # β NEW: GPU memory management
β β βββ enhancement_service.py
β β βββ analysis_service.py
β β βββ reasoning_service.py
β β βββ training_plan_service.py
β β βββ clip_service.py
β β βββ knowledge_service.py
β β βββ llm_service.py
β β βββ audio_service.py
β β βββ storage_service.py
β βββ ui/ # QWebChannel bridge
β βββ web/ # Frontend (HTML/JS/CSS)
β βββ knowledge/ # YAML rules + drills
βββ scripts/ # Test & utility scripts
βββ tests/ # Unit tests
βββ data/ # User videos
βββ docs/ # Additional documentation
βββ PLAN.md # Original development plan
# Verify all services work
uv run python scripts/verify_system.py
# Test tracking quality (NEW v2)
uv run python scripts/test_tracking_v2.py --video path/to/match.mp4
# Test YOLO on GPU
uv run python scripts/smoke_test_cv.py
# Test LLM (English + Arabic)
uv run python scripts/smoke_test_llm.py
# Run full pipeline on a video
uv run python scripts/end_to_end_test.py --video your_match.mp4See BUILD.md for detailed build instructions.
MIT License β see LICENSE
This is a viable technical architecture with real domain knowledge in the knowledge base, and at v0.12.0 is on the path toward a real product. The next phases need to focus on:
- Validating tracking accuracy on real amateur footage (currently tuned for broadcast)
- Integrating SoccerNet/tracklab for football-tuned ReID
- Testing with 5+ amateur coaches to see if reports are actually useful
- Reducing bundle size via lazy model loading
- Building the trust layer (model card, data card, ground truth eval, LLM groundedness)
See docs/INDEX.md for the full documentation map.
See ITERATION_LOG.md for the current cycle log and the 63-target backlog.
The vision is sound. The execution is iterating.
Initial review by Claude (kawkab-ai-review.md). Subsequent cycles tracked in ITERATION_LOG.md.