A Flask app that finds sidewalk damage — cracks, potholes, heaving — in walking-style videos.
It sends a video to Amazon Bedrock (TwelveLabs Pegasus) for damage detection, matches the per-frame GPS track to Overture Maps sidewalk segments, and shows everything on a Mapbox map with a run-level summary.
- Find footage on a map — the main way to get a video: browse a live map of Mapillary street-level imagery, click a route, and the app builds a video + GPS track from it automatically.
- Analyze it — uploads to S3, runs it through Pegasus (with an optional verification pass), and joins each frame to the nearest Overture sidewalk segment.
- See results — a map, a severity/damage-type summary, and a per-segment table, all cross-linked.
- Videos can also come from an existing local file or a browser upload, if you'd rather not use the map picker.
- Python 3.10+
- The AWS CLI, an AWS account (for S3 + Bedrock)
- A Mapbox token — powers the map
- A Mapillary token — powers the map-based video picker (the main way to get a video here); skip only if you'll always supply your own videos
- FFmpeg — used to encode video when building from the map
If you've never set this up before, here's the shape of it (menus may shift over time — check the AWS docs if something doesn't match):
- Create an S3 bucket — AWS Console → S3 → Create bucket. Note the name/region for
.env. - Enable Bedrock model access — AWS Console → Bedrock → Model access → request access to
the TwelveLabs Pegasus model. Off by default per account — easy to miss, and causes
AccessDenied/ResourceNotFounderrors if skipped. - Create an IAM user — AWS Console → IAM → Users → Create user. Attach
AmazonS3FullAccessandAmazonBedrockFullAccess(broad, fine for a personal project — scope down for anything else). - Log in via the AWS CLI — either create an access key for that user and run
aws configure, or use IAM Identity Center / SSO withaws sso login(needsbotocore[crt], already inrequirements.txt). Either way boto3 picks up the credentials automatically — no keys go in.env. Check withaws sts get-caller-identity. - Note your AWS account id — same command as above, or top-right in the console. You'll need
it for
AWS_BUCKET_OWNER.
git clone <this repo>
cd sidewalk-analyzer
python3 -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
pip install -r requirements.txt
cp .env.example .envFill in .env:
| Variable | Purpose |
|---|---|
MAPBOX_ACCESS_TOKEN |
Required — powers the map. |
MAPILLARY_ACCESS_TOKEN |
Needed for the map-based video picker and Mapillary search. |
AWS_BUCKET_NAME |
The S3 bucket from step 2.1. |
AWS_REGION |
Region for S3/Bedrock (default us-east-1). |
AWS_MODEL_ID |
Bedrock model id for Pegasus (default twelvelabs.pegasus-1-2-v1:0). |
AWS_BUCKET_OWNER |
Your AWS account id (step 2.5). |
A handful of detection-tuning knobs also exist with sane defaults — no need to touch .env for
them, they're editable from the Settings button once the app is running.
Per-video CSV (if bringing your own video) — csvs/<name>.csv needs lat/long columns, one
row per frame, matching the video's basename.
source .venv/bin/activate
python app.pyOpen http://127.0.0.1:5000/. Health check: GET /api/health.
- Find on map (default tab) — pan/zoom, click a highlighted route, then Create video. Once it's built, an Analyze this video button appears right there — no need to go find it.
- Use existing — pick an already-local video and click Analyze video, or View results if it's already been analyzed.
- Upload — add an
.mp4(and its GPS-track CSV, if you have one) from the browser. - Results: a map, severity/damage-type summary, and per-segment table — click any segment to jump to it.
- Settings (top right) — tune detection sensitivity and matching distances. Tokens and AWS
config stay
.env-only, on purpose.
app.py— Flask entrypointsidewalk_analyzer_web/routes.py— routes and API surfacesidewalk_analyzer_web/analysis.py— upload → Pegasus → Overture join + saved-results IOsidewalk_analyzer_web/insights.py— per-run summary statssidewalk_analyzer_web/pegasus.py,overture.py,mapillary.py,aws_errors.py— service helperssidewalk_analyzer_web/sequence_builder.py— Mapillary sequence id → CSV +.mp4buildersidewalk_analyzer_web/settings.py,env.py— Settings schema +.envread/write
The map-based video builder was inspired by the workflow of Stefal/mapillary_download — credit to Stefal for the idea. That repo has no LICENSE file, so no code from it is used here; this is an independent implementation against the official public Mapillary Graph API.