reco-yolo26s-football
A YOLO26s detector for ball, player and referee in amateur football, trained for the automatic camera in reco, an open-source GPU panoramic sports stitcher. The detections drive the virtual camera: where the ball is decides where the exported video looks.
This is the checkpoint reco runs in production. Read "What this was trained on" before using it - it is a narrow model, not a general football detector.
What changed in this update. This version replaces the earlier release of this repo. Measured on the same data, it is clearly better at players and referees and about equal on the ball. See "Results" for the numbers and for what they can and cannot show.
Classes
| id | name |
|---|---|
| 0 | person |
| 1 | ball |
| 2 | referee |
Note the order: person is 0 and ball is 1, which is not the COCO order. Referee is a separate class from person.
What this was trained on
- Amateur football on a fixed two-camera fisheye rig. The frames are the raw 3840x2880 output of one rig type. reco stitches the two views into a panorama for the exported video, but detection runs on each camera's own frame, before any stitching, and that is what this model was trained on. Geometry, lens distortion and colour rendition are therefore consistent throughout the training set, and the model has had no reason to become robust to anything else.
- 1632 tiles (1384 train / 248 val), two per camera frame: two overlapping 2880x2880 crops, each resized to 1920x1920. The train tiles hold 15889 person, 1322 ball and 1098 referee instances; the val tiles 2768 / 266 / 185. The ball is by far the rarest object, which shows in the results below.
- Labels were bootstrapped with a teacher model (see Credits) and then reviewed and corrected by hand in Label Studio.
The training images are not published. They show amateur football including minors, recorded without any expectation of public release. Only the weights are shared. Do not ask for the dataset.
Trained on tiles, and two ways to run it
The model was trained on 1920x1920 tiles cut from 3840x2880 camera frames. There are two ways to feed it a frame:
- Whole frame, one pass (what the reco app runs today). The 3840x2880 frame is letterboxed into 1920x1920 (scale 0.5, 240 px of padding top and bottom). Fastest, and it is the configuration with the most real-world hours. A ball is half its native size, smaller than anything seen in training (the training tiles are at scale 0.667).
- Two tiles, matching training. Crop
x = 0 .. 2880andx = 960 .. 3840(full height), each resized to 1920x1920 (bilinear), run the model on both, map boxes back to the camera frame and merge the overlap with a per-class NMS. Twice the inference cost. On our held-out match this finds more balls (see Results); in an end-to-end test of a similar single-crop variant in the reco pipeline the extra recall did not carry through to the final camera tracking, so it is not the app default.
Feed it camera frames, not stitched panoramas. reco runs the model on each camera's own frame before any stitching. A stitched panorama is a different domain - reprojected geometry, dewarped lens distortion, a different aspect ratio and a different object scale - and the model has never seen one. Running it at the native scale, i.e. 1920x1920 crops without resizing, finds more small balls but also more false boxes (white boots, a round logo on a jacket); that is not what this checkpoint was trained on.
Results
Validation set (248 held-out tiles)
Selected checkpoint (epoch 259 of 300), measured with imgsz=1920:
| class | precision | recall | mAP50 | mAP50-95 |
|---|---|---|---|---|
| all | 0.852 | 0.825 | 0.862 | 0.685 |
| person | 0.953 | 0.947 | 0.970 | 0.803 |
| ball | 0.751 | 0.636 | 0.682 | 0.465 |
| referee | 0.851 | 0.892 | 0.935 | 0.786 |
The same 248 tiles, the previous release of this repo:
| class | precision | recall | mAP50 | mAP50-95 |
|---|---|---|---|---|
| all | 0.795 | 0.780 | 0.800 | 0.615 |
| person | 0.891 | 0.915 | 0.947 | 0.766 |
| ball | 0.858 | 0.643 | 0.737 | 0.501 |
| referee | 0.635 | 0.784 | 0.717 | 0.580 |
Caveats: this validation set also chose the checkpoint (epoch 259), so the numbers for this model are slightly optimistic. The ball row is better for the previous release, mostly through precision.
Ball on a separate held-out match
200 camera frames (100 random, 100 from play time only) from one match that no model was trained on, labelled by hand. Only balls inside the playing area count (94 balls). Inference with two tiles as described above, confidence threshold 0.10:
| this version | previous release | |
|---|---|---|
| balls found | 64 / 94 (68%) | 70 / 94 (74%) |
| balls found at conf 0.50 | 59% | 57% |
| false boxes in the field at 0.10 | 12 | 25 |
| false boxes in the field at 0.50 | 2 | 2 |
| balls under 12 px found | 8 / 28 | 12 / 28 |
The difference in balls found is not significant (paired sign test: 4 balls only this version, 10 only the previous one, p = 0.18). What the numbers do show: no detectable gain on the ball, and fewer false boxes at a low threshold. Treat them as indicative: the labels were bootstrapped from model predictions and are known to miss some spare balls lying around the pitch, and it is one match.
The same 200 frames, run the way the reco app runs them today (whole frame letterboxed into 1920x1920, one pass, scale 0.5):
| this version | previous release | |
|---|---|---|
| balls found at conf 0.10 | 52 / 94 (55%) | 57 / 94 (61%) |
| balls found at conf 0.50 | 46% | 40% |
| false boxes in the field at 0.10 | 6 | 8 |
| balls under 12 px found | 6 / 28 | 10 / 28 |
Again not significant (5 balls only this version, 10 only the previous one, p = 0.30). Whole-frame inference finds fewer balls than two tiles for both models, so the first table is the best case for the ball.
Ball detection is the open problem in this project, not a solved one. Balls under about 12 px in the camera frame are mostly missed.
Training
Trained from random initialisation, not from COCO or other pre-trained weights, with ultralytics 8.4.146 (the checkpoint records this version; the run was resumed once):
Settings that differ from a default fine-tune: pretrained=False,
imgsz=1920, batch=2, epochs=300, patience=100, optimizer=auto.
All other settings are ultralytics defaults (mosaic on, closed for the
last 10 epochs). The run finished all 300 epochs; the best epoch by
validation fitness was 259. Single 8 GB GPU.
imgsz=1920 is high on purpose. The ball is a handful of pixels across
in a 3840x2880 frame, and training smaller measurably cost detection
quality.
Files
| file | notes |
|---|---|
best.pt | 20.8 MB. Ultralytics checkpoint - load, fine-tune, or re-export from this. Pickle format, so only load it if you trust this repo. |
best.onnx | 39.5 MB. Exported at imgsz=1920, input 1x3x1920x1920, output 1x300x6, exported with NMS. This is what reco loads. |
Both files had the training machine's local filesystem paths removed
before upload (ultralytics stores them in the checkpoint args and in the
ONNX description). The weights themselves are untouched: all weights
compare equal to the originals and predictions are identical. The tool
used is scripts/strip_ultralytics_local_paths.py in the
reco repository.
Usage
With ultralytics, on one 1920x1920 tile:
from ultralytics import YOLO
model = YOLO("best.pt")
results = model.predict("tile_1920.jpg", imgsz=1920, conf=0.1)
for box in results[0].boxes:
print(model.names[int(box.cls)], float(box.conf), box.xyxy.tolist())
With onnxruntime, no ultralytics dependency:
import numpy as np, onnxruntime as ort
session = ort.InferenceSession("best.onnx", providers=["CPUExecutionProvider"])
# One tile: RGB, 1920x1920, float32, 0-1, NCHW.
out = session.run(None, {"images": tile})[0] # (1, 300, 6)
# Each row: x1, y1, x2, y2, confidence, class_id (pixels of the 1920 tile).
reco runs this at conf=0.1 and filters afterwards, because a
low-confidence ball detection that a tracker can corroborate is worth
more than a missed one.
Limitations
- Ball recall is the weak point, particularly for small or occluded balls, and false boxes on white boots or socks occur at low thresholds. Anything relying on continuous ball tracking needs temporal logic on top; reco does its own coasting and player-anchor reasoning around this model rather than trusting per-frame detections.
- Trained on footage from one camera rig type. Expect a drop on other camera geometry, other pitches, or football with a very different player density (for example full-pitch 11-a-side); how far it carries over has not been measured.
- The referee class only saw the kit colours present in the training footage.
- No tracking, no re-identification, no team classification. Detection only.
License
AGPL-3.0. This model was trained from scratch, not from Ultralytics'
pre-trained weights, but with the AGPL-3.0-licensed ultralytics package
and its YOLO26 architecture, and the checkpoint itself carries
Ultralytics' own license field
(AGPL-3.0 (https://ultralytics.com/license)). The model is therefore
published under the same terms. If you need it under different terms,
that is between you and
Ultralytics licensing. reco itself is
AGPL-3.0 as well.
Credits
- Ultralytics for YOLO26 and the training framework.
Adit-jain/soccana, a YOLO11 football fine-tune, used as the teacher model to generate the initial pre-labels for the first part of the data before human correction. That repository lists no license at the time of writing.- Label Studio for the annotation work.