Agentic post-disaster loss inventory. A policyholder uploads the messy photo pile from a fire/flood/storm; OpenCV 5 cross-examines every photo (sharpness, exposure, duplicate views, damage candidates, room grouping) and an agent loop turns those findings into decisions — rejecting unusable photos, demanding the missing shots, escalating contradictions to a human, and finally emitting a reconciled inventory with per-item confidence. The visual evidence provably changes what the agent does next: every round's perception digest and decision are recorded in a judge-readable trace.
Built for the OpenCV + AWS competition (Agentic Vision path). OpenCV 5.0.0 performs
all substantive image analysis; the whole pipeline runs serverless on AWS
(Lambda container image on Graviton/arm64 + S3 + DynamoDB) in region ap-southeast-2.
python -m venv .venv
.venv\Scripts\pip install -r requirements-dev.txt # pinned: opencv-python==5.0.0.93, numpy==2.5.4
.venv\Scripts\python -m pytest tests # 15 tests: analysis ground truth + agent e2e
set "AFTERMATH_STORE=json" && .venv\Scripts\python -m app.api.local_server
# open http://127.0.0.1:8000Generate the sample dataset and run the scripted evaluation (both reproducible, no API calls, ~30 s):
.venv\Scripts\python -m eval.make_dataset # -> eval/dataset/*.jpg + manifest.json
.venv\Scripts\python -m eval.run_eval # -> eval/results/results.{json,md}Optional local smoke test of the real HTTP stack: .venv\Scripts\python smoke_local.py.
Requires: AWS CLI v2 logged in (aws login). No Docker needed — the zip
deploy stages aarch64 wheels directly:
# provider defaults to deterministic policy ("mock"); add an LLM for live demos:
powershell -File deploy\deploy-zip.ps1 -LlmProvider anthropic -LlmKey sk-ant-... -LlmModel claude-haiku-4-5(On Linux/CloudShell: LLM_PROVIDER=openai LLM_KEY=... bash deploy/deploy.sh.
A Docker-based variant deploy\deploy.ps1 builds the same thing as a container
image via ECR.)
The script stages pinned aarch64 wheels (OpenCV 5 headless + numpy + requests),
uploads the zip to S3, creates the S3 evidence bucket, the DynamoDB session
table, a least-privilege IAM role, the Lambda function (python3.13, arm64/
Graviton), and an API Gateway HTTP API as the public endpoint — note that
Function URLs with anonymous auth are blocked by this account type's managed
policies, which is why the public entry is API Gateway. Current deployment:
https://jw8tmot50b.execute-api.ap-southeast-2.amazonaws.com (verify with
/healthz). Teardown: powershell -File deploy\teardown.ps1.
LLM provider options (AFTERMATH_LLM_PROVIDER): mock (deterministic policy —
used by tests/eval), anthropic, openai, gemini (key via AFTERMATH_LLM_KEY,
model via AFTERMATH_LLM_MODEL). The LLM receives the same structured perception
digest as the policy and its output is validated against the live session; on any
invalid or failed LLM response the loop falls back to the policy and records that
in the trace — the demo cannot break because of a provider outage.
| Method | Path | Purpose |
|---|---|---|
| GET | /healthz |
liveness + OpenCV version |
| POST | /api/session |
open a claim {incident_type, items:[{name,room,qty}], notes} |
| POST | /api/session/{id}/photo?name=&item= |
upload photo (raw body) — runs full OpenCV 5 analysis |
| POST | /api/session/{id}/round |
run one agent round (perception -> decision -> action) |
| POST | /api/session/{id}/attribute |
tag a photo with {photo_id, item_id} |
| POST | /api/session/{id}/ack |
mark a human-review escalation resolved |
| GET | /api/session/{id} |
full session incl. rounds trace and report |
| GET | /api/session/{id}/thumb/{photo} |
server-side thumbnail (cv2.resize) |
8 scripted sessions with a simulated claimant: 7/7 counted sessions completed with
all items confirmed (avg 2.4 rounds, avg 25 ms OpenCV analysis per photo); the 8th
is a designed failure case (claimant never produces a usable photo) that correctly
ends unresolved instead of inventing evidence. Duplicate detection, quality gates,
quantity interrogation and contradiction escalation are all exercised and asserted in
tests/ with known ground truth.