MagRoad introduces a novel path-centric reasoning approach for extracting vectorized road networks, specifically designed to handle the challenges of off-road and wild environments. Unlike node-centric methods (sam_road series), our model focuses on the connectivity and topology of paths, enabling robust extraction in complex terrains.
Node-centric models suffer from path ambiguity due to sparse features, path-centric sampling resolves path ambiguity by leveraging evidence along the entire edge.
Key Features:
-
🤖Robust Extraction Pipeline: Path-centric reasoning for reliability in complex terrains.
-
🖱️Interactive Annotation: Lightweight tool for faster, low-effort annotation and refinement.
-
🌍 WildRoad Dataset: A new benchmark for challenging scenarios.
MaGRoad demonstrates effective road extraction results across four diverse datasets: City-Scale, Global-Scale, SpaceNet, and WildRoad.
| Manual Annotation (QGIS) | Interactive Annotation (Ours) |
|---|---|
![]() |
![]() |
To address the bottleneck of creating large-scale vectorized datasets, we developed the first interactive road extraction algorithm and integrated it into a seamless Web Application. It transforms the workflow: instead of tedious manual plotting (e.g., QGIS), our model intelligently automates path connectivity based on sparse user clicks, drastically reducing annotation time.
📢 Open Source: The full codebase for both the interactive algorithm and the annotation tool has been released here.
-
Clone the repository
git clone https://github.com/xiaofei-guan/MaGRoad.git cd MaGRoad -
Environment Setup
conda create -n magroad python=3.8 # we use python 3.8.19 conda activate magroad pip install -r requirements.txtNote: Ensure you have PyTorch and CUDA installed compatible with your system.
Please download the ViT-B checkpoint from the official SAM repository and place it under sam/ckpt:
mkdir -p sam/ckpt
# Save sam_vit_b_01ec64.pth hereWe support our new WildRoad benchmark and the Global-Scale dataset. Please download the data and place it into the wildroad and globalscale folders, respectively.
WildRoad Dataset:
cd wildroad
bash preprocess_data/preprocess.sh ./wild_road ./wild_road_GLG ./wild_road_mask 16GlobalScale Dataset:
cd globalscale
bash preprocess_data/preprocess.sh ./Globalscale ./Globalscale_GLG ./Globalscale_mask 16The expected directory structures after preprocessing are shown below:
| WildRoad Structure | Global-Scale Structure |
|---|---|
wildroad/ |
globalscale/ |
Note for City-Scale and SpaceNet: The
mainbranch is dedicated to WildRoad and Global-Scale experiments. To reproduce results on City-Scale or SpaceNet (following thesam_roaddata preparation), please switch to the legacy branch:git checkout cityspace
Train the model with the specified configuration.
python train.py --config=config/toponet_vitb_1024_wild_road.yaml
# Example with resume
python train.py --config=config/toponet_vitb_1024_wild_road.yaml --resume=<your_ckpt_path>Compute the mask and topo connectivity threshold.
bash compute_threshold/test.sh --config config/toponet_vitb_1024_wild_road.yaml --checkpoint <your_ckpt_path>Update mask and topo threshold
-
ITSC_THRESHOLD: 0.133
-
ROAD_THRESHOLD: 0.839
-
TOPO_THRESHOLD: 0.373
python inferencer.py --config=config/toponet_vitb_1024_wild_road.yaml --checkpoint=<your_ckpt_path>Evaluate the model using APLS and TOPO metrics.
# Usage: bash <script> <gt_dir> <pred_dir> <output_dir> <params...>
bash wildroad_metrics/apls_topo_parallel.sh wildroad/wild_road/test pred_dir wildroad_metrics/result/ 32 32🎉 Great News! We have released the pre-trained checkpoints for all major datasets! You can now directly reproduce our results without training from scratch.
| Dataset | Download Link |
|---|---|
| WildRoad | Google Drive |
| Global-Scale | Google Drive |
| SpaceNet | Google Drive |
Download the weights and place them in your checkpoint directory to get started!
- Release automated extraction code (Training & Inference).
- Organize and clean up dataset preparation scripts.
- Release WildRoad Dataset.
- Release pre-trained model checkpoints.
- Release Interactive Annotation Tool and GUI.
If you find this work useful for your research, please cite our paper:
@article{magroad2025,
title={Beyond Endpoints: Path-Centric Reasoning for Vectorized Off-Road Network Extraction},
author={Guan, Wenfei and Mei, Jilin and Shen, Tong and Wu, Xumin and Wang, Shuo and Min, Chen and Hu, Yu},
journal={arXiv preprint arXiv:2512.10416},
year={2025}
}We sincerely thank the authors of the following open-source projects for their contributions, which served as important foundations for our work:




