README v2: sample provenance + quickstart notebook
Browse files- README.md +70 -33
- examples/quickstart.ipynb +295 -0
README.md
CHANGED
|
@@ -1,29 +1,81 @@
|
|
| 1 |
---
|
| 2 |
license: cc-by-nc-4.0
|
| 3 |
pretty_name: CounterStrike-1K Sample
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
tags:
|
| 5 |
- counter-strike-2
|
| 6 |
-
-
|
| 7 |
-
- video
|
|
|
|
|
|
|
| 8 |
- sample
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
---
|
| 10 |
|
| 11 |
# CounterStrike-1K Sample
|
| 12 |
|
| 13 |
-
This is
|
| 14 |
-
uses the same v12 per-sample schema as the full release, but stores ordinary
|
| 15 |
-
files instead of WebDataset tar shards.
|
| 16 |
|
| 17 |
-
##
|
| 18 |
|
| 19 |
-
-
|
| 20 |
-
- Match-map demos: 1
|
| 21 |
-
- Map(s): dust2
|
| 22 |
-
- Rounds: 16
|
| 23 |
-
- Samples: 160
|
| 24 |
-
- Rendered POV-hours: 2.630
|
| 25 |
|
| 26 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
|
| 28 |
```text
|
| 29 |
videos/360p/{sample_key}.mp4
|
|
@@ -31,27 +83,12 @@ actions/{sample_key}.actions.bin
|
|
| 31 |
state/{sample_key}.state.bin
|
| 32 |
events/{sample_key}.events.json
|
| 33 |
metadata/{sample_key}.json
|
|
|
|
|
|
|
| 34 |
```
|
| 35 |
|
| 36 |
-
The
|
| 37 |
-
`match_index.parquet`, `subsets/sample.parquet`, and the public schema files.
|
| 38 |
-
|
| 39 |
-
## Loading
|
| 40 |
|
| 41 |
-
|
| 42 |
-
from pathlib import Path
|
| 43 |
-
from huggingface_hub import snapshot_download
|
| 44 |
-
from counterstrike1k import CounterStrike1K
|
| 45 |
-
|
| 46 |
-
root = Path(snapshot_download(
|
| 47 |
-
repo_id="ArnieRamesh/CounterStrike-1K-sample",
|
| 48 |
-
repo_type="dataset",
|
| 49 |
-
))
|
| 50 |
-
ds = CounterStrike1K(root, subset="sample", resolution="360p")
|
| 51 |
-
sample = next(iter(ds))
|
| 52 |
-
print(sample["metadata"]["sample_key"])
|
| 53 |
-
print(sample["actions"].shape, sample["state"].shape, sample["player_alive"].mean())
|
| 54 |
-
```
|
| 55 |
|
| 56 |
-
No raw demos, Steam IDs, account identifiers, raw HLTV identifiers, player
|
| 57 |
-
names, or chat text are included.
|
|
|
|
| 1 |
---
|
| 2 |
license: cc-by-nc-4.0
|
| 3 |
pretty_name: CounterStrike-1K Sample
|
| 4 |
+
task_categories:
|
| 5 |
+
- video-classification
|
| 6 |
+
- reinforcement-learning
|
| 7 |
+
- video-to-video
|
| 8 |
tags:
|
| 9 |
- counter-strike-2
|
| 10 |
+
- world-model
|
| 11 |
+
- video-prediction
|
| 12 |
+
- action-conditioned-video
|
| 13 |
+
- multi-view
|
| 14 |
- sample
|
| 15 |
+
- audio
|
| 16 |
+
- esports
|
| 17 |
+
size_categories:
|
| 18 |
+
- n<1K
|
| 19 |
---
|
| 20 |
|
| 21 |
# CounterStrike-1K Sample
|
| 22 |
|
| 23 |
+
This is the reviewer/developer sample for [CounterStrike-1K](https://huggingface.co/datasets/ArnieRamesh/CounterStrike-1K). It contains one Dust2 match-map, 16 released rounds, all 10 synchronized player POVs per round, 160 clips total, and about 2 GB of 360p media. It is intended for inspecting video/audio quality, validating the v12 schema, building loaders, and running quick local experiments without downloading the full release.
|
|
|
|
|
|
|
| 24 |
|
| 25 |
+
## How this sample was created
|
| 26 |
|
| 27 |
+
The sample was created from the same public v12 postprocessing and QA pipeline as the full CounterStrike-1K release:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
|
| 29 |
+
1. We selected one QA-passing Dust2 match-map from the full release manifest.
|
| 30 |
+
2. We kept the first 16 released rounds from that match-map, preserving all 10 synchronized active-player POVs for each round.
|
| 31 |
+
3. We used the same v12 artifacts as the full release: rendered MP4 video/audio, dense per-frame `actions.bin`, dense per-frame `state.bin`, sparse `events.json`, and public metadata sidecars.
|
| 32 |
+
4. We downsampled the sample media to 360p for reviewer convenience while preserving the same 32 FPS frame grid, per-frame action/state alignment, and anonymized metadata schema.
|
| 33 |
+
5. We stored the artifacts as ordinary files instead of WebDataset tar shards, so reviewers can browse and download individual clips directly.
|
| 34 |
+
|
| 35 |
+
The exact sample membership is listed in `subsets/sample.parquet`. This sample is representative of the dataset format and synchronization/annotation quality, but it is not intended to be statistically representative of all maps, teams, matches, or gameplay situations in the full release.
|
| 36 |
+
|
| 37 |
+
## Quickstart
|
| 38 |
+
|
| 39 |
+
Start a fresh `uv` project and add the loader:
|
| 40 |
+
|
| 41 |
+
```bash
|
| 42 |
+
mkdir cs1k-demo && cd cs1k-demo
|
| 43 |
+
uv init
|
| 44 |
+
uv add "counterstrike1k @ git+https://github.com/AnirudhhRamesh/counterstrike1k"
|
| 45 |
+
```
|
| 46 |
+
|
| 47 |
+
<details>
|
| 48 |
+
<summary>Using pip instead</summary>
|
| 49 |
+
|
| 50 |
+
```bash
|
| 51 |
+
mkdir cs1k-demo && cd cs1k-demo
|
| 52 |
+
python -m venv .venv && source .venv/bin/activate
|
| 53 |
+
pip install "counterstrike1k @ git+https://github.com/AnirudhhRamesh/counterstrike1k"
|
| 54 |
+
```
|
| 55 |
+
</details>
|
| 56 |
+
|
| 57 |
+
```python
|
| 58 |
+
from counterstrike1k import load_sample
|
| 59 |
+
|
| 60 |
+
for sample in load_sample():
|
| 61 |
+
print(sample["metadata"]["sample_key"])
|
| 62 |
+
print(sample["actions"].shape, sample["state"].shape, len(sample["video"]))
|
| 63 |
+
break
|
| 64 |
+
```
|
| 65 |
+
|
| 66 |
+
`load_sample()` downloads this repo on first call, then iterates decoded samples in manifest order:
|
| 67 |
+
|
| 68 |
+
- `video`: mp4 bytes (H.264 + AAC, 640×360 @ 32 FPS with synchronized stereo audio)
|
| 69 |
+
- `actions`: structured numpy array (per-frame `tick`, `delta_pitch`, `delta_yaw`, 12-button bitmask)
|
| 70 |
+
- `state`: structured numpy array (per-frame view, position, weapon, ammo, HP, money, score, …)
|
| 71 |
+
- `events`: list of sparse round/kill/bomb events
|
| 72 |
+
- `metadata`: public sample metadata
|
| 73 |
+
|
| 74 |
+
For a Jupyter walkthrough, use [`examples/quickstart.ipynb`](examples/quickstart.ipynb) in this sample repo or the same notebook in the [source repo](https://github.com/AnirudhhRamesh/CounterStrike-1K).
|
| 75 |
+
|
| 76 |
+
## Layout
|
| 77 |
+
|
| 78 |
+
Direct files (not WebDataset shards), organized by modality:
|
| 79 |
|
| 80 |
```text
|
| 81 |
videos/360p/{sample_key}.mp4
|
|
|
|
| 83 |
state/{sample_key}.state.bin
|
| 84 |
events/{sample_key}.events.json
|
| 85 |
metadata/{sample_key}.json
|
| 86 |
+
manifest.parquet
|
| 87 |
+
round_index.parquet
|
| 88 |
```
|
| 89 |
|
| 90 |
+
The full release uses WebDataset shards instead — see [`CounterStrike-1K-360-wds`](https://huggingface.co/datasets/ArnieRamesh/CounterStrike-1K-360-wds) and [`CounterStrike-1K-720-wds`](https://huggingface.co/datasets/ArnieRamesh/CounterStrike-1K-720-wds).
|
|
|
|
|
|
|
|
|
|
| 91 |
|
| 92 |
+
## License & citation
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 93 |
|
| 94 |
+
CC BY-NC 4.0. Citation in the [main dataset card](https://huggingface.co/datasets/ArnieRamesh/CounterStrike-1K). No raw demos, Steam IDs, account identifiers, raw HLTV identifiers, player names, or chat text are included.
|
|
|
examples/quickstart.ipynb
ADDED
|
@@ -0,0 +1,295 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"cells": [
|
| 3 |
+
{
|
| 4 |
+
"cell_type": "markdown",
|
| 5 |
+
"id": "intro",
|
| 6 |
+
"metadata": {},
|
| 7 |
+
"source": "# CounterStrike-1K — Quickstart\n\nThis notebook runs end-to-end against the public preview repo. No environment variables, no config files. Open and run all.\n\n**What you'll see**: 1) browse the manifest, 2) decode one sample, 3) inspect actions/state, 4) watch the video, 5) **HUD overlay to verify action–video alignment**, 6) load all 10 synchronized POVs of one round.\n\n**Setup** (run once in a fresh project directory):\n\n```bash\nmkdir cs1k-demo && cd cs1k-demo\nuv init\nuv add datasets \"counterstrike1k @ git+https://github.com/AnirudhhRamesh/counterstrike1k\" jupyterlab matplotlib pandas\n```\n\nOr with pip:\n\n```bash\nmkdir cs1k-demo && cd cs1k-demo\npython -m venv .venv && source .venv/bin/activate\npip install datasets \"counterstrike1k @ git+https://github.com/AnirudhhRamesh/counterstrike1k\" jupyterlab matplotlib pandas\n```"
|
| 8 |
+
},
|
| 9 |
+
{
|
| 10 |
+
"cell_type": "markdown",
|
| 11 |
+
"id": "browse-md",
|
| 12 |
+
"metadata": {},
|
| 13 |
+
"source": [
|
| 14 |
+
"## 1. Browse the manifest\n",
|
| 15 |
+
"\n",
|
| 16 |
+
"The manifest is a small Parquet file (~25 MB) listing every released POV sample with split, map, weapon, kill counts, and round/match grouping. Read it with pandas — no media is downloaded here."
|
| 17 |
+
]
|
| 18 |
+
},
|
| 19 |
+
{
|
| 20 |
+
"cell_type": "code",
|
| 21 |
+
"execution_count": null,
|
| 22 |
+
"id": "browse-code",
|
| 23 |
+
"metadata": {},
|
| 24 |
+
"outputs": [],
|
| 25 |
+
"source": [
|
| 26 |
+
"import pandas as pd\n",
|
| 27 |
+
"from huggingface_hub import hf_hub_download\n",
|
| 28 |
+
"\n",
|
| 29 |
+
"manifest = pd.read_parquet(hf_hub_download(\n",
|
| 30 |
+
" \"ArnieRamesh/CounterStrike-1K\", \"manifest.parquet\", repo_type=\"dataset\",\n",
|
| 31 |
+
"))\n",
|
| 32 |
+
"print(f\"{len(manifest):,} POV samples across all splits\")\n",
|
| 33 |
+
"manifest.head()[[\"sample_key\", \"split\", \"map_slug\", \"round_id\", \"pov_idx\", \"duration_s\", \"frames\"]]"
|
| 34 |
+
]
|
| 35 |
+
},
|
| 36 |
+
{
|
| 37 |
+
"cell_type": "markdown",
|
| 38 |
+
"id": "filter-md",
|
| 39 |
+
"metadata": {},
|
| 40 |
+
"source": [
|
| 41 |
+
"Boolean masks give you fast, vectorized filtering — much faster than `.filter(lambda)`:"
|
| 42 |
+
]
|
| 43 |
+
},
|
| 44 |
+
{
|
| 45 |
+
"cell_type": "code",
|
| 46 |
+
"execution_count": null,
|
| 47 |
+
"id": "filter-code",
|
| 48 |
+
"metadata": {},
|
| 49 |
+
"outputs": [],
|
| 50 |
+
"source": [
|
| 51 |
+
"mirage_train = manifest[(manifest[\"map_slug\"] == \"mirage\") & (manifest[\"split\"] == \"train\")]\n",
|
| 52 |
+
"print(f\"{len(mirage_train):,} Mirage train clips\")\n",
|
| 53 |
+
"manifest[\"map_slug\"].value_counts()"
|
| 54 |
+
]
|
| 55 |
+
},
|
| 56 |
+
{
|
| 57 |
+
"cell_type": "markdown",
|
| 58 |
+
"id": "decode-md",
|
| 59 |
+
"metadata": {},
|
| 60 |
+
"source": [
|
| 61 |
+
"## 2. Stream one sample\n",
|
| 62 |
+
"\n",
|
| 63 |
+
"We stream from the small preview repo (no full download). `decode_sample` turns one shard sample into numpy arrays plus mp4 bytes."
|
| 64 |
+
]
|
| 65 |
+
},
|
| 66 |
+
{
|
| 67 |
+
"cell_type": "code",
|
| 68 |
+
"execution_count": null,
|
| 69 |
+
"id": "decode-code",
|
| 70 |
+
"metadata": {},
|
| 71 |
+
"outputs": [],
|
| 72 |
+
"source": [
|
| 73 |
+
"from counterstrike1k import load_sample\n",
|
| 74 |
+
"\n",
|
| 75 |
+
"samples = list(load_sample()) # downloads ~2 GB on first call, then cached.\n",
|
| 76 |
+
"sample = samples[0]\n",
|
| 77 |
+
"\n",
|
| 78 |
+
"print(\"key: \", sample[\"key\"])\n",
|
| 79 |
+
"print(\"actions:\", sample[\"actions\"].shape, sample[\"actions\"].dtype.names)\n",
|
| 80 |
+
"print(\"state: \", sample[\"state\"].shape, sample[\"state\"].dtype.names[:6], \"...\")\n",
|
| 81 |
+
"print(\"events: \", len(sample[\"events\"]), \"events\")\n",
|
| 82 |
+
"print(\"video: \", len(sample[\"video\"]), \"mp4 bytes\")"
|
| 83 |
+
]
|
| 84 |
+
},
|
| 85 |
+
{
|
| 86 |
+
"cell_type": "markdown",
|
| 87 |
+
"id": "buttons-md",
|
| 88 |
+
"metadata": {},
|
| 89 |
+
"source": [
|
| 90 |
+
"## 3. Inspect actions and state\n",
|
| 91 |
+
"\n",
|
| 92 |
+
"Buttons are stored as a `uint16` bitmask. `unpack_buttons` expands them into one boolean array per button (`FORWARD`, `FIRE`, `JUMP`, ...)."
|
| 93 |
+
]
|
| 94 |
+
},
|
| 95 |
+
{
|
| 96 |
+
"cell_type": "code",
|
| 97 |
+
"execution_count": null,
|
| 98 |
+
"id": "buttons-code",
|
| 99 |
+
"metadata": {},
|
| 100 |
+
"outputs": [],
|
| 101 |
+
"source": [
|
| 102 |
+
"from counterstrike1k import unpack_buttons\n",
|
| 103 |
+
"\n",
|
| 104 |
+
"buttons = unpack_buttons(sample[\"actions\"])\n",
|
| 105 |
+
"pressed = {name: int(values.sum()) for name, values in buttons.items() if values.any()}\n",
|
| 106 |
+
"print(\"pressed frames per button:\", pressed)\n",
|
| 107 |
+
"\n",
|
| 108 |
+
"state = sample[\"state\"]\n",
|
| 109 |
+
"print(\"\\nFirst frame:\")\n",
|
| 110 |
+
"print(f\" pos = ({state['pos_x'][0]:.1f}, {state['pos_y'][0]:.1f}, {state['pos_z'][0]:.1f})\")\n",
|
| 111 |
+
"print(f\" view = pitch {state['pitch'][0]:.1f}°, yaw {state['yaw'][0]:.1f}°\")\n",
|
| 112 |
+
"print(f\" health = {state['health'][0]}, armor = {state['armor_value'][0]}\")\n",
|
| 113 |
+
"print(f\" score = T {state['t_score'][0]} : CT {state['ct_score'][0]}\")"
|
| 114 |
+
]
|
| 115 |
+
},
|
| 116 |
+
{
|
| 117 |
+
"cell_type": "markdown",
|
| 118 |
+
"id": "video-md",
|
| 119 |
+
"metadata": {},
|
| 120 |
+
"source": [
|
| 121 |
+
"## 4. Watch the video\n",
|
| 122 |
+
"\n",
|
| 123 |
+
"Write the mp4 bytes to a file and embed the player. Audio plays in browsers that allow it."
|
| 124 |
+
]
|
| 125 |
+
},
|
| 126 |
+
{
|
| 127 |
+
"cell_type": "code",
|
| 128 |
+
"execution_count": null,
|
| 129 |
+
"id": "video-code",
|
| 130 |
+
"metadata": {},
|
| 131 |
+
"outputs": [],
|
| 132 |
+
"source": [
|
| 133 |
+
"from pathlib import Path\n",
|
| 134 |
+
"from IPython.display import Video\n",
|
| 135 |
+
"\n",
|
| 136 |
+
"out = Path(\"data/quickstart\") / f\"{sample['key']}.mp4\"\n",
|
| 137 |
+
"out.parent.mkdir(parents=True, exist_ok=True)\n",
|
| 138 |
+
"out.write_bytes(sample[\"video\"])\n",
|
| 139 |
+
"Video(str(out), embed=False, html_attributes=\"controls\")"
|
| 140 |
+
]
|
| 141 |
+
},
|
| 142 |
+
{
|
| 143 |
+
"cell_type": "markdown",
|
| 144 |
+
"id": "overlay-md",
|
| 145 |
+
"metadata": {},
|
| 146 |
+
"source": [
|
| 147 |
+
"## 5. Verify alignment with the debug overlay\n",
|
| 148 |
+
"\n",
|
| 149 |
+
"When working with action-conditioned video, the first thing you want to check is: *do the labels actually align with the video?* `overlay_frame` draws a HUD with the WASD keys, FIRE/JUMP/DUCK chips, mouse delta, HP/armor/money, and current score onto any frame.\n",
|
| 150 |
+
"\n",
|
| 151 |
+
"Pick a frame around something interesting — e.g., the first frame where FIRE is pressed:"
|
| 152 |
+
]
|
| 153 |
+
},
|
| 154 |
+
{
|
| 155 |
+
"cell_type": "code",
|
| 156 |
+
"execution_count": null,
|
| 157 |
+
"id": "overlay-code-frame",
|
| 158 |
+
"metadata": {},
|
| 159 |
+
"outputs": [],
|
| 160 |
+
"source": [
|
| 161 |
+
"from counterstrike1k import overlay_frame\n",
|
| 162 |
+
"\n",
|
| 163 |
+
"fire_frames = buttons[\"FIRE\"].nonzero()[0]\n",
|
| 164 |
+
"frame_idx = int(fire_frames[0]) if len(fire_frames) else len(sample[\"actions\"]) // 2\n",
|
| 165 |
+
"print(f\"showing frame {frame_idx}\")\n",
|
| 166 |
+
"overlay_frame(sample, frame_idx)"
|
| 167 |
+
]
|
| 168 |
+
},
|
| 169 |
+
{
|
| 170 |
+
"cell_type": "markdown",
|
| 171 |
+
"id": "overlay-video-md",
|
| 172 |
+
"metadata": {},
|
| 173 |
+
"source": [
|
| 174 |
+
"For a moving overlay, `overlay_video` writes a debug mp4. This is what to share with collaborators when you're explaining what's in the dataset."
|
| 175 |
+
]
|
| 176 |
+
},
|
| 177 |
+
{
|
| 178 |
+
"cell_type": "code",
|
| 179 |
+
"execution_count": null,
|
| 180 |
+
"id": "overlay-code-video",
|
| 181 |
+
"metadata": {},
|
| 182 |
+
"outputs": [],
|
| 183 |
+
"source": [
|
| 184 |
+
"from counterstrike1k import overlay_video\n",
|
| 185 |
+
"\n",
|
| 186 |
+
"debug_path = Path(\"data/quickstart\") / f\"{sample['key']}.debug.mp4\"\n",
|
| 187 |
+
"overlay_video(sample, debug_path, max_frames=192) # ~6 seconds at 32 FPS\n",
|
| 188 |
+
"Video(str(debug_path), embed=False, html_attributes=\"controls\")"
|
| 189 |
+
]
|
| 190 |
+
},
|
| 191 |
+
{
|
| 192 |
+
"cell_type": "markdown",
|
| 193 |
+
"id": "round-md",
|
| 194 |
+
"metadata": {},
|
| 195 |
+
"source": [
|
| 196 |
+
"## 6. Load all 10 POVs of one synchronized round\n",
|
| 197 |
+
"\n",
|
| 198 |
+
"Every round has exactly 10 synchronized POVs sharing a `round_id`. Group them with the manifest, then pull each one."
|
| 199 |
+
]
|
| 200 |
+
},
|
| 201 |
+
{
|
| 202 |
+
"cell_type": "code",
|
| 203 |
+
"execution_count": null,
|
| 204 |
+
"id": "round-code",
|
| 205 |
+
"metadata": {},
|
| 206 |
+
"outputs": [],
|
| 207 |
+
"source": [
|
| 208 |
+
"rows = pd.DataFrame([{**s[\"metadata\"], \"frames_actual\": len(s[\"actions\"])} for s in samples])\n",
|
| 209 |
+
"round_id = rows[\"round_id\"].iloc[0]\n",
|
| 210 |
+
"round_samples = rows[rows[\"round_id\"] == round_id].sort_values(\"pov_idx\")\n",
|
| 211 |
+
"print(f\"round {round_id}: {len(round_samples)} POVs\")\n",
|
| 212 |
+
"round_samples[[\"sample_key\", \"pov_idx\", \"team_side\", \"frames_actual\", \"alive_duration_s\"]]"
|
| 213 |
+
]
|
| 214 |
+
},
|
| 215 |
+
{
|
| 216 |
+
"cell_type": "markdown",
|
| 217 |
+
"id": "grid-md",
|
| 218 |
+
"metadata": {},
|
| 219 |
+
"source": [
|
| 220 |
+
"## 7. (Optional) Display all 10 POVs as a grid\n",
|
| 221 |
+
"\n",
|
| 222 |
+
"Decodes the midpoint frame from each POV and stacks them into a 5×2 grid."
|
| 223 |
+
]
|
| 224 |
+
},
|
| 225 |
+
{
|
| 226 |
+
"cell_type": "code",
|
| 227 |
+
"execution_count": null,
|
| 228 |
+
"id": "grid-code",
|
| 229 |
+
"metadata": {},
|
| 230 |
+
"outputs": [],
|
| 231 |
+
"source": [
|
| 232 |
+
"import io\n",
|
| 233 |
+
"import av\n",
|
| 234 |
+
"from PIL import Image, ImageDraw\n",
|
| 235 |
+
"\n",
|
| 236 |
+
"def midpoint_frame(video_bytes):\n",
|
| 237 |
+
" with av.open(io.BytesIO(video_bytes)) as container:\n",
|
| 238 |
+
" frames = list(container.decode(video=0))\n",
|
| 239 |
+
" return frames[len(frames) // 2].to_image()\n",
|
| 240 |
+
"\n",
|
| 241 |
+
"by_pov = {int(s[\"metadata\"][\"pov_idx\"]): s for s in samples if s[\"metadata\"][\"round_id\"] == round_id}\n",
|
| 242 |
+
"tile_w = 320\n",
|
| 243 |
+
"tiles = []\n",
|
| 244 |
+
"for pov in sorted(by_pov):\n",
|
| 245 |
+
" img = midpoint_frame(by_pov[pov][\"video\"])\n",
|
| 246 |
+
" th = int(round(tile_w * img.height / img.width))\n",
|
| 247 |
+
" tiles.append((pov, by_pov[pov][\"metadata\"].get(\"team_side\", \"\"), img.resize((tile_w, th))))\n",
|
| 248 |
+
"\n",
|
| 249 |
+
"tw, th = tiles[0][2].size\n",
|
| 250 |
+
"cols, rows_n = 5, 2\n",
|
| 251 |
+
"grid = Image.new(\"RGB\", (cols * tw + 4, rows_n * (th + 22) + 4), (18, 18, 18))\n",
|
| 252 |
+
"draw = ImageDraw.Draw(grid)\n",
|
| 253 |
+
"for i, (pov, side, img) in enumerate(tiles):\n",
|
| 254 |
+
" r, c = divmod(i, cols)\n",
|
| 255 |
+
" x, y = c * tw + 2, r * (th + 22) + 2\n",
|
| 256 |
+
" draw.text((x + 4, y), f\"pov {pov} {side}\", fill=(245, 245, 245))\n",
|
| 257 |
+
" grid.paste(img, (x, y + 22))\n",
|
| 258 |
+
"grid"
|
| 259 |
+
]
|
| 260 |
+
},
|
| 261 |
+
{
|
| 262 |
+
"cell_type": "markdown",
|
| 263 |
+
"id": "next-md",
|
| 264 |
+
"metadata": {},
|
| 265 |
+
"source": [
|
| 266 |
+
"## What's next\n",
|
| 267 |
+
"\n",
|
| 268 |
+
"- For training: stream the **360p** or **720p** WebDataset shards. See `examples/torch_dataset.py`.\n",
|
| 269 |
+
"- For full schema details: open the [`schema/` folder](https://huggingface.co/datasets/ArnieRamesh/CounterStrike-1K/tree/main/schema) on the dataset card.\n",
|
| 270 |
+
"- For deeper exploration (parquet+offset access, smoke checks): see `examples/advanced/`."
|
| 271 |
+
]
|
| 272 |
+
}
|
| 273 |
+
],
|
| 274 |
+
"metadata": {
|
| 275 |
+
"kernelspec": {
|
| 276 |
+
"display_name": "Python 3 (ipykernel)",
|
| 277 |
+
"language": "python",
|
| 278 |
+
"name": "python3"
|
| 279 |
+
},
|
| 280 |
+
"language_info": {
|
| 281 |
+
"codemirror_mode": {
|
| 282 |
+
"name": "ipython",
|
| 283 |
+
"version": 3
|
| 284 |
+
},
|
| 285 |
+
"file_extension": ".py",
|
| 286 |
+
"mimetype": "text/x-python",
|
| 287 |
+
"name": "python",
|
| 288 |
+
"nbconvert_exporter": "python",
|
| 289 |
+
"pygments_lexer": "ipython3",
|
| 290 |
+
"version": "3.14.2"
|
| 291 |
+
}
|
| 292 |
+
},
|
| 293 |
+
"nbformat": 4,
|
| 294 |
+
"nbformat_minor": 5
|
| 295 |
+
}
|