--- license: apache-2.0 language: - en tags: - robotics - droid - lerobot - video - dataloader task_categories: - robotics pretty_name: DROID RGB Dataloader (Standalone) --- # DROID RGB Dataloader (Standalone) Minimal, self-contained PyTorch loader for DROID video (RGB only). Pairs with our preprocessed DROID mirror: **Dataset:** [`SeonghuJeon/droid-1.0.1-preprocessed`](https://huggingface.co/datasets/SeonghuJeon/droid-1.0.1-preprocessed) **DO NOT use `lerobot/droid_1.0.1` directly.** That HF release has: 1. **Broken `from_timestamp` / `to_timestamp` fields** in `meta/episodes/*.parquet` — UNIX-epoch drift up to ~54 years. Any naive video seek lands on garbage. 2. **~30,815 episodes (~32%) with missing/truncated mp4 files** that throw random `av.error.*` deep into training. Our preprocessed mirror bakes in the timestamp fix and ships our blacklist + non-idle range sidecars. Same LeRobot v3.0 layout, drop-in replacement. ## What this repo (`droid-rgb-loader`) ships | File | Purpose | |------|---------| | `droid_rgb_dataset.py` | `DroidRGBDataset`, ~275 LoC, only deps are torch/numpy/pandas/pyarrow/pyav | | `example_usage.py` | End-to-end sanity check + DataLoader example | | `_stats/droid_blacklist_eps.json` | 30,815 episodes to skip | | `_stats/droid_nonidle_ranges.json` | per-episode `{start,end}` frame range where arm is moving | The stats files are also mirrored inside `droid-1.0.1-preprocessed` for convenience, but you can feed either copy to the loader via `stats_dir=`. ## Step 1 — Download the preprocessed DROID dataset ```bash HF_XET_HIGH_PERFORMANCE=1 \ hf download SeonghuJeon/droid-1.0.1-preprocessed \ --repo-type dataset \ --local-dir /path/to/droid-1.0.1-preprocessed ``` This is **~1.2TB** (all three cameras + framecache sidecars + fixed meta). Video-only download (skip framecache, keep raw mp4 + meta) is smaller: ```bash hf download SeonghuJeon/droid-1.0.1-preprocessed \ --repo-type dataset \ --local-dir /path/to/droid-1.0.1-preprocessed \ --include "meta/*" "data/*" "videos/**/*.mp4" ``` If you only want one camera: ```bash hf download SeonghuJeon/droid-1.0.1-preprocessed \ --repo-type dataset \ --local-dir /path/to/droid-1.0.1-preprocessed \ --include "meta/*" "data/*" "videos/observation.images.exterior_2_left/**/*.mp4" ``` ## Step 2 — Install dependencies ```bash pip install torch numpy pandas pyarrow av pillow ``` `av` is PyAV, the Python binding for ffmpeg. That's the only decode dep — no decord, no torchcodec, no torchvision VideoReader. ## Step 3 — Get this loader repo ```bash hf download SeonghuJeon/droid-rgb-loader --repo-type dataset --local-dir ./droid-rgb-loader cd droid-rgb-loader ``` ## Step 4 — Run the example ```bash python example_usage.py \ --root /path/to/droid-1.0.1-preprocessed \ --n-frames 8 --stride 3 --num-workers 2 ``` Expected output: ``` usable episodes: 63908 exterior: shape=(2, 8, 224, 224, 3) dtype=torch.uint8 wrist: shape=(2, 8, 224, 224, 3) dtype=torch.uint8 ``` If `usable episodes` is much lower than ~64k, something is wrong with paths or stats dir. ## Using `DroidRGBDataset` in your own code ```python from droid_rgb_dataset import DroidRGBDataset from torch.utils.data import DataLoader ds = DroidRGBDataset( root="/path/to/droid-1.0.1-preprocessed", stats_dir="./_stats", camera_keys=("observation.images.exterior_2_left", "observation.images.wrist_left"), n_frames=16, # window length stride=1, # 1=15Hz, 3=5Hz image_size=(224, 224), apply_blacklist=True, # mandatory apply_nonidle=True, # skip idle pre/post-roll ) loader = DataLoader(ds, batch_size=4, num_workers=4, shuffle=True) for batch in loader: ext = batch["observation.images.exterior_2_left"] # (B, T, H, W, 3) uint8 ... ``` Each `__getitem__` picks a **random valid window** from the i-th usable episode. `__len__` returns the number of usable episodes. Iterate the `DataLoader` multiple times per epoch if you want more diverse windows than one per episode. ## Why the blacklist is non-negotiable DROID on the original HF release has **~30,815 episodes (32%)** whose mp4 files are missing, truncated, or fail to decode. They remain silently present in the metadata parquets. We rebuilt the blacklist by walking every `observation.images.*` mp4 on disk and we re-encode nothing — we just skip those episodes. The preprocessed mirror on `SeonghuJeon/droid-1.0.1-preprocessed` only contains video files we verified decode end-to-end, but the blacklist is still applied at dataloader time as a belt-and-suspenders check. ## Why `apply_nonidle` matters DROID was collected via VR teleop, and episodes start/end with the operator sitting still (several seconds of no-op frames). `droid_nonidle_ranges.json` tells you the `[start, end)` frame range where the arm is actually moving, so you don't waste training capacity on motionless pre-roll. We built it from gripper + cartesian velocity thresholds. 88,097 episodes (of the non-blacklisted ones) have a non-empty non-idle range. Episodes missing from this file are considered fully idle and dropped by the loader. ## Camera keys DROID stores three exterior views. We strongly recommend: - `observation.images.exterior_2_left` (primary third-person view) - `observation.images.wrist_left` (wrist-mounted) **Do NOT use** `observation.images.exterior_1_left`: it is mis-calibrated or occluded on a large fraction of episodes. We blocked it in all our runs. ## File layout (LeRobot v3.0) ``` / meta/info.json meta/episodes/chunk-NNN/file-NNN.parquet <- FIXED timestamps (mirror only) data/chunk-NNN/file-NNN.parquet videos//chunk-NNN/file-NNN.mp4 videos//chunk-NNN/file-NNN.framecache/ (optional speedup, mirror only) ``` One mp4 holds **many** episodes. Each episode's window inside the mp4 is given by `videos//from_timestamp` in the episode meta parquet. The loader seeks there and decodes `n_frames` frames at the requested stride. ## Performance notes - **PyAV seek + decode**: ~10-30ms per window on a local SSD. Fast enough for training at `num_workers=8+`. - **Stride 3 = 5Hz** matches the DROID effective control rate most policies use (native 15Hz is over-sampled for slow VR teleop data). - **Framecache**: the preprocessed mirror ships `.framecache` sidecars next to each mp4 (one JPEG per frame, pre-decoded). This loader does not use them, but if you want roughly 3× faster random-window reads, ask us for the framecache reader — it's not included here to keep the code standalone. - **Multi-worker**: PyAV containers are not fork-safe, so the loader opens and closes a container per `__getitem__`. This is the safe default. ## Known limitations - No language instructions returned (DROID has them in the data parquet; add a column read in `_build_index` if you need them). - No action / state returned. If you need them later, the spec lives in `meta/info.json` → `features`, and the relevant columns are in `data/chunk-NNN/file-NNN.parquet` keyed by `(episode_index, frame_index)`. - Windows are per-episode random at `__getitem__` time (not exhaustively enumerated). `len(ds) == num_usable_episodes`, not num_windows. ## Contact Built by Seonghu Jeon. If you hit a broken mp4 that's not in the blacklist, or a non-idle range that looks wrong, please send the episode index back so we can update the stats.