drishya1's picture
Add files using upload-large-folder tool
10f7377 verified
|
Raw
History Blame Contribute Delete
12.8 kB
---
task_categories:
- video-classification
language:
- en
tags:
- soccer
- football
- action-spotting
- temporal-action-localization
- sports
- tracking
size_categories:
- 10K<n<100K
---
# SN-GAR Action Spotting - tracking
64 whole-match player/ball tracking tables at ~29.97 Hz (11,849,815 frames), with 87,939 action-spotting annotations across 10 labels.
This is one of a **pair** of datasets built in a single pass from the same raw
source. `SNGAR-Action-Spotting-Tracking` ships tracking tables,
`SNGAR-Action-Spotting-Video`
ships the broadcast video, and both carry **byte-identical ground truth** - the
same games, the same splits, the same event lists in the same order. A
tracking-vs-video comparison run on this pair measures the modality and nothing
else. The companion repo is the `video` one.
## Layout
```
annotations_train.json 45 games
annotations_valid.json 9 games
annotations_test.json 10 games
train/videos/<game_id>.parquet
valid/videos/<game_id>.parquet
test/videos/<game_id>.parquet
README.md
MANIFEST.sha256 sha256 of every shipped file
```
Payload: 3.0 GB across 64 games.
## Splits
| split | games | game ids | events |
|---|---:|---|---:|
| `train` | 45 | 3812-3840, 10502-10517 | 62,159 |
| `valid` | 9 | 3841-3849 | 12,091 |
| `test` | 10 | 3850-3859 | 13,689 |
Splits are assigned by **string-sorted** game id, so the `105xx` games sort
before the `38xx` ones. This is not random and not stratified - it is the
original SN-GAR contract, preserved so results stay comparable with prior work.
## Labels
| label | train | valid | test | total |
|---|---:|---:|---:|---:|
| PASS | 40,745 | 7,762 | 9,009 | **57,516** |
| PLAYER SUCCESSFUL TACKLE | 7,716 | 1,537 | 1,690 | **10,943** |
| OUT | 4,184 | 810 | 884 | **5,878** |
| HEADER | 3,986 | 870 | 867 | **5,723** |
| THROW IN | 1,834 | 372 | 392 | **2,598** |
| CROSS | 1,514 | 314 | 347 | **2,175** |
| FREE KICK | 1,261 | 255 | 272 | **1,788** |
| SHOT | 720 | 135 | 186 | **1,041** |
| GOAL | 135 | 23 | 30 | **188** |
| HIGH PASS | 64 | 13 | 12 | **89** |
| **all** | **62,159** | **12,091** | **13,689** | **87,939** |
## One label per instant
The task is single-label: each `position_ms` in a game carries exactly one
event. The source stream does not come that way - a throw-in is also a high
pass, a headed shot is both a header and a shot - so where several labels land
on the same millisecond, `LABEL_PRIORITY` selects the intended one.
Worth knowing when reading per-class results, because it is lossy *across*
labels rather than uniformly. Least-preserved: **HIGH PASS** keeps 89 of 2,697 (3%); **SHOT** keeps 1,041 of 1,559 (67%). Those classes are
sparse by construction rather than by data quality, so a model scoring badly on
them is not necessarily doing badly.
## Source
64 games: the 2022 FIFA World Cup (`3812`-`3859`) plus 16 further matches
(`10502`-`10517`). Two raw inputs per game:
| input | content |
|---|---|
| `RawEventsData/<game>.json` | hand-annotated event stream, ~2,000 events per game, each with `gameEvents` / `possessionEvents` / `initialTouch` sub-objects |
| `PlayerPoseTracking/<game>.jsonl.bz2` | bz2 line-delimited JSON, one line per tracked frame at ~29.97 Hz, ~186k lines per game (11.9M total) |
## How it was built
**1. Tracking to table.** Each `.jsonl.bz2` is decoded line by line and
flattened. The non-obvious part is player roles: the source exposes
`position_group_type` only inside `game_event`, which appears on roughly 1% of
frames. The builder therefore makes a **first full pass** to construct a
`team_id -> jersey -> position` map plus the game-static home/away team ids,
then a **second pass** stamping `position` and `positionGroup` onto every
player on every frame. This tags 99.98% of player-frames; the original
converter resolved team ids per frame and so tagged only the sparse event
frames.
Rows are then sorted by `(videoTimeMs, frameNum)` and deduplicated on
`videoTimeMs` keeping the first, which removes 42,950 rows corpus-wide and
leaves a strictly monotone clock.
**2. Events to labels.** Each source event maps to zero or more of the 10 SN-GAR
labels:
```
possessionEventType == "PA" (pass) bodyType == "HE" -> HEADER
ballHeightType == "A" -> HIGH PASS
passType == "H" -> THROW IN
otherwise -> PASS
== "CR" (cross) -> CROSS
== "SH" (shot) bodyType == "HE" -> HEADER |
always -> SHOT | all that
shotOutcomeType == "G" -> GOAL | apply
== "CH" (challenge) challengeWinnerPlayerId -> PLAYER SUCCESSFUL TACKLE
== "CL" (clearance) bodyType == "HE" -> HEADER
gameEventType == "OUT" -> OUT
setpieceType == "T" -> THROW IN
== "F" -> FREE KICK
```
Every rule that matches fires, so **one event can emit several labels**, each
becoming its own annotation at the same `position_ms`. A headed goal produces
three: HEADER, SHOT and GOAL. `position_ms` is `int(eventTime * 1000)`, and
`eventTime` is on the same video clock as `videoTimeMs` - which is what makes
step 3 possible.
**3. Alignment.** For each event, find the tracking row with the nearest
`videoTimeMs`. If it is further than `tolerance_ms` (10.0 ms)
away, drop the event: there is no tracking against which to localise it.
> **Note.** At 10.0 ms this window is narrower than half a native
> frame period (16.69 ms). Because the tracking clock ticks every
> ~33.4 ms, an event timestamped at an arbitrary millisecond can be up to
> 16.69 ms from the nearest row and still be perfectly aligned.
> This build therefore also drops 441 such events, chosen deliberately to
> reproduce the historical event count. A tolerance of 34.0 ms (one full
> frame period) keeps them.
```
94,285 extracted
-4,963 removed by priority dedup
-1,383 dropped as unalignable
=======
87,939 final
```
Most dropped events are post-match, where the source keeps annotating
tracking has stopped; at this tolerance the rest are the mid-frame
events described above.
**4. Write.** Both modalities' annotation files are written from the *same*
in-memory event lists - identical ground truth by construction rather than by a
follow-up sync - followed by the sha256 manifest and this card.
## Annotation format
OpenSportsLib v2, one file per split:
```json
{
"version": "2.0",
"task": "action_spotting",
"dataset_name": "action_spotting_tracking_valid",
"metadata": {"modality": "tracking", "aligned": true,
"tolerance_ms": 10.0,
"deduplicated_events": true,
"events_identical_across_modalities": true},
"labels": {"action": {"type": "single_label", "labels": ["PASS", "HEADER", ...]}},
"data": [{
"game_id": "3841",
"split": "valid",
"inputs": [{"type": "tracking_parquet", "path": "valid/videos/3841.parquet", "fps": 30.0}],
"events": [{"head": "action", "label": "PASS", "position_ms": 190256,
"gameTime": "1 - 00:00", "team": "home", "visibility": "visible"}]
}]
}
```
`position_ms` is the only field you need to localise an event. `gameTime` is
the `period - MM:SS` match clock, useful for display but **not** for
indexing.
## Payload format
### `{split}/videos/<game_id>.parquet`
One row per tracked frame, 17 columns, 178k-191k rows per game.
| column | type | meaning |
|---|---|---|
| `videoTimeMs` | float32 | **the clock.** Absolute video time in ms. `position_ms` indexes into this column and nothing else. |
| `frameNum` | int32 | source frame counter |
| `period` | int32 | 1-2, or 1-4 for the three extra-time games (`10506`, `10508`, `10517`) |
| `game_event_id` | int32 | -1 when the frame carries no game event |
| `possession_event_id` | int32 | -1 when the frame carries no possession event |
| `game_event_type` | string | `FIRSTKICKOFF`, `OTB`, `OUT`, ... empty on non-event frames |
| `player_name`, `player_id` | string | the event actor; empty on non-event frames |
| `team_id`, `home_team` | string | the actor's team; `home_team` is `"1"`/`"0"` |
| `possession_event_type` | string | `PA`, `SH`, `CR`, `CH`, `CL`, ... |
| `homePlayers`, `awayPlayers` | string | **JSON array** of 11 objects (see below) |
| `homePlayersSmoothed`, `awayPlayersSmoothed` | string | same, from the smoothed track |
| `balls` | string | **JSON array** of `{"visibility", "x", "y", "z"}` |
| `ballsSmoothed` | string | **JSON object** - note, not an array |
A player object:
```json
{"jerseyNum": "4", "confidence": "LOW", "visibility": "ESTIMATED",
"x": -16.286, "y": 5.821, "position": "RCB", "positionGroup": "DEF"}
```
Coordinates are pitch metres with the origin at the centre circle. `position`
is the fine-grained role and `positionGroup` collapses it to `GK`/`DEF`/`MID`/`FWD`.
Two shape quirks inherited from the source, documented rather than silently
patched, since fixing them would break existing loaders:
- The `*Smoothed` player columns carry **no** `position`/`positionGroup` keys.
Only the raw `homePlayers`/`awayPlayers` are role-enriched.
- `ballsSmoothed` is a JSON **object** where `balls` is a JSON **array**.
Both are inert for training: the OpenSportsLib loader reads only
`videoTimeMs`, `balls`, `homePlayers` and `awayPlayers`.
The nested columns are JSON strings rather than Arrow structs. That is what the
original SN-GAR conversion produced and what every existing loader expects, so
it is preserved; zstd compression absorbs the cost (62 GB -> 2.9 GB).
## Loading
```python
import json, pandas as pd
ann = json.load(open("annotations_test.json"))
game = ann["data"][0]
df = pd.read_parquet(game["inputs"][0]["path"])
times = df["videoTimeMs"].to_numpy() # the clock, in ms
for event in game["events"][:5]:
row = times.searchsorted(event["position_ms"])
players = json.loads(df["homePlayers"].iloc[row])
print(event["label"], event["position_ms"], len(players), "home players")
```
With OpenSportsLib:
```python
from opensportslib.core.utils.load_annotations import annotationstoe2eformat_tracking
labels, task = annotationstoe2eformat_tracking(
["annotations_test.json"], ["."], extract_fps=5
)
```
## The clock is not the wall clock
The single most important property of this dataset, and the one that has
already broken an evaluation once:
`videoTimeMs` starts **40-211 seconds** into the broadcast, because recording
begins before kickoff. Every game then has coverage gaps - 70 gaps longer than
5 s corpus-wide, median 58 s, mostly half-time plus outages. The tracked span
runs 95.5-144.8 minutes (median 101.9), against mp4 durations of 98.9-157.6.
**A parquet row index is therefore not linear in time.** `row_index / fps` is
not a timestamp. Computing one that way is what previously drove an oracle test
- feeding perfect predictions through the metric - down to 0.98% mAP instead of
99.07%, a ceiling under which no model could have scored well regardless of
quality. Read time from the `videoTimeMs` column, always.
## Other known properties
Real characteristics of the source, not defects to be cleaned:
- **Ball coverage is 53-79% of frames** (mean 68%). The most informative object
for spotting is missing about a third of the time. At *event* frames coverage
rises to 93% - the ball is tracked when it matters most.
- **11-v-11 on 99.93% of team-frames**, 99.98% `positionGroup` coverage, and
zero out-of-bounds coordinates.
- **Three games have extra time** (`10506`, `10508`, `10517`), with `period`
running 1-4 rather than 1-2.
## Build contract
| setting | value | why |
|---|---|---|
| label resolution | one label per instant, resolved by priority | see above |
| `tolerance_ms` | `10.0` | **tighter than half a native frame period** (16.69 ms), so it also rejects events that sit correctly on the clock between two rows |
| `dedupe_video_time_ms` | `True` | the source emits repeated `videoTimeMs`; removing them makes the clock strictly monotone |
| `aligned` | `True` | tracking cannot localise events outside its coverage |
| splits | 45 / 9 / 10 | alphabetical by game id, the original contract |
## Integrity
`MANIFEST.sha256` lists a sha256 for every shipped file:
```bash
sha256sum -c MANIFEST.sha256
```
## Access
Access is gated. Approval covers internal research use; check with the dataset
owners before redistributing.
Built by `build_sngar_spotting.py` on 2026-08-28.