YAML Metadata Warning:empty or missing yaml metadata in repo card
Check out the documentation for more information.
SN44 football event detection — measurement harness
Tooling for the manako/DetectFootballEvent private-track element on Bittensor
subnet 44.
Two pieces, deliberately split by what ships:
| Location | Ships in miner image | |
|---|---|---|
| Inference + calibration | turbovision/scorevision/miner/private_track/sv_football/ |
yes |
| Harness, tuning, training | football-harness/ (this directory) |
no |
The miner Dockerfile only copies scorevision/miner/private_track/, which is
why sv_football lives inside the turbovision repo. The harness imports it
from there, so tuning and production run identical post-processing code.
Quick start
python scripts/fetch_dataset.py # labels (add --clips for the mp4s)
python scripts/eval_baseline.py # score the incumbent — the target
python scripts/tune_calibration.py # tune post-processing (--write to ship)
python scripts/analyze_tracking.py # ball/player track quality
python -m pytest tests/ -q # 37 tests, no data or GPU needed
The scorer, tuner and tests need nothing beyond the standard library plus
opencv-python-headless. Tracking with real detections needs torch and
ultralytics; training needs a GPU.
The validation set
SN44 publishes a daily audit sample per private element: clip URL, full ground truth, and the winning miner's own predictions. That makes the target measurable exactly rather than estimated.
- Index:
https://turbo.scoredata.me/manako/audit/manako_DetectFootballEvent/index.json - Currently 30 clips, 413 labelled events, 10–30s each at 25fps
- Grows by ~1 clip/day; it only ever samples the winner, so once you win, your own outputs get published too
30 clips is a validation set, not a training set. Train on SoccerNet.
Measured findings
Incumbent baseline: 0.4388 mean score across the 30 clips.
Their per-class precision is 0.9–1.0 almost everywhere — they essentially never
emit a false positive — while recall is low (pass 0.77, pass_received 0.69,
recovery 0.39, tackle 0.36, block 0.12). The opening is recall at
maintained precision.
Where the score actually lives (share of total scoreable ground-truth weight):
| class | share | class | share | |
|---|---|---|---|---|
pass_received |
25.9% | tackle |
5.4% | |
pass |
24.8% | block |
5.2% | |
recovery |
9.5% | clearance |
4.8% | |
ball_out_of_play |
5.8% | everything else | 18.6% |
pass and pass_received alone are 50.7% of all available score.
pass_received derivation does not work as a constant offset
This was the most promising idea on paper — the class is 25.9% of the score and has no public training labels — but the data says no. Measured on ground truth:
pass -> next reception gap: median 38f (1.50s) stdev 76.5f
p10 22 p25 27 p75 67 p90 143
The distribution is far too wide for a 25-frame tolerance. Only ~71% of
receptions fall within tolerance of the best constant offset, and because
pass_received has min_score=0.0 its credit decays linearly to zero across
that window, so even the hits earn partial credit while the misses take a
full-weight penalty. The tuner evaluates offsets from 12 to 60 frames and
disables the feature every time.
The code is kept (derive_pass_received) because the conclusion changes if you
can estimate ball flight time per pass. Detecting receptions visually, or
conditioning the offset on ball trajectory, is the single largest available
gain — but a fixed delay is not the way to get it.
Tracking: players solved, ball blocked on a trained detector
Stage 0 built ball/player tracking (sv_football/tracking/), measured with
scripts/analyze_tracking.py.
Player tracking works. Generic COCO weights (yolo11s, person class) at
imgsz=1280 give 19.0–20.5 detections per frame across the three clips,
which is essentially the true count, with team-colour balance 0.67–0.87. This
is good enough for the geometric engine's player-side needs without any
football-specific training.
Scale, measured from those detections: player height median 69 px (p25 50, p95 134). A ball is 0.22 m against a player's 1.8 m, so the implied ball diameter is ~8 px, spanning roughly 6–16 px across the frame.
An earlier revision of this file put players at ~9 px and the ball at 2–4 px. That came from motion-segmentation blobs, which are body fragments, not whole players, and it was wrong. A 6–16 px ball is comfortably detectable by a trained model — the constraint is appearance, not resolution.
Ball tracking does not work yet, and the reason is now well supported. Every variant tried sits within noise of chance:
| ball candidates | perspective model | pooled AUC (18 events) |
|---|---|---|
| motion | none (compactness only) | 0.380 |
| motion + pitch mask | none | 0.461 |
| motion + pitch mask | size prior, flat | 0.591 |
| YOLO players + motion ball | size prior, flat | 0.538 ± 0.139 |
| YOLO players + motion ball | size prior, horizon | 0.420 ± 0.128 |
The intervals all straddle 0.50. At ~8 px the ball is size-degenerate with body-part motion blobs — a foot or a hand produces a blob of the same size and roundness — so no geometric prior separates them. Discrimination has to come from appearance, i.e. a trained ball detector. Further tuning of the motion fallback is not worth doing.
Notably, making the perspective model more physically correct made the AUC worse (0.420 vs 0.538). Those intervals overlap heavily so the difference is not meaningful, but it does confirm that size carries no ball signal here. The horizon-based model is retained because it is the correct one, not because it scored better.
Three real bugs the measurement caught:
- Camera pan (~2.2 px/frame) turns static high-contrast background — radio
masts, buildings, trees — into apparent motion, and the first run tracked an
antenna in the sky as the ball.
pitch.pyrestricts detection to the grass and cut players per frame from 44/41/73 to 25/29/39. - Ranking ball candidates by blob compactness puts sensor noise first, because
noise is perfectly circular.
ball_prior.pyscores by size agreement instead. - The first perspective guard rejected any near/far ratio above 6x as unphysical. Apparent height is linear in image row and reaches zero at the horizon, so large ratios are expected when far players stand near the vanishing line. The guard now checks that the fitted horizon lies above every observed player.
How track quality is measured
There are no ground-truth trajectories — the audit export publishes events, not tracks — so quality is judged by pass-anchored AUC. A pass is a sudden change in ball velocity, so if tracking works, ball acceleration at ground-truth pass frames should outrank acceleration at random frames. It needs no track labels and directly predicts whether the geometric engine can work.
Report the pooled figure with its interval, never per-clip AUCs: each clip holds only 4–9 passes, and single-clip values ranged 0.362–0.805 on identical tracking. Mirroring more of the 30 audit clips would narrow the interval about four-fold, which is the cheapest available improvement to measurement power.
scripts/analyze_tracking.py caches detections to data/artifacts/*.npz
(harness/detcache.py). Replay is 1.5s per clip against 335s, so the
smoother, the path search and the priors can be iterated without re-running
detection. Pass --refresh to invalidate.
Runtime: a GPU is required
yolo11s at imgsz=1280 costs 369 ms/frame on 32 CPU cores → 277s for a
750-frame clip, against a 26s budget. Tiled ball inference multiplies that by
the tile count. The pipeline is deadline-aware (TrackingSettings +
DeadlineGuard) and degrades to a truncated track rather than timing out, but
production needs GPU inference.
Training the ball detector
The Roboflow models the repo's example miner names
(football-player-detection.pt, football-ball-detection.pt) are not
downloadable checkpoints — Roboflow Universe serves them through an
API-keyed inference endpoint, which is why the example miner expects you to
place your own .pt in your Hugging Face repo. So the ball detector has to be
trained, and the source used here is SoccerNet-Tracking: 200 clips of 30s
at 1080p with per-frame boxes for players, goalkeepers, referees and the ball.
It is shot from the main tactical camera, not the broadcast cut, so the
viewpoint is much closer to Pixellot than SoccerNet's broadcast datasets.
python scripts/build_ball_dataset.py --download # a few GB, from KAUST
python scripts/build_ball_dataset.py --summary-only # check the domain match
python scripts/build_ball_dataset.py --out data/ball_tiles
python -c "from pathlib import Path
from training.train_ball_detector import TrainConfig, train
train(TrainConfig(data=Path('data/ball_tiles'), device=0))"
Run --summary-only before building. It prints SoccerNet's ball size
distribution in pixels; the Pixellot clips imply 6–16 px, and if SoccerNet
sits far from that the crops need rescaling before the detector will transfer.
Three design points that are easy to get wrong:
- Training crops must match inference crops. Inference slices each frame into overlapping 640×640 tiles at native resolution, so training uses 640×640 native crops. Training on downscaled full frames would shrink an 8 px ball to 3 px and discard the only signal available.
- Negatives are as important as positives. Inference examines ~15 tiles per frame and at most one holds the ball, so a model trained only on ball-containing crops fires constantly. 70% of negatives are aimed at players, because body parts are the specific confusion measured above.
- Splits are by sequence, never by frame. Adjacent frames at 25fps are near-duplicates, so a frame-level split leaks validation into training and reports a fictitious score.
Ball positions are jittered within the positive tile rather than centred, so the model does not learn that the ball sits mid-crop when at inference the tile grid is fixed and the ball lands anywhere.
Once trained, plug it in beside the COCO player model:
python scripts/analyze_tracking.py --coco --ball-weights runs/ball/weights/best.pt
The ingestion is tested against synthetic fixtures matching the documented SoccerNet layout, so the parser and tiler are verified without downloading several GB first.
Scoring model
Reward is not mAP. A matched prediction earns weight × decay; an unmatched one
costs the full weight. Expected value of emitting is:
Δ = w · [ p·(1 + decay) − 1 ] → emit only if p > 1 / (1 + decay)
Weight cancels, so the break-even confidence is ~0.55–0.65 for every class. Weight determines the damage when wrong, not the threshold. Consequences:
confidenceis ignored by the reward scorer (it only feeds the publishedmAP@1sbenchmark), so thresholding must happen miner-side.- Each ground-truth event matches at most once, so duplicates are pure penalty and per-class NMS is mandatory.
pass,pass_receivedandrecoveryhavemin_score=0.0: credit decays to zero at the tolerance edge, so timing precision matters. Everything else floors at 0.5, so merely landing inside the window earns half credit.- Ground truth contains unscored labels (
foul_won,defensive_1on1) that the validator ignores.
Layout
harness/
scorer.py exact port of the validator scorer (parity-tested)
dataset.py audit fetch, clip download, chronological split
evaluate.py scoring + per-class attribution
simulate.py synthetic detector for pre-checkpoint measurement
tune.py coordinate-descent calibration tuner
track_quality.py intrinsic + pass-anchored track metrics
detcache.py detection cache; replay tracking without re-detecting
scripts/ fetch_dataset / eval_baseline / tune_calibration / analyze_tracking
training/
soccernet_map.py spotting label mapping -> scored actions
dataset.py dense per-frame targets for the spotting model
train_spotting.py action spotting training loop
soccernet_tracking.py MOT reader; identifies the ball via gameinfo.ini
ball_dataset.py tiled YOLO dataset, hard negatives, seq-level split
train_ball_detector.py ball training config tuned for a tiny single class
tests/ parity + scorer edge cases + tracking + ingestion
The tracking package itself ships with the miner:
sv_football/tracking/
types.py Detection, BallTrack, PlayerTrack, TrackingResult
kalman.py constant-velocity filter + RTS smoother (fills occlusions)
detect.py YoloDetector (tiled native-res ball) | Motion | Composite
pitch.py grass segmentation — keeps detection on the playing surface
ball_prior.py perspective model; rescores candidates by expected ball size
tracker.py global DP ball-path selection; greedy player association
teams.py per-clip torso-colour clustering, majority vote per track
homography.py pixels -> pitch metres, and off-pitch tests
pipeline.py orchestrator, batched decode, deadline-aware
Ball tracking is a global optimisation, not online association: a clip arrives complete, so the best trajectory through all 750 frames is picked at once by dynamic programming, which survives the ball disappearing behind players far better than any greedy tracker. The Kalman smoother then fills the gaps.
python scripts/analyze_tracking.py --overlay # motion only
python scripts/analyze_tracking.py --coco --no-ball # real players
python scripts/analyze_tracking.py --player-weights football-player-detection.pt \
--ball-weights football-ball-detection.pt
Workflow
fetch_dataset.py --clipsto mirror labels and video.- Build a SoccerNet training index via
training/soccernet_map.py. training/train_spotting.pyto producemodel.pt.tune_calibration.py --checkpoint model.pt --writeto fit thresholds, offsets and NMS windows against the real scorer.- Copy
model.ptnext tosv_football/predict.py(or setSV_FOOTBALL_CHECKPOINT) and deploy.
The shipped calibration.json is a principled starting point, not a tuned one:
thresholds sit at break-even, and every class without public training labels is
disabled. Retune it against a real checkpoint before deploying.
- Downloads last month
- 48