Skip to content

Segment Anything Model for large-scale, vectorized road network extraction from maps

License

Notifications You must be signed in to change notification settings

i-dot-ai/sam_road_map

 
 

Repository files navigation

Fork of "Segment Anything Model for Road Network Graph Extraction"

Link to google creds https://drive.google.com/file/d/1e6AJ6tSdS1dVmAF4KuOcWVLpn5_opASH/view?usp=drive_link

Demos

Predicted road network graph in a large region (2km x 2km). sam_road_cover

Predicted road network graphs and corresponding masks in dense urban with complex and irregular structures. sam_road_mask_and_graph

Installation

You need the following:

  • an Nvidia GPU with latest CUDA and driver.
  • the latest pytorch.
  • pytorch lightning.
  • wandb.
  • Go, just for the APLS metric (we should really re-write this with pure python when time allows).
  • and pip install whatever is missing.

Getting Started

SAM Preparation

Download the ViT-B checkpoint from the official SAM directory. Put it under:
-sam_road
--sam_ckpts
---sam_vit_b_01ec64.pth

Data Preparation

Refer to the instructions in the RNGDet++ repo (https://github.com/TonyXuQAQ/RNGDetPlusPlus) to download City-scale and SpaceNet datasets. Put them in the main directory, structure like:
-sam_road
--cityscale
---20cities
--spacenet
---RGB_1.0_meter

Download links copied from https://github.com/TonyXuQAQ/RNGDetPlusPlus

SpaceNet

https://drive.google.com/uc?id=1FiZVkEEEVir_iUJpEH5NQunrtlG0Ff1W

The data_split.json is copied from the dataset.json in this folder.

CityScale

https://drive.google.com/uc?id=1R8sI1RmFe3rUfWMQaOfsYlBDHpQxFH-H

Find the 20cities folder under this folder.

Then, run "python generate_labes.py" under both dirs.

Training

City-scale dataset:
python train.py --config=config/toponet_vitb_512_cityscale.yaml

SpaceNet dataset:
python train.py --config=config/toponet_vitb_256_spacenet.yaml

You can find the checkpoints under lightning_logs dir.

Inference

python inferencer.py --config=path_to_the_same_config_for_training --checkpoint=path_to_ckpt
This saves the inference results and visualizations.

Inferencing with our checkpoints:

Cityscale:

python inferencer.py --config=config/toponet_vitb_512_cityscale.yaml --checkpoint=/path_to/cityscale_vitb_512_e10.ckpt

Spacenet:

python inferencer.py --config=config/toponet_vitb_256_spacenet.yaml --checkpoint=/path_to/spacenet_vitb_256_e10.ckpt

Test

Go to cityscale_metrics or spacenet_metrics, and run
bash eval_schedule.bash

About

Segment Anything Model for large-scale, vectorized road network extraction from maps

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 100.0%