Pedestrian routing that scores how walkable each part of a proposed route is, based on a semantic segmentation model applied to OpenStreetMap tile imagery.
Given a start and an end point, the backend:
- Asks OSRM for a walking route.
- Samples the route every N meters.
- Downloads the OSM raster tile around each sample and builds a 512x512 image.
- Runs an ONNX segmentation model on the image and computes a per-tile passability score from the fraction of pixels classified as walkable, grass, road, obstacle, etc.
- Returns the route geometry, the sampled nodes with their scores, and a summary of average passability, distance, and estimated duration.
The frontend renders the route on a Mapbox map, colored by passability, and lets the user pick start and end via search or clicks.
React 19, Vite, FastAPI, ONNX Runtime for inference, Caddy for reverse proxy
Two environment files are read at build and runtime:
- Root
.env(used by docker compose for build args). Required entry:VITE_MAPBOX_TOKEN=pk.your-mapbox-public-token frontend/.env(read by Vite when runningnpm run devoutside Docker). Required entries:VITE_API_URL=http://localhost:8000 VITE_MAPBOX_TOKEN=pk.your-mapbox-public-token
docker compose up -d --build
open http://localhost:3000
- Frontend is served at
http://localhost:3000(nginx inside the container). - Backend is directly reachable at
http://localhost:8000for debugging. - The frontend calls
/api/*, which the container's own nginx proxies to the backend service on the internal docker network. - Be careful as docker uses arm64 images, so it may require changes for x86 hosts or try running prod containers.
The production stack adds a Caddy service that owns ports 80 and 443, handles HTTPS with automatically-provisioned Let's Encrypt certificates, and reverse-proxies to the internal frontend and backend containers.
Prerequisites on the VM:
- DNS A records for
mobimpai.ruandwww.mobimpai.rupointing at the VM. - Ports 80 and 443 open in the firewall.
- Repo checked out at
/home/mobimpai. - Root
.envwith the Mapbox token.
Start the stack:
cd /home/mobimpai
docker compose -f docker-compose.prod.yml up -d --build
docker compose -f docker-compose.prod.yml logs -f caddy
Wait for Caddy to log certificate obtained successfully. The site is then
live at https://mobimpai.ru.
For each sampled point on the route:
- Fetch the surrounding OSM tiles and stitch a 512x512 image centered on the coordinate.
- Convert to a float32 NCHW tensor in the range [0, 1].
- Run the ONNX session:
session.run(["logits"], {"pixel_values": input}). - Take
argmaxover the class axis to get a per-pixel class map. - Compute score (see formula in the code )
Class weights live in backend/config.py and need to match the semantics of the trained model