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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
# Preparing VANTAGE-Bench data for inference (`run_lmudata.py`)
A beginner-friendly guide to turning the public **VANTAGE-Bench** Hugging Face
dataset into a local **LMUData** folder you can run VANTAGE-Bench's evaluation 
toolkit inference against.
> **TL;DR** — most participants just run:
> ```bash
> hf auth login                                   # once
> python scripts/run_lmudata.py --all --lmu-root ~/LMUData
> ```
> Run inference with `--mode infer`.
>
> Running this from a clone of the **PhysicalAI-VANTAGE-Bench dataset repo**? It
> auto-uses the local `data/` folder — see *"Where are you running this from?"*.

---

## A. What this script does

`run_lmudata.py` downloads the **public, no-ground-truth** VANTAGE-Bench dataset
from Hugging Face (`nvidia/PhysicalAI-VANTAGE-Bench`) and reshapes it into the
exact folder layout that VANTAGE-Bench's evaluation toolkit's dataset loaders expect (called
**LMUData**).

- It prepares data **for inference and submission generation**.
- It is **not** for local scoring. Ground-truth answers are withheld from the
  public dataset; scoring happens **server-side** on the leaderboard.
- It never fabricates answers. Evaluation-only columns are simply not written.

You run this once per machine. After it finishes, you run your model with
VANTAGE-Bench's evaluation toolkit in `--mode infer`, which produces a **submission JSONL** 
you can submit.

---

## B. The mental model (how the pieces fit)

```
Hugging Face dataset repo              (nvidia/PhysicalAI-VANTAGE-Bench)
        │  download

Local HF cache                         (~/.cache/huggingface/ — files reused)
        │  run_lmudata.py reshapes + links/copies

LMUData/                               (datasets/<TASK>/… — what toolkit reads)
        │  python run.py --mode infer

Predictions  ─►  submission JSONL      (submit to VANTAGE-Bench for scoring)
```

Key idea: the HF cache is the real local copy of the media. By **default**, your
LMUData folder *symlinks* into that cache instead of duplicating tens of GB.

---

## Where are you running this from?

This same script ships in **two** repos and picks its data source automatically.
The source is shown in the run summary as `Source: …`.

**Source resolution priority:**
1. `--local-source PATH` (explicit) — use that local checkout's `data/` folder.
2. **Auto-local** — if the script *file itself* lives inside a valid
   PhysicalAI-VANTAGE-Bench checkout (detected by walking the script's own
   parent folders — **no filesystem search**).
3. **HF remote** — download from `--hf-repo` (default
   `nvidia/PhysicalAI-VANTAGE-Bench`) via the HF cache.

### A. Running from the VANTAGE-Bench's Github repo

- Default: **HF remote**. Pulls data through the HF cache.
- Nothing special to do — this is the normal path.
  ```bash
  python scripts/run_lmudata.py --all --lmu-root ~/LMUData
  ```

### B. Running from the PhysicalAI-VANTAGE-Bench dataset repo

- If you cloned the dataset repo and run its bundled copy of this script, it
  **auto-detects** the repo and reads `data/` **locally** — no re-download of the
  primary dataset.
  ```bash
  python scripts/run_lmudata.py --all --lmu-root ~/LMUData
  # Source: local-auto:/path/to/PhysicalAI-VANTAGE-Bench
  ```
- **SOT and Grounding still need network.** The dataset repo ships the SOT
  benchmark + prep script and the RefDrone prep script, but **not** the SOT
  source camera videos (from `nvidia/PhysicalAI-SmartSpaces`) or the VisDrone
  images. Those still download. Local mode only avoids re-fetching the primary
  VANTAGE data.

### C. Explicit local source

```bash
python scripts/run_lmudata.py --all --lmu-root ~/LMUData \
  --local-source /path/to/PhysicalAI-VANTAGE-Bench
```
- Takes precedence over auto-detect and `--hf-repo`.
- The checkout must be **complete and post-PR** (validated per task).

### D. Warnings for local mode

- **Stale / pre-PR clone fails validation.** Each task checks for its expected
  post-PR paths (e.g. `data/pointing/VANTAGE_2DPointing.jsonl`,
  `data/event_verification/data_jsons/annotations/`). A missing marker fails
  *that task* with a clear message — it never silently serves the wrong layout.
- **Missing Git LFS files** (videos/images not pulled) will fail media checks.
  Run `git lfs pull` in the clone first.
- **Symlink mode points into the clone.** In local mode the default symlinks
  reference files inside your dataset clone; moving or `git clean`-ing the clone
  breaks them. Use `--copy` for a portable LMUData.
