How feliciaxyao/navmorph works
1. What this repo is
NavMorph is a VLN-CE system for continuous navigation in Habitat. Its core architecture combines imitation learning, a self-evolving world model, and contextual memory to improve instruction-following in unseen environments.
2. Top-level execution
run.py is the general entrypoint, while run_r2r/main.bash is the main orchestration script for R2R training/evaluation. The YAML files under run_r2r/ and vlnce_baselines/config/r2r_configs/ select experiment variants such as Seq2Seq, CMA, augmentation, and tuning modes.
3. Environment and simulation boundary
The repo depends on external Habitat-Lab/Habitat-Sim and Matterport3D scenes. vlnce_baselines/common/environments.py and env_utils.py wrap the simulator, expose episode state, and normalize camera/configuration details. This is the boundary where raw scene observations become model inputs.
4. Data and asset layer
Runtime assets are kept outside the code path in data/ and pretrained/: datasets, scene reconstructions, pretrained visual backbones, BERT weights, waypoint predictors, and saved checkpoints. The README’s folder structure is important because many modules load weights and dataset encodings from these paths directly.
5. Instruction understanding
Natural-language instructions are handled by vlnce_baselines/models/encoders/instruction_encoder.py, with BERT/XLM-R-related assets under vlnce_baselines/bert-base-uncased/ and data/instruction/. This produces the language embedding that conditions the navigation policy and world model.
6. Visual perception
Visual features come from vlnce_baselines/models/encoders/clip.py and resnet_encoders.py. These encoders turn RGB observations into compact embeddings that are fused with language and memory state. This is the main observation-to-feature path for the agent.
7. NavMorph core world model
The central policy/world-model stack lives in vlnce_baselines/models/Policy_ViewSelection_ETP.py and the models/etp/ package. vilmodel_cmt.py, vlnbert_init.py, and nerf.py indicate a multimodal transformer plus NeRF-style latent scene modeling. This is the “self-evolving world model” that predicts how the environment changes and supports lookahead planning.
8. Memory and context evolution
Contextual Evolution Memory is implemented across utils_p/memory.py, utils_p/prompt.py, and related utilities. This subsystem stores scene-contextual state across time, helping the agent adapt online instead of relying only on the current observation window.
9. Navigation decision layer
The action-selection/policy boundary is in vlnce_baselines/models/policy.py, graph_utils.py, and common/transformer.py. These modules convert fused multimodal state into navigation actions, view selection, and trajectory decisions.
10. Waypoint and semantic mapping support
The vlnce_baselines/waypoint_networks/ package is a separate perception/planning aid. img_segmentor_model.py, resnetUnet.py, and semantic_grid.py build semantic spatial maps and waypoint predictions, which feed the higher-level policy and are tied to the pretrained waypoint checkpoints mentioned in the README.
11. Training loops
There are multiple trainer paths: base_il_trainer.py for imitation-learning scaffolding, dagger_trainer.py for dataset aggregation, and ss_trainer_ETP.py for the self-supervised / world-model-oriented training path. common/recollection_dataset.py suggests replay/recollection data support for iterative training.
12. Losses, metrics, and evaluation
utils_p/losses.py, utils_p/metrics.py, and common/aux_losses.py provide optimization objectives and reporting. These modules separate training signals from model code, which is useful for diagramming the system as “perception/policy/model” vs. “optimization/evaluation.”
13. Configuration and experiment management
vlnce_baselines/config/default.py plus the task-specific YAMLs define the experiment graph: dataset choice, model variant, training mode, and evaluation behavior. The README also notes dataset-specific camera settings, which are a real architectural constraint because R2R and RxR use different HFOV/VFOV assumptions.
14. Practical dependency boundaries
The repo is not self-contained: it relies on Habitat, Matterport3D scenes, external pretrained encoders, and extra native/ML packages like torch_kdtree and tinycudann. Those dependencies materially shape the architecture because they determine what runs in simulation, what is learned, and what is loaded as fixed pretrained infrastructure.
Main entry points: Policy_ViewSelection_ETP.py NavMorph policy · environments.py env wrappers · vilmodel_cmt.py ETP stack · data data & weights
Components 21
Entry & runs
Top-level launch scripts and experiment selection.
Environment
Habitat simulation boundary and runtime adapters.
- env wrappers · Habitat environment wrappers and state normalization.
vlnce_baselines/common/environments.py - env utils · Helpers for simulator setup, camera, and episode handling.
vlnce_baselines/common/env_utils.py
Models
Multimodal encoders, policy, world model, and planning components.
- instruction enc · Encodes navigation instructions into language embeddings.
vlnce_baselines/models/encoders/instruction_encoder.py - visual enc · RGB feature extraction via CLIP and ResNet backbones.
vlnce_baselines/models/encoders/clip.py - ETP stack · Multimodal transformer and latent scene modeling core.
vlnce_baselines/models/etp/vilmodel_cmt.py - NeRF latent · NeRF-style latent scene representation used by the world model.
vlnce_baselines/models/etp/nerf.py - policy sel · Navigation action selection and view choice boundary.
vlnce_baselines/models/policy.py - NavMorph policy · Main policy that combines encoders, memory, and ETP components.
vlnce_baselines/models/Policy_ViewSelection_ETP.py - context memory · Contextual evolution memory across time and episodes.
utils_p/memory.py - waypoint net · Semantic grid and waypoint prediction support.
vlnce_baselines/waypoint_networks/semantic_grid.py
Training
Training loops, datasets, losses, and evaluation support.
- IL trainer · Imitation-learning training scaffold.
vlnce_baselines/common/base_il_trainer.py - DAgger · Dataset aggregation training path.
vlnce_baselines/dagger_trainer.py - SS ETP · Self-supervised / world-model-oriented training path.
vlnce_baselines/ss_trainer_ETP.py - recollect ds · Recollection and replay dataset support.
vlnce_baselines/common/recollection_dataset.py - losses · Training objectives and auxiliary losses.
utils_p/losses.py - metrics · Reporting and success metrics.
utils_p/metrics.py
Assets
External datasets, pretrained weights, and instruction resources.
- data & weights · Datasets, instruction resources, pretrained backbones, and checkpoints.
data
Config
Experiment configuration and task variants.
- R2R configs · Task and experiment variants for Seq2Seq, CMA, augmentation, and tuning.
run_r2r/r2r_vlnce.yaml - default cfg · Base configuration wiring for the codebase.
vlnce_baselines/config/default.py
Connections 24
- run.py → default cfg: loads · Entry point resolves the base experiment configuration.
- run.py → env wrappers: starts · Launches training or evaluation in the Habitat environment boundary.
- R2R bash → R2R configs: selects · Shell orchestration chooses an R2R variant.
- R2R configs → default cfg: extends · Task configs build on the base configuration.
- default cfg → env utils: configures · Configuration sets simulator and camera parameters.
- env wrappers → env utils: uses · Wrappers delegate simulator setup and normalization details.
- env wrappers → instruction enc: observes · Language instructions are paired with episodes for conditioning.
- env wrappers → visual enc: observes · Raw RGB observations are exposed to visual encoders.
- visual enc → NavMorph policy: features · Vision embeddings feed the main policy stack.
- instruction enc → NavMorph policy: features · Language embeddings condition the policy and world model.
- context memory → NavMorph policy: state · Persistent context is fused into policy decisions.
- NavMorph policy → ETP stack: routes · Main policy delegates multimodal reasoning to the ETP stack.
- ETP stack → NeRF latent: models · World model maintains a latent scene representation.
- ETP stack → policy sel: predicts · Transformer outputs support action and view selection.
- waypoint net → policy sel: guides · Waypoint predictions inform navigation decisions.
- IL trainer → losses: optimizes · Trainer consumes task and auxiliary losses.
- IL trainer → metrics: evaluates · Trainer reports navigation metrics.
- DAgger → recollect ds: trains on · DAgger uses aggregated rollout data.
- SS ETP → ETP stack: trains · Self-supervised path targets the world-model stack.
- SS ETP → recollect ds: reuses · Iterative training can draw from recollection data.
- NavMorph policy → data & weights: loads · Policy and encoders rely on pretrained weights and datasets.
- instruction enc → data & weights: loads · Instruction models depend on BERT/XLM-R resources and instruction data.
- visual enc → data & weights: loads · Visual encoders use pretrained backbones and checkpoints.
- waypoint net → data & weights: loads · Waypoint module consumes pretrained waypoint models.