close
Skip to content

xiaofei-guan/MaGRoad

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Beyond Endpoints: Path-Centric Reasoning for Vectorized Off-Road Network Extraction

License: MIT Framework: PyTorch

MagRoad Results

📖 Introduction

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.

MagRoad Results

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.

📊 Demo

🤖 Automated Extraction

MagRoad Results

MaGRoad demonstrates effective road extraction results across four diverse datasets: City-Scale, Global-Scale, SpaceNet, and WildRoad.

🖱️ Interactive Annotation Tool

Manual Annotation (QGIS) Interactive Annotation (Ours)
Manual Interactive

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.


🛠️ Quick Start

  1. Clone the repository

    git clone https://github.com/xiaofei-guan/MaGRoad.git
    cd MaGRoad
  2. Environment Setup

    conda create -n magroad python=3.8 # we use python 3.8.19
    conda activate magroad
    pip install -r requirements.txt

    Note: Ensure you have PyTorch and CUDA installed compatible with your system.

📥 Model Preparation

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 here

📂 Data Preparation

We 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 16

GlobalScale Dataset:

cd globalscale
bash preprocess_data/preprocess.sh ./Globalscale ./Globalscale_GLG ./Globalscale_mask 16

The expected directory structures after preprocessing are shown below:

WildRoad Structure Global-Scale Structure
wildroad/
├── preprocess_data/
├── wild_road/ # Raw Data
│ ├── train_patches/
│ ├── val_patches/
│ └── test_patches/
├── wild_road_GLG/ # Processed Graphs
│ ├── train_patches/
│ ├── val_patches/
│ └── test_patches/
└── wild_road_mask/ # Processed Masks
├── train_patches/
├── val_patches/
└── test_patches/
globalscale/
├── preprocess_data/
├── Globalscale/ # Raw Data
│ ├── train/
│ ├── val/
│ ├── in-domain-test/
│ └── out_of_domain/
├── Globalscale_GLG/ # Processed Graphs
│ ├── train_GLG/
│ └── out_of_domain_GLG/
└── Globalscale_mask/ # Processed Masks
├── train/
└── out_of_domain/

Note for City-Scale and SpaceNet: The main branch is dedicated to WildRoad and Global-Scale experiments. To reproduce results on City-Scale or SpaceNet (following the sam_road data preparation), please switch to the legacy branch:

git checkout cityspace

🚀 Usage

1. Training

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>

2. Threshold

Compute the mask and topo connectivity threshold.

bash compute_threshold/test.sh --config config/toponet_vitb_1024_wild_road.yaml --checkpoint <your_ckpt_path>

3. Inference

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>

4. Evaluation

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

🎁 Model Zoo

🎉 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!

📝 To-Do List

  • 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.

📍 Citation

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}
}

🤝 Acknowledgements

We sincerely thank the authors of the following open-source projects for their contributions, which served as important foundations for our work:

About

MaGRoad: Path-centric reasoning for vectorized off-road network extraction. Includes WildRoad, the first large-scale vectorized off-road road network dataset.

Resources

License

Stars

Watchers

Forks

Contributors