4D Temporal Vision Transformer predicting coastal flood risk in Alexandria, Egypt.
# π Alexandria Sentinel: 4D Flood Risk Predictor
**Alexandria Sentinel** is a geospatial Deep Learning portfolio project designed to predict urban coastal vulnerability, focusing on the coastline from Agami to Abu Qir, Egypt.
The system utilizes a custom **Temporal Vision Transformer (TSViT)** to fuse multi-modal satellite data, allowing the architecture to "see" through heavy cloud cover during extreme storm events by combining radar and optical bands.
## π§ Model Architecture (TSViT)
Standard CNNs struggle with irregular urban coastlines due to localized kernels. This project implements a custom Attention-based architecture using `einops` and PyTorch to evaluate both spatial and temporal dynamics simultaneously.
* **Parameters:** ~2.8 Million
* **Inputs:** 4D Tensors `(Batch, Time, Channels, Height, Width)`
* **Bands Used:** 7 Channels total
* Sentinel-1 SAR (VV & VH) - *Penetrates cloud cover*
* Sentinel-2 Optical (RGB & NIR) - *Surface context*
* NASA ASTER Global DEM - *Topographic elevation*
## βοΈ The Data Pipeline
The data ingestion pipeline (`data_engine.py`) authenticates securely with the Google Earth Engine API to dynamically fetch, filter, and clip Copernicus satellite imagery specifically to the Alexandria bounding box `[29.8, 31.1, 30.1, 31.3]`.
## π Deployment (Batch Inference)
To ensure high-performance UI rendering on standard cloud hardware, the application utilizes a Batch Inference Pipeline.
1. The PyTorch model processes the 4D tensors offline to generate risk score matrices.
2. The UI (`app.py`) leverages Streamlit and Folium's HeatMap engine to render the pre-computed inference data over interactive geographic tile layers.
## π Repository Structure
* `/app.py` - Streamlit application and Folium UI.
* `/model.py` - PyTorch TSViT class and Multi-Head Attention blocks.
* `/data_engine.py` - GEE authentication and satellite data extraction.
* `/train.py` - PyTorch Lightning training loop blueprint.
> **Note on Model Weights:** The curr β¦