Downloads · 30 days
0
Tvpower/Kart-Coaching
Kart-Coaching is a machine learning model from Tvpower. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
A computer vision system for analyzing go-kart racing lines and identifying critical racing points using deep learning. The system detects track segments, curve numbers, racing line directions, and key racing points (…
Downloads · 30 days
0
Access
Public
Updated Oct 30, 2025
Repo size
—
Likes
0
Public
Click a slice to open those files.
.py14.4 KB · 40%
From the Hugging Face model README
A computer vision system for analyzing go-kart racing lines and identifying critical racing points using deep learning. The system detects track segments, curve numbers, racing line directions, and key racing points (turn-in, apex, exit) with pixel-level coordinate prediction.
This project combines a frozen DINOv3 vision transformer backbone with a custom multi-head architecture to analyze racing footage. It processes video frames to identify track characteristics and optimal racing points, providing real-time coaching feedback.
facebook/dinov3-vitl16-pretrain-lvd1689m)The model uses five specialized prediction heads:
L = L_segment + L_curve + L_direction + L_point + 0.5 * L_coords
git clone <repository-url>
cd kart-coaching
pip install -r requirements.txt
Key Dependencies:
torch - PyTorch frameworktransformers - Hugging Face for DINOv3 modelpillow - Image processingscikit-learn - Train/val splittingnumpy, scipy - Numerical operationsThe dataset follows a JSON annotation format with frame-level labels.
Place your data in data/annotations/default.json:
{
"items": [
{
"attr": {"frame": 1},
"image": {"path": "frame_001.jpg"},
"annotations": [
{
"type": "label",
"attributes": {
"Type": "Curve",
"Number": 1,
"Direction": "Left"
}
},
{
"type": "points",
"label_id": 1,
"points": [0.45, 0.62]
}
]
}
]
}
Track Segment Types:
Racing Points:
Directions:
data/
├── annotations/
│ └── default.json
├── images/
│ └── default/
│ ├── frame_001.jpg
│ ├── frame_002.jpg
│ └── ...
The createDataset.py module provides the GoKartDataset class:
from transformers import AutoImageProcessor
from data.createDataset import GoKartDataset
processor = AutoImageProcessor.from_pretrained("facebook/dinov3-vitl16-pretrain-lvd1689m")
dataset = GoKartDataset("data/annotations/default.json", "data/annotations", processor)
Features:
Run training with:
python training/training.py
Training Configuration:
Training Features:
model/best_model.pthMonitoring:
Epoch 1/50
Train Loss: 2.3456 | Val Loss: 2.1234 | Point Acc: 65.32% | Curve Acc: 72.15%
After training, export the model for C++ inference:
python export_model.py
This creates model/coach_model.pt - a TorchScript traced model optimized for deployment.
Export Process:
best_model.pthDownload LibTorch (cxx11 ABI version) from pytorch.org
Extract to /opt/libtorch:
wget https://download.pytorch.org/libtorch/cu121/libtorch-cxx11-abi-shared-with-deps-2.0.0%2Bcu121.zip
unzip libtorch-cxx11-abi-shared-with-deps-2.0.0+cu121.zip
sudo mv libtorch /opt/
export TORCH_CUDA_ARCH_LIST="12.0"
export LD_LIBRARY_PATH=/opt/libtorch/lib:$LD_LIBRARY_PATH
Install OpenCV with CUDA support:
sudo apt update
sudo apt install libopencv-dev
Or build from source for better CUDA integration:
git clone https://github.com/opencv/opencv.git
cd opencv && mkdir build && cd build
cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D WITH_CUDA=ON \
-D CUDA_ARCH_BIN=7.5,8.6,8.9,9.0 \
..
make -j$(nproc)
sudo make install
cd inference
mkdir build && cd build
cmake ..
make -j$(nproc)
This produces the inference executable.
Process a racing video:
./inference ../model/coach_model.pt input_video.mp4 output_video.mp4
Arguments:
cv::Mat → Resize(518x518) → BGR→RGB → Normalize([0.485,0.456,0.406], [0.229,0.224,0.225]) → GPU Tensor
The system annotates each frame with:
Example overlay:
Curve 3 (Left) - Apex
Confidence: 92.5%
GPU Memory:
Processing Speed:
Optimization Tips:
inference.h - Header file defining:
Prediction struct (results container)GoKartInference class interfaceinference.cpp - Implementation:
main.cpp - Entry point:
CMakeLists.txt - Build configuration:
kart-coaching/
├── model/
│ ├── coachModel.py # PyTorch model definition
│ ├── best_model.pth # Trained weights (PyTorch)
│ └── coach_model.pt # Exported model (TorchScript)
├── training/
│ └── training.py # Training script
├── inference/
│ ├── inference.h # C++ header
│ ├── inference.cpp # C++ implementation
│ ├── main.cpp # Entry point
│ ├── CMakeLists.txt # Build config
│ └── build/ # Build artifacts
├── data/
│ ├── annotations/ # JSON labels
│ └── images/ # Training frames
├── createDataset.py # Dataset loader
├── export_model.py # Model export script
└── requirements.txt # Python dependencies
CUDA Out of Memory:
training/training.pytorch.cuda.empty_cache()Poor Accuracy:
Model Loading Error:
Slow Performance:
nvidia-smiBuild Errors: