Skip to content

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

Sidewalk Analyzer

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.

What it does

  • 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.

1. Prerequisites

  • 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

2. AWS setup

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):

  1. Create an S3 bucket — AWS Console → S3 → Create bucket. Note the name/region for .env.
  2. 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/ResourceNotFound errors if skipped.
  3. Create an IAM user — AWS Console → IAM → Users → Create user. Attach AmazonS3FullAccess and AmazonBedrockFullAccess (broad, fine for a personal project — scope down for anything else).
  4. Log in via the AWS CLI — either create an access key for that user and run aws configure, or use IAM Identity Center / SSO with aws sso login (needs botocore[crt], already in requirements.txt). Either way boto3 picks up the credentials automatically — no keys go in .env. Check with aws sts get-caller-identity.
  5. Note your AWS account id — same command as above, or top-right in the console. You'll need it for AWS_BUCKET_OWNER.

3. Setup

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 .env

Fill 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.

4. Run it

source .venv/bin/activate
python app.py

Open http://127.0.0.1:5000/. Health check: GET /api/health.

5. Using it

  • 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.

Code layout

  • app.py — Flask entrypoint
  • sidewalk_analyzer_web/routes.py — routes and API surface
  • sidewalk_analyzer_web/analysis.py — upload → Pegasus → Overture join + saved-results IO
  • sidewalk_analyzer_web/insights.py — per-run summary stats
  • sidewalk_analyzer_web/pegasus.py, overture.py, mapillary.py, aws_errors.py — service helpers
  • sidewalk_analyzer_web/sequence_builder.py — Mapillary sequence id → CSV + .mp4 builder
  • sidewalk_analyzer_web/settings.py, env.py — Settings schema + .env read/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.

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages