This repository provides the basic pipeline for HeightMatch using INRIA_Buildings as an example.
The recommended order is:
- Prepare the pretrained checkpoint
- Generate synthetic height maps
- Train the model
- Test the model
Before training, make sure the pretrained DINOv2 checkpoint is available in the pretrained folder.
Required file:
pretrained/dinov2_small.pth
Download link:
After downloading, rename the file to:
dinov2_small.pth
and place it in:
pretrained/
Run generate_synthetic_height.py to generate synthetic height maps from RGB images.
Example for one city:
python3 generate_synthetic_height.py \
--imgdir /home/Datasets/RSSeg/INRIA/Austin/image \
--outdir /home/Datasets/RSSeg/INRIA/Austin/heightThe script only accepts one imgdir and one outdir at a time.
Therefore, if the INRIA dataset is organized by multiple cities, you need to run the script once for each city.
Example:
python3 generate_synthetic_height.py \
--imgdir /home/Datasets/RSSeg/INRIA/Austin/image \
--outdir /home/Datasets/RSSeg/INRIA/Austin/height
python3 generate_synthetic_height.py \
--imgdir /home/Datasets/RSSeg/INRIA/Chicago/image \
--outdir /home/Datasets/RSSeg/INRIA/Chicago/heightThe generated height maps are saved in the folder specified by --outdir.
Before training, make sure the split files are ready, for example:
splits/inria_buildings/
├── val.txt
├── test.txt
└── 0.5/
├── labeled.txt
└── unlabeled.txt
Each line should contain:
image_path label_path height_path
Example:
Austin/image/austin1.tif Austin/label/austin1.tif Austin/height/austin1.png
The third path must point to the generated synthetic height map.
Training is launched with train.sh.
Example settings in train.sh:
dataset='inria_buildings'
split='0.5'
method='heightmatch'
model='dinov2_small'Run training:
bash train.sh 4Here, 4 means using 4 GPUs.
The checkpoints are saved to:
saved/inria_buildings/0.5/heightmatch/dinov2_small/
Testing is launched with test.sh.
Make sure the settings in test.sh are consistent with training:
dataset='inria_buildings'
split='0.5'
method='heightmatch'
model='dinov2_small'Run testing:
bash test.shThe testing script loads:
saved/inria_buildings/0.5/heightmatch/dinov2_small/best.pth
The results are written to:
test_results.xlsx
# Step 0: prepare pretrained checkpoint
# Put pretrained/dinov2_small.pth in the pretrained folder
# Step 1: generate synthetic height maps
python3 generate_synthetic_height.py \
--imgdir /home/Datasets/RSSeg/INRIA/Austin/image \
--outdir /home/Datasets/RSSeg/INRIA/Austin/height
# Repeat for other cities if needed
# Step 2: train
bash train.sh 4
# Step 3: test
bash test.sh