AI-powered racing line analysis to find the fastest, most efficient path around any track
DriveOS is a deep learning application that trains neural networks to detect racing track boundaries in real-time video footage. Inspired by comma.ai's openpilot lane detection system, DriveOS uses advanced computer vision to understand track geometry from a driver's perspective.
Dual-Head Neural Network
-
Track Segmentation Head - U-Net architecture for drivable surface detection
- Encoder-decoder with skip connections for precise boundaries
- Outputs pixel-wise classification (track vs. non-track)
- Handles lighting variations and track surface changes
-
Edge Regression Head - Direct coordinate prediction (like openpilot)
- Predicts left/right track edges as 3D coordinates in world space
- 33 points per edge with quadratic spacing (dense near, sparse far)
- X-coordinate: Distance ahead (0-50 meters)
- Y-coordinate: Lateral offset from center (meters)
- Mixture Density Network outputs with uncertainty estimation
Why This Approach Works:
- 3D World Coordinates - Unlike pixel-based methods that bunch at image horizon, world-space coordinates naturally spread points based on actual track distance
- Explicit Supervision - Model learns exact edge positions rather than deriving them from segmentation masks
- Temporal Smoothing - Exponential moving average (EMA) with ฮฑ=0.7 for stable, jitter-free edges
- Uncertainty Aware - Confidence scores allow filtering of unreliable predictions
Training Process:
- Data Annotation - Built-in tool to label track boundaries
- Edge Label Generation - Automatically converts segmentation masks to 3D edge coordinates
- Multi-Task Learning - Trains both segmentation and edge regression simultaneously
- Edge Coordinate Loss - L1 loss on (X,Y) positions + confidence classification
- Inference - Real-time prediction with temporal smoothing for production-quality results
Key Innovation: Following openpilot's proven approach of predicting explicit coordinates in world space rather than pixel space eliminates the "horizon bunching" problem common in image-based lane detection
- Download this repository (Code โ Download ZIP)
- Extract to any location
- Double-click
INSTALL.bat
The installer automatically handles everything - Python environment, dependencies, GPU detection, and creates a desktop shortcut. Launch DriveOS from your desktop after installation!
Minimum:
- Windows 10+ (64-bit)
- Python 3.9-3.11 (Download) - Check "Add Python to PATH"
- 8 GB RAM, 5 GB free space
- Intel Core i5 / AMD Ryzen 5 (4+ cores)
Recommended:
- 16 GB RAM, 10 GB free space
- Intel Core i7/i9 or AMD Ryzen 7/9 (8+ cores)
- NVIDIA GPU (GTX 1060 6GB+, RTX 2060+) - 10-20x faster training
-
๐ฅ Multiple Input Sources:
- Video files (MP4, AVI, MOV, MKV)
- Webcam/Camera feed
- Screen capture (perfect for sim racing!)
-
๐ค AI-Powered Analysis:
- Dual-head architecture: U-Net segmentation + Edge regression
- Openpilot-inspired 3D coordinate prediction (world-space, not pixel-space)
- 33-point edge detection with quadratic spacing (0-50m ahead)
- Mixture Density Network with uncertainty estimation
- Temporal smoothing (EMA ฮฑ=0.7) for stable predictions
-
๐ Visual Feedback:
- Green overlay = Detected track surface
- White polylines = Left/right track edges in world coordinates
- Edge confidence scores (L/R) displayed
- Real-time inference time monitoring
- Smooth, jitter-free edge tracking
-
๐ฏ Professional GUI:
- Easy to use interface
- Real time statistics
- Progress tracking
- Batch video processing
Process racing videos and overlay the optimal racing line.
Real time racing line analysis from video files, webcams, or screen capture.
Interactive annotation tool for creating custom training datasets.
Train custom AI models on your own racing footage.
DriveOS supports screen capture, making it perfect for analyzing your sim racing sessions in real time! Works with:
- iRacing
- Assetto Corsa / Assetto Corsa Competizione
- F1 games
- Gran Turismo (via capture card)
- Any racing game or simulator
- Launch DriveOS โ "Analyze Video" tab
- Select your racing video
- Click "ANALYZE VIDEO WITH AI"
- Get processed video with racing line overlay
- "Live Preview" tab โ Choose source (Video, Webcam, or Screen Capture)
- Click "Start Processing" for real time analysis
- "Create Training Data" tab โ Select video โ "Launch Annotation Tool"
- Draw track boundaries: left edge (red), right edge (blue)
- Press SPACE to save frame, Q when done
- Annotate 50-100 diverse frames for best results
- "Train Model" tab โ Select training data directory
- Set environment variables (or use defaults):
USE_EDGE_HEAD=true- Enable openpilot-style edge regressionEDGE_LOSS_WEIGHT=1.0- Weight for edge coordinate lossEDGE_CONF_WEIGHT=0.5- Weight for edge confidence loss
- Adjust parameters (epochs: 50-100, batch size: 4-8)
- Click "Start Training" (5-10 min GPU, 30-60 min CPU)
- Edge labels auto-generated from segmentation masks before training
git clone https://github.com/BrayanVillatoro/DriveOS.git
cd DriveOS
python -m venv .venv
.venv\Scripts\activate
# GPU: pip install torch torchvision --index-url https://download.pytorch.org/whl/cu118
# CPU: pip install torch==2.4.1 torchvision==0.19.1 --index-url https://download.pytorch.org/whl/cpu
pip install -r config/requirements.txt
python launchers/launch_gui.pyArchitecture: Dual-head U-Net inspired by comma.ai's openpilot vision model
Segmentation Head:
- Encoder: 5 downsampling blocks (64โ1024 filters)
- Decoder: 4 upsampling blocks with skip connections
- Output: Track surface segmentation (2 classes)
Edge Regression Head (Openpilot-Style):
- Input: Multi-scale features from U-Net encoder
- Output: 2 edges ร 33 points ร 2 coordinates (X, Y)
- Coordinate System:
- X: Distance ahead (0-50m, quadratic spacing)
- Y: Lateral offset from center (meters)
- Uncertainty: Per-point std deviations + edge confidence scores
- Loss: L1 on coordinates + BCE on confidence
Training:
- Multi-task loss: Segmentation (BCE) + Edge coordinates (L1 + confidence)
- Loss weights: Seg=1.0, Edge=1.0, Confidence=0.5
- Data: Auto-generated edge labels from segmentation masks
- Optimizer: Adam with learning rate scheduling
Inference Pipeline:
- Forward pass through dual-head network
- Temporal smoothing: EMA (ฮฑ=0.7) on edge coordinates
- Convert world coordinates to pixel space for visualization
- Render track overlay + edge polylines
Performance:
- CPU: ~175-200ms/frame (5 FPS)
- GPU: ~15-30ms/frame (30-60 FPS)
- Model size: 320ร320 input โ any output resolution
Key Advantages:
- World-space coordinates eliminate horizon bunching
- Explicit edge supervision improves boundary accuracy
- Temporal smoothing provides production-quality stability
- Uncertainty-aware predictions for reliability filtering
This project is licensed under the MIT License - see the LICENSE file for details.
This is research software. DriveOS is provided for educational and research purposes. The racing line suggestions are AI generated and should not be considered as professional racing advice. Always prioritize safety when racing.
- "Python not found": Install Python 3.9-3.11, check "Add Python to PATH"
- Installation fails: Run as Administrator, check internet connection
- Slow processing: Close other apps, consider NVIDIA GPU for 10-20x speedup
- Issues/questions: GitHub Issues
- Contributions welcome via Pull Requests
Made with โค๏ธ for the racing community | DriveOS - Drive faster, smarter, better ๐



