Training and inference for a navigation policy that conditions a diffusion policy on V-JEPA2 visual context features. Trajectories (waypoints) are predicted by a conditional 1D U-Net denoiser over a sequence of past frames and an optional goal image.
Inspired by visualnav-transformer (NoMaD / ViNT / GNM); the data pipeline and several training utilities are adapted from that codebase (see Inherited from the original visualnav-transformer / NoMaD codebase below).
Inference rollout on a SCAND clip (Jackal, GDC library):
Ablation + scaling sweep results (tables and plots): see experiments.md.
flowchart LR
obs["Obs clip"] --> enc["V-JEPA2 ViT-L<br/>(frozen)"]
goal["Goal img"] --> enc
enc --> fuse["Fusion Tx<br/>2L · 8H"] --> pool["CLS pool"] --> merge(("c"))
gxy["goal_xy"] --> gmlp["MLP"] --> merge
x["x_t"] --> unet["1D U-Net"]
t["t"] --> unet
merge --> unet --> eps["ε"]
Tc = context frames, Tp = predicted-waypoint horizon (len_traj_pred).
The V-JEPA2 encoder is loaded from torch.hub and kept frozen; everything
downstream of it is trained. Classifier-free guidance drops the goal tokens
at training time and is hoisted out of the diffusion loop at inference.
Library code at repo root (imported by the scripts below):
model_vjepa_diffusion.py—VJepa2NavModel(V-JEPA2 encoder + diffusion head)vjepa_dataset.py—VJEPADataset: loads trajectories, samples context windows, computes action targets
Scripts, grouped by purpose:
train/train_vjepa.py— main training loop
inference/vjepa_inference_video.py— single-clip inference and renderingrender_clips.py— batched inference over multiple clips with one model loadrank_recon.py— rank RECON trajectories by displacement (helper for picking inference clips)
tests/smoke_test.py— end-to-end dataset → model fwd/bwd → inference smoke testgenerate_spoof_data.py— synthesize a tiny fake dataset for smoke testing
data_prep/data_split.py— writetraj_names.txttrain/test split files for a processed datasetprocess_recon.py— convert the RECON HDF5 release into the on-disk trajectory formatprocess_bags.py— generic ROS-bag → trajectory converter (used for SCAND, tartan_drive, locobot, sacson; dataset selected via-d <tag>againstvint_train/process_data/process_bags_config.yaml). Requires therosbagPython bindings; seedata_prep/setup_rosbag_env.sh.frames_to_video.py— utility
Each script directory is a Python package (has an __init__.py). Run
scripts from the repo root using python -m, e.g.
python -m train.train_vjepa --config config/vjepa.yaml — this puts the
repo root on sys.path so scripts can import the library modules.
Configs live in config/: defaults.yaml, vjepa.yaml, vjepa_test.yaml.
Conda env: train_environment_vjepa.yml.
diffusion_policy/ is the vendored diffusion-policy library
(provides the conditional U-Net and related modules), included as a git
submodule pinned to upstream real-stanford/diffusion_policy.
Clone with submodules and create the conda env:
git clone --recurse-submodules <this-repo-url>
cd vjepa_diffusion_nav
conda env create -f train_environment_vjepa.yml
conda activate vjepa_train
pip install -e diffusion_policy/If you already cloned without --recurse-submodules:
git submodule update --init --recursiveSeveral pieces of training infrastructure are reused as-is from the upstream
visualnav-transformer repo. The relevant module is kept in-tree as
vint_train/:
vint_train/data/data_config.yaml— read byvjepa_dataset.pyto get per-datasetmetric_waypoint_spacing, action statistics, and camera intrinsics for image rectification. Edit this file to add a new dataset.vint_train/data/data_splits/<dataset>/{train,test}/traj_names.txt— the train/test partition format. Each line names a trajectory folder. Generated bydata_split.py(whose--data-splits-dirdefaults tovint_train/data/data_splits).- On-disk trajectory format — a directory per trajectory containing
traj_data.pkl({"position": Nx2, "yaw": N}) plus numbered RGB frames (0.jpg,1.jpg, ...). This is the format produced byprocess_recon.py. - LMDB image cache layout —
vjepa_dataset.pywrites per-split LMDBs next totraj_names.txt(controlled byuse_lmdb_cache: Truein the dataset config).
Nothing in the kept VJEPA code imports vint_train as a Python package;
the dependency is purely on file paths and on-disk formats. The rest of
vint_train/ (NoMaD/ViNT/GNM models, training utils, visualizers) is
unused by this codebase and only kept here so the data-config and
data-splits paths stay valid.
The codebase has been used with the following publicly available navigation datasets:
process_recon.py handles RECON HDF5s directly; for the others, you'll
need a similar preprocessing pass that emits the trajectory layout below.
After preprocessing, each dataset directory should look like:
<dataset_name>/
├── <traj_1>/
│ ├── 0.jpg
│ ├── 1.jpg
│ ├── ...
│ ├── T_1.jpg
│ └── traj_data.pkl
├── <traj_2>/
│ └── ...
Each *.jpg is a forward-facing RGB observation, temporally ordered.
traj_data.pkl is a pickled dict with keys:
"position"—np.ndarray [T, 2], xy-coordinates at each frame"yaw"—np.ndarray [T], yaw at each frame
After splitting, splits live in
vint_train/data/data_splits/<dataset_name>/{train,test}/traj_names.txt.
- Preprocess the raw release into the trajectory format
(
process_recon.pyfor RECON). - Split with
data_split.py:This writespython -m data_prep.data_split -i <processed_dataset_dir> -d <dataset_name> -s 0.8
vint_train/data/data_splits/<dataset_name>/{train,test}/traj_names.txt. - Configure
config/vjepa.yaml: underdatasets:setdata_folder(the processed dataset dir) andtrain/test(the split dirs from step 2). Per-dataset waypoint spacing should matchvint_train/data/data_config.yaml. - Train:
python -m train.train_vjepa --config config/vjepa.yaml
- Inference / rendering:
python -m inference.vjepa_inference_videofor a single clip,python -m inference.render_clipsfor batched rendering of a fixed clip list.
- Lay out the dataset to match the trajectory layout above.
- Append an entry to
vint_train/data/data_config.yaml:<dataset_name>: metric_waypoint_spacing: <avg meters between waypoints> # plus action stats and camera intrinsics as in existing entries
- Run
data_split.pyto producetraj_names.txt. - Add the dataset to
config/vjepa.yamlunderdatasets::<dataset_name>: data_folder: <path_to_dataset> train: vint_train/data/data_splits/<dataset_name>/train/ test: vint_train/data/data_splits/<dataset_name>/test/ end_slack: 0 # trim N frames off each trajectory's end goals_per_obs: 1 negative_mining: True
