Step-by-Step Guide: How the OpenStreetMap AI Helper Blueprint works
Contributing to OpenStreetMap with the help of AI requires a model trained on an appropriate dataset.
We provide tools and example notebooks to:
- Creating a custom dataset using ground truth data from OpenStreetMap
- Finetuning a YOLO detector using the custom dataset
Once you have a trained model, you can Run Inference in order to find the type of elements you used to train the model (in the example, we chose swimming pools).
Overview
The inference has 4 core stages:
Step 1: Pick a point in the map and download data around it
After a point is selected, a bounding box is computed around it based on the margin
argument.
All the existing elements of interest are downloaded from OpenStreetMap using get_elements
.
All the tiles are downloaded from MapBox and joined to create a stacked image
using download_stacked_image_and_mask
. The elements are grouped and converted to a ground truth mask
for later usage.
Step 2: Run inference on the stacked image
The stacked image is divided into tiles to run inference using tile_prediction
.
For each tile, we run the trained YOLO detector.
If an object of interest is detected, we pass the bounding box to the provided SAM2 model to obtain a segmentation mask.
All the predictions are aggregated into a single stacked output mask
.
Step 3: Find existing, new and missed polygons
All the individual mask blobs are converted to polygons for both the stacked output mask
and the ground truth mask
.
Based on overlap, all the polygons are categorized into existing
(green), new
(yellow) or missed
(red).
The really relevant ones are the new
(yellow), the others just serve as reference on how the model behaves
for polygons already existing in OpenStreetMap.
Step 4: Review, filter and upload the new
polygons to OpenStreetMap
The new
polygons can be manually reviewed and filtered:
The ones you chose to keep
will be uploaded to OpenStreetMap using upload_osm
.
Warning
Once uploaded, the changes will be added to OpenStreetMap, so ensure you're confident about the ones you've kept.
🎨 Customizing the Blueprint
To better understand how you can tailor this Blueprint to suit your specific needs, please visit the Customization Guide.
🤝 Contributing to the Blueprint
Want to help improve or extend this Blueprint? Check out the Future Features & Contributions Guide to see how you can contribute your ideas, code, or feedback to make this Blueprint even better!