- **`--hf-repo` is ignored** when a local source is active (a warning is logged).

---

## C. Before you start (checklist)

1. **Python environment** with the project installed and `huggingface_hub`
   available. If a snapshot fails with `huggingface_hub is required`, run 
   `pip install huggingface_hub`.
2. **Hugging Face login** (recommended): `hf auth login`. The script
   auto-detects this token — you won't need to pass `--hf-token`.
3. **ffmpeg** — only needed for the **SOT** task (frame extraction). Skip if you
   aren't preparing SOT. Easiest install: `conda install -c conda-forge ffmpeg`.
4. **Disk space** — symlink mode (default) needs little extra space (media stays
   in the HF cache, ~40 GB there). `--copy` mode duplicates that media into
   LMUData. SOT adds ~16 GB of source videos to the HF cache.
5. **Choose an LMUData location** — an absolute path you control, e.g.
   `~/LMUData` or `/data/LMUData`. Pass it with `--lmu-root`. The script never
   writes to the current working directory by default.

---

## D. What is the HF cache?

When `huggingface_hub` downloads files, it stores them in a local **cache**,
usually:

```
~/.cache/huggingface/
```

(overridable with the `HF_HOME` env var or this script's `--hf-cache`).

- Downloads are **reused**: re-running the script, or preparing another task
  that shares files, won't re-download what's already cached.
- **Symlink mode (default) depends on this cache.** Your LMUData media entries
  are symlinks pointing into the cache. If you delete or move the HF cache,
  those symlinks break. (Fix: re-run the prep, or use `--copy`.)

---

## Disk Space Requirements

### Why disk usage varies

How much disk you need depends mostly on the **media mode**:

- **`--symlink` (default):** LMUData itself stays small — its media entries are
  symlinks into the HF cache (or, in local mode, into your dataset clone). The
  real bytes live in the cache/clone, which must **remain in place** for the
  symlinks to keep working.
- **`--copy`:** LMUData contains real copied media, so it uses **more** disk but
  is portable/self-contained and unaffected by HF-cache cleanup.

Hugging Face downloads are cached locally, usually under:

```text
~/.cache/huggingface/
```

(overridable with `HF_HOME` or `--hf-cache`). Cached files are reused across
runs, so you generally download each file only once.

### Approximate per-task disk usage

These are **rough** estimates and may change as the dataset evolves.

| Task | Approx. disk impact | Notes |
|---|---:|---|
| VQA | ~7–8 GB | Video files |
| Event Verification | ~1–3 GB | Referenced videos only |
| DVC | ~5–6 GB | Video files |
| Temporal Localization | ~2–5 GB | Video files |
| 2D Pointing | <1 GB | Images |
| Astro2D | <1 GB | Images + empty placeholder labels |
| 2D Grounding / RefDrone | ~300 MB retained, ~600 MB temporary | Downloads VisDrone/RefDrone image archive, extracts images, deletes zip |
| SOT | ~16 GB HF SmartSpaces cache + extracted frame outputs | Downloads source camera videos and extracts frames |

### Total disk recommendation

For a full `--all` run using the default symlink mode, plan for roughly:

- ~21–22 GB for the VANTAGE HF dataset cache
- ~16 GB for the SmartSpaces/SOT source-video cache
- ~300 MB retained Grounding workdir/images
- SOT extracted frames and task metadata
- relatively small LMUData task folders because most media are symlinked

Recommended free disk for **default symlink mode**:

- minimum: ~50–60 GB free
- safer: ~70+ GB free

For **`--copy` mode**:

- LMUData contains real copied media in addition to the HF cache
- plan for roughly ~80–100 GB free
- safer on shared/HPC systems: 100+ GB free

These figures are approximate and may shift as the benchmark grows.

### SOT runtime note

SOT is the slowest task to prepare. It downloads source camera videos from
SmartSpaces and uses `ffmpeg` to extract sequence frames. Depending on network
speed and storage speed, this may take a long time. It is normal for SOT
preparation to run much longer than the other tasks.

### Check local disk usage

```bash
df -h
du -sh ~/.cache/huggingface 2>/dev/null || true
du -sh ~/LMUData 2>/dev/null || true
```

### Advanced disk-space notes

- If disk is limited, use the default symlink mode.
- If portability is important, use `--copy`.
- Do not delete the HF cache if using symlink mode, because symlinks may break.

---

## E. Recommended participant command (default: symlink)

```bash
python scripts/run_lmudata.py \
  --all \
  --lmu-root /path/to/LMUData
```

- `--all` prepares all eight tasks.
- Media is **symlinked** from the HF cache (disk-efficient).
- Already-prepared tasks are skipped automatically (safe to re-run).

If you only want some tasks (e.g. skip the large SOT download):

```bash
python scripts/run_lmudata.py \
  --tasks vqa,event_verification,dvc,temporal,pointing,astro2d,grounding \
  --lmu-root /path/to/LMUData
```

---

## F. Portable / self-contained command (copy mode)

Use `--copy` when you want a LMUData folder with **real media files** inside it —
portable across machines, and unaffected by HF-cache cleanup:

```bash
python scripts/run_lmudata.py \
  --all \
  --lmu-root /path/to/LMUData \
  --copy
```

Trade-off: this duplicates tens of GB of media into LMUData.

---

## G. Dry-run (simulation, no writes)

Preview exactly what would happen — **no downloads, no files written**, the
LMUData folder isn't even created:

```bash
python scripts/run_lmudata.py \
  --all \
  --lmu-root /path/to/LMUData \
  --dry-run
```

The summary header shows the media mode (`media=symlink` by default), and each
task prints the HF files it would fetch and the paths it would write.

---

## H. SOT-specific prerequisites

SOT (single-object tracking) is the heaviest task. It downloads source camera
videos from
[`nvidia/PhysicalAI-SmartSpaces`](https://huggingface.co/datasets/nvidia/PhysicalAI-SmartSpaces)
and extracts frames.

- **ffmpeg is required** for frame extraction. The shipped prep script has no
  ffmpeg-free path. The wrapper auto-discovers ffmpeg on your `PATH` **and** in
  common conda envs (`~/miniconda3/envs/*/bin`, `/opt/conda/envs/*/bin`, …) and
  bridges it onto the subprocess automatically.
- **HF token is auto-detected** in this order: `--hf-token``HF_TOKEN` env →
  the token from `hf auth login`. If you've logged in, nothing to pass.
- **Source videos:** ~16 GB pulled into the HF cache; expect a multi-minute run.
- **`gt.json` contains only the public `init_bbox`** — no hidden per-frame
  trajectories.
**If ffmpeg is missing**, you'll get a clear message with install options:
```
conda install -c conda-forge ffmpeg          # recommended; auto-detected
sudo apt-get install -y ffmpeg               # Debian/Ubuntu
# or a static build from https://johnvansickle.com/ffmpeg/
```
**If no token is found**, the message lists the three ways to provide one
(`hf auth login`, `HF_TOKEN`, `--hf-token`).
---
## I. RefDrone / Grounding prerequisites
The grounding task materializes 1503 VisDrone images via the shipped
`prep_refdrone_data.py`.
| Requirement | Needed? | Notes |
|---|---|---|
| Internet access | yes | Downloads from `github.com` + `huggingface.co`. |
| GitHub HTTPS mirror | primary | Ultralytics release (~311 MB), size + SHA-256 verified. **Sufficient on its own.** |
| Google Drive / `gdown` | **optional** | Fallback only, used if the HTTPS mirror fails. Install with `pip install gdown` only then. |
| Disk | ~600 MB transient | Zip downloaded, images extracted, **zip then deleted** (~290 MB remains). |
| System packages | none | Pure-Python extraction. |

If you already have the images staged, pass `--skip-grounding-images` to write
`annotations.json` without re-downloading.

---

## J. Common troubleshooting

- **Wrong LMUData path / Toolkit can't find data.** VANTAGE-Bench's evaluation 
  toolkit resolves `LMUDataRoot()` from `$LMUData` (if it points to an 
  existing dir), else `~/LMUData`. Make them match:
  ```bash
  export LMUData=/path/to/LMUData
  python -c "from vlmeval.smp import LMUDataRoot; print(LMUDataRoot())"
  ```
- **Broken / dangling symlinks.** In symlink mode, deleting or moving the HF
  cache breaks LMUData media links. Fix by re-running the prep, or rebuild with
  `--copy` for a self-contained folder.
- **Missing ffmpeg (SOT).** Install via conda/apt (see section H). A conda-env
  ffmpeg is auto-detected.
- **HF auth / token issues.** Run `hf auth login`, or `export HF_TOKEN=hf_xxx`,
  or pass `--hf-token`. If a download 401/403s, confirm any required dataset
  license acceptance and that your token has read access.
- **Use `--mode infer`, not `--mode all`.** These TSVs are inference-only and
  omit GT columns. `--mode all` would call `evaluate()` and crash; scoring is
  server-side anyway.

---

## K. What gets created under LMUData

```
LMUData/
└── datasets/
    ├── VANTAGE_VQA/                 VANTAGE_VQA.tsv                + videos/
    ├── VANTAGE_EventVerification/   VANTAGE_EventVerification.tsv  + videos/
    ├── VANTAGE_DVC/                 VANTAGE_DVC.tsv                + videos/
    ├── VANTAGE_Temporal/            VANTAGE_Temporal.tsv           + videos/
    ├── VANTAGE_2DPointing/          VANTAGE_2DPointing.tsv         + images_annotated/
    ├── Astro2D/                     images/ + labels/ (empty placeholders)
    ├── VANTAGE_2DGrounding/         annotations.json               + images/
    └── VANTAGE_SOT/                 <seq>/gt.json + <seq>/frames/f0X.png
```

Inference-only TSV schemas (no GT columns):

| Task | Columns |
|---|---|
| VANTAGE_VQA | `index, video, question, options` |
| VANTAGE_EventVerification | `index, video, system_prompt, question` |
| VANTAGE_DVC | `index, video, question` |
| VANTAGE_Temporal | `index, video, question` (video = bare stem, no `.mp4`) |
| VANTAGE_2DPointing | `index, question_id, image_path, question, A, B, C, D` |
- **Astro2D `labels/*.txt` are intentionally empty** — they exist only so the
  loader doesn't drop images; they contain no ground truth.
- **VANTAGE_2DGrounding `annotations.json` omits `bboxes`** — the loader takes
  its no-GT branch.
> **Note:** a `LMUData/images/` folder may appear **later** — that is the toolkit's 
*runtime* artifact (frame caching / image dumping during
> inference), **not** produced by this prep script. It's safe to ignore.
---
## L. Advanced options
| Flag | Purpose |
|---|---|
| `--tasks a,b,c` | Prepare a subset. Choices: `vqa, event_verification, dvc, temporal, pointing, astro2d, grounding, sot`. |
| `--all` | Prepare all eight tasks (default if neither `--tasks` nor `--all` given). |
| `--lmu-root PATH` | Output root (absolute). Default `~/LMUData`. Never CWD. |
| `--local-source PATH` | Use a local PhysicalAI-VANTAGE-Bench checkout's `data/` instead of HF. Wins over `--hf-repo`. Auto-enabled when the script lives inside such a repo. |
| `--symlink` | **Default.** Symlink media (from the HF cache, or the local checkout in local mode). |
| `--copy` | Copy real media into LMUData (portable, self-contained; uses more disk). |
| `--force` | Rebuild the index file even if the task already looks complete; re-places missing media. |
| `--force-clean` | **Destructive.** Wipe a task's media dir before re-staging. |
| `--dry-run` | Print the plan; no HF calls, no writes. |
| `--hf-token TOKEN` | HF token. Optional — auto-detected from `HF_TOKEN` / `hf auth login`. Needed for SOT. |
| `--hf-repo REPO` | Source repo override (testing/simulation only). Production default: `nvidia/PhysicalAI-VANTAGE-Bench`. |
| `--skip-grounding-images` | For grounding: write `annotations.json` but don't download VisDrone images. |
| `--write-manifest` | Write `.vantage_prep_manifest.json` telemetry at the LMU root (off by default). |
| `--verbose` / `-v` | Debug logging (snapshot paths, per-file decisions). |

`--symlink` and `--copy` are mutually exclusive.

### Idempotency & safety

- **Re-running is safe.** A task that already passes its integrity check is
  **skipped** (no download, no writes) unless you pass `--force`.
- **Interrupted runs recover.** A partial task fails its integrity check, so the
  next normal run rebuilds just that task. SOT resumes cheaply — already
  downloaded videos and extracted frames are reused from the HF cache.
- **Non-destructive by default.** Without `--force-clean`, the script only adds
  missing files and (under `--force`) overwrites the index file. It never
  deletes media on its own.

### Per-task failure isolation

Each task runs independently. If one fails (missing source, no token, no
ffmpeg, mirror down), it's marked `failed` in the summary **and the other tasks
continue**. The process exits non-zero if any task failed, zero otherwise.

---

## After preparing: run inference

```bash
export LMUData=/path/to/LMUData
python run.py --data VANTAGE_VQA --model <YourModel> --mode infer
```

Repeat per task (or pass multiple to `--data`). Each run emits a
`*.submission.jsonl` next to the prediction file — that's what you submit.
Scoring is done server-side against the withheld ground truth.