FloodSense-PK — Devpost Project Story
Inspiration
In 2022, floods displaced 33 million people in Pakistan. Every year, 5–8 million Pakistanis are affected and $3–4 billion is lost — yet many rural communities get less than 6 hours of warning.
The cruelest irony? The exact moment a flood peaks is the moment we go blind. Monsoon clouds block every optical satellite, field surveys become slow and dangerous, and disaster authorities are left making life-or-death decisions with stale data.
We asked ourselves: what if we could see through the clouds? Sentinel-1's radar can — it actively transmits pulses that penetrate clouds, rain, and darkness. FloodSense-PK was born from that idea: fuse radar AI with Pakistan's own river data and its most painful historical memory — the 2010 Great Floods — into one national early warning system.
What it does
FloodSense-PK is an end-to-end flood intelligence platform that answers three questions at once:
- "Where is water RIGHT NOW?" — Sentinel-1 SAR imagery is pulled live from Google Earth Engine and segmented by our U-Net deep learning model, producing flood masks through clouds, at night, for any of Pakistan's 148 districts.
- "How bad is it compared to 2010?" — Every detection is benchmarked against the 2010 Great Pakistan Floods (reconstructed from Landsat-5 MNDWI), producing a "Delta Severity" score. If today exceeds 2010, that's CRITICAL.
- "What's coming downstream?" — A live scraper monitors 31 stations from Pakistan's Flood Forecasting Division (Tarbela → Sukkur → Kotri), classifying each as NORMAL, HIGH, or EXTREME.
Then it acts. A four-agent AI pipeline fuses all three evidence streams: a Disaster Intelligence Agent classifies the risk, a Simulation Agent projects flood progression over 6/12/24/48 hours using a physical volume-balance model (including which downstream districts will be hit and when), and a Response Agent evaluates safe zones, plans evacuation routes, and drafts citizen + authority alerts — even emailing subscribers a personalized evacuation alert with safe-zone coordinates and a Google Maps directions link.
It all ships as a Streamlit executive dashboard, a React 19 web console on a FastAPI + MongoDB backend, a Flet mobile app with district-based alerts, and a RAG-powered Knowledge Assistant grounded in Pakistan's disaster-management documentation.
How we built it
Deep learning core: We trained a U-Net with a ResNet34 encoder (~24M parameters) on Sen1Floods11, a peer-reviewed global flood benchmark of 11 flood events. We used only 3 SAR channels (VV, VH, VH/VV ratio) — deliberately dropping optical channels since they fail exactly when floods happen — which also unlocked ImageNet transfer learning. Dice + Focal loss, AdamW, SAR-safe augmentations. Best validation IoU: 0.5503.
Satellite pipeline: Google Earth Engine fetches Sentinel-1 GRD composites for any district/province at dynamic resolution (~80 m district, ~1000 m national), applies an SRTM slope mask to kill terrain false positives, then our tiled inference engine slices large exports into 256×256 patches and stitches the flood masks back together.
Historical benchmark: We reconstructed the 2010 floods from Landsat-5 using MNDWI, subtracting 2009 permanent water so we only measure true flood footprint — computed as zonal statistics for every district.
Live hydraulics: A resilient regex-based scraper parses the FFD river portal into structured discharge, trend, and status data, mapped onto the encoded Indus/Kabul/Jhelum/Chenab river topology.
Agentic pipeline: Four deterministic, rule-based agents (Pydantic-schemad, fully testable without API keys) orchestrated by run_pipeline(), with optional Gemini/Groq enrichment for narrative reports. The Simulation Agent's projections are physically grounded: net river flux spills overbank, spreads across the floodplain at an assumed inundation depth, and propagates along the real river chain.
RAG knowledge layer: A pypdf → structural chunker → sentence-transformers → Qdrant pipeline that grounds both the chatbot and the risk assessment in our structured domain-knowledge document (barrage capacities, district histories, escalation rules) with cited sources.
Frontends: Streamlit dashboard (6 tabs), React 19 + Vite + TypeScript + Tailwind v4 console with TanStack Query polling background analysis jobs on the FastAPI/MongoDB backend (JWT auth, auto-alerts), and a Flet mobile app with per-user district monitoring.
Challenges we ran into
- Seeing floods without optical data. Most flood datasets lean on optical bands — useless under monsoon clouds. We had to make pure SAR work, engineering a VH/VV ratio channel and slope masking to separate water from radar shadow and smooth terrain.
- GEE at two scales. District-level detail (~80 m) versus national situational awareness (~1000 m) required a dynamic-resolution export system and tiled inference to handle exports up to 1024×1024 without exhausting memory.
- Comparing 2010 optical to 2026 radar. Two different sensors, physics, and eras. We resolved it by treating the 2010 MNDWI footprint as a benchmark indicator (Delta Severity) rather than pretending it's a pixel-perfect diff — an honest framing that authorities can defend.
- A fragile government data source. The FFD portal has no API and its layout shifts. We built aggressive regex parsing with status fallbacks so a scraper break degrades gracefully instead of taking down the dashboard.
- Making AI defensible. Disaster authorities can't act on black-box vibes. So risk scoring is a transparent weighted formula (40% flood extent, 30% delta vs 2010, 30% river status), and the agent pipeline is deterministic — LLMs only polish the language, never decide the risk.
Accomplishments that we're proud of
- 0.5503 IoU on Sen1Floods11 — a solid single-model result on a globally diverse, peer-reviewed benchmark, well above threshold baselines (~0.30), with an honest published comparison table.
- A real four-agent disaster pipeline — not a demo prompt chain, but deterministic, schema-validated agents with a physical volume-balance simulation, downstream propagation along Pakistan's actual river topology, and a full pytest suite.
- Three production frontends sharing one engine — Streamlit dashboard, React ops console with background jobs and JWT auth, and a mobile alert app covering all 148 districts.
- Closing the last mile — a subscribed citizen receives an actual email with their recommended safe zone, exact coordinates, distance, ETA, and a tap-to-navigate Google Maps link.
- Grounded AI — the RAG layer means every chatbot answer and risk assessment cites real sources from our disaster knowledge base instead of hallucinating.
What we learned
- Radar physics is a superpower. Open water acting as a specular mirror (dark pixels in SAR) is a stronger, more reliable flood signal during monsoon than any optical index — once you handle terrain shadows.
- Less data can be more. Dropping Sen1Floods11's optical channels down to 3 SAR channels didn't just match the deployment reality — it enabled ImageNet pretraining that lifted our IoU.
- Determinism earns trust. Building the agent pipeline rule-based-first (LLM as optional garnish) made it testable, reproducible, and explainable — everything a disaster authority actually needs.
- Historical context transforms numbers. "18% of the district is flooded" means little; "flooding is at 60% of 2010 disaster levels and rising" drives decisions.
- Real-world data is hostile. Scraping a government portal, multi-line TOML private keys, GEE service-account quotas — the unglamorous plumbing took as much engineering as the ML.
What's next for FloodSense-PK
- Dual-polarization exports — pulling true VH from GEE instead of approximating it, recovering the full VH/VV ratio signal.
- Pakistan fine-tuning — adapting the Sen1Floods11-trained model on local flood events in priority districts to close the domain gap.
- Urban flooding — fusing DEM and clear-sky optical data to catch water hidden in SAR building shadows.
- Push-scale alerting — SMS and WhatsApp delivery on top of email, plus native push in the mobile app, to reach communities that currently get <6 hours of warning.
- NDMA/PDMA integration — piloting the API with provincial disaster management authorities so alerts flow into official response channels.
- Ensemble + attention models — pushing IoU toward the published ~0.78 ensemble ceiling while keeping inference fast enough for national scans.

Log in or sign up for Devpost to join the conversation.