DEM CNN is a modified Faster R-CNN model from the conference proceedings article "Road Obstacles Detection on Digital Elevation Model". This repository includes dataset preparation utilities, model training/evaluation/saving scripts and an inference example. The article proposes methods of pre- and post-processing of Digital Elevation Models data, including the sliding window algorithm with reduction to the target resolution. Experiments have been conducted with different approaches. As a result of research, an artificial neural network has been developed and trained to work with 2.5D data.
-
Set up conda environment:
conda env create -n dem_cnn -f environment.yml conda activate dem_cnn
-
Install dependencies:
pip install -r requirements.txt
Be aware that preinstalled CUDA is required to run the project on GPU (instructions here).
Refer to inference.ipynb for an example of how to use DEM CNN for inference. It implements image+annotation preprocessing, inference, postprocessing and visualization partially using this repository's tools. Your model can be loaded from MLflow registry or from local file.
Due to proprietary nature of original work's dataset, it cannot be provided for training the model. However, this repository holds extract_data.ipynb notebook that can be used to generate a dataset of your own using DEMs and segmentation masks with roads and annotated obstacles. Use dataset_viewer.ipynb to view generated files.
After obtaining a dataset, MLflow tracking server has to be started. If you do not have it in your server already, you can start it locally:
mlflow uiMLflow will be used to store all artifacts and metrics, and it is only implemented option for experimenting.
To train and evaluate DEM CNN, follow these steps:
-
Customize
config.pyto fit your needs, leave unknown parameters to you as is. -
Run training:
python3 train.py
-
After successful training, register model in MLflow manually. Set test tag to registered model in registry. This signifies that model is ready for evaluation and saving.
-
Evaluate model:
python3 evaluate.py
-
If evaluation has proven that model is ready for deployment, save it:
python3 save_model.py
It is generally preferred to save model's state dictionary so it can be loaded later in your project without preserving
original project structure. If you saved model's state dictionary, getting weights/dem_cnn_sd.pt file as a result, use
create_model function from model/tools.py and load_state_dict method from PyTorch to load it, similar to how it is done in inference.ipynb.
Original pretrained DEM CNN model weights will not be distributed as it is used in proprietary software. The results, however, can be replicated and surpassed using this repository specifically for your data.
This model achieves global mAP: 42.02% and mAP@50: 67.52% on test dataset with various data of different quality. However, when provided with a dataset of DEMs with resolution of 2 cm/pixel, evaluation metrics are better - global mAP: 52.03%, mAP@50: 77.57%.
Parameters for training original model and predicting with it are by default in config.py (classes are also in there).
It is worth noting that DEM CNN usage is not limited to detecting only road obstacles. Model can be used to detect any objects on DEMs, as long as they are located on flat surfaces and are not noisy. Just rasterize regions of interest during inference with such flat surfaces and make predictions on them to get similar results.
@inproceedings{makarov2025dem-cnn,
title = {Road Obstacles Detection on Digital Elevation Model},
organization = {Concern CSRI Elektropribor},
booktitle = {27th Conference of Young Scientists "Navigation and Motion Control" (with international participants)},
author = {Makarov, Georgy V. and Gontar, Denis A.},
year = {2025},
pages = {}
}