Spaces:
Sleeping
Sleeping
Commit Β·
7eb5b75
1
Parent(s): 70d9e6c
Add colleague setup guide and env template for Change-Detection-DEV repo.
Browse filesDEV_SETUP.md covers Python, GDAL/rasterio, library layout, run.py, and troubleshooting; README points to it.
Co-authored-by: Cursor <cursoragent@cursor.com>
- .env.example +30 -0
- .gitignore +1 -0
- DEV_SETUP.md +212 -0
- README.md +65 -44
.env.example
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copy to .env and uncomment values as needed (optional for local dev).
|
| 2 |
+
# python run.py sets APP_MODE=dda automatically.
|
| 3 |
+
|
| 4 |
+
# APP_MODE=dda
|
| 5 |
+
# SECRET_KEY=change-me-to-a-long-random-string
|
| 6 |
+
|
| 7 |
+
# Database (default: SQLite in data/satellite_app.db)
|
| 8 |
+
# DATABASE_URL=sqlite:///./data/satellite_app.db
|
| 9 |
+
|
| 10 |
+
# Local image library folder (default: library_sources/)
|
| 11 |
+
# LOCAL_LIBRARY_ROOT=C:/path/to/your/images
|
| 12 |
+
|
| 13 |
+
# GeoTIFF upload limit in MB (default 5120 = 5 GB)
|
| 14 |
+
# MAX_GEOTIFF_MB=5120
|
| 15 |
+
|
| 16 |
+
# Max pixel dimension for detection (lower = less RAM, default 4096 local)
|
| 17 |
+
# DETECTION_MAX_SIDE=4096
|
| 18 |
+
|
| 19 |
+
# Public URL for report links in emails (default http://localhost:8000 locally)
|
| 20 |
+
# PUBLIC_BASE_URL=http://localhost:8000
|
| 21 |
+
|
| 22 |
+
# Email notifications (optional)
|
| 23 |
+
# EMAIL_API_URL=https://emailservice.managemybusinessess.com/api/email/send
|
| 24 |
+
# SMTP_HOST=smtp.gmail.com
|
| 25 |
+
# SMTP_PORT=587
|
| 26 |
+
# SMTP_USER=
|
| 27 |
+
# SMTP_PASS=
|
| 28 |
+
|
| 29 |
+
# Hugging Face model cache directory
|
| 30 |
+
# HF_HOME=./.hf_cache
|
.gitignore
CHANGED
|
@@ -4,6 +4,7 @@ __pycache__/
|
|
| 4 |
data/satellite_app.db
|
| 5 |
data/overlays/*
|
| 6 |
!data/overlays/.gitkeep
|
|
|
|
| 7 |
# Local library images (too large for git β keep on disk only)
|
| 8 |
library_sources/**/*.tif
|
| 9 |
library_sources/**/*.tiff
|
|
|
|
| 4 |
data/satellite_app.db
|
| 5 |
data/overlays/*
|
| 6 |
!data/overlays/.gitkeep
|
| 7 |
+
data/library_cache/
|
| 8 |
# Local library images (too large for git β keep on disk only)
|
| 9 |
library_sources/**/*.tif
|
| 10 |
library_sources/**/*.tiff
|
DEV_SETUP.md
ADDED
|
@@ -0,0 +1,212 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# DDA Change Detection β Local Dev Setup
|
| 2 |
+
|
| 3 |
+
This repo is the **development branch** of the satellite change-detection app (DDA SOW). It runs the full dev UI: image library, GeoTIFF comparison, async jobs, reports, and PDF export.
|
| 4 |
+
|
| 5 |
+
**Live dev Space (reference):** https://coderuday21-satdetect-dev.hf.space
|
| 6 |
+
**Production Space (do not deploy this repo there without review):** https://coderuday21-satdetect.hf.space
|
| 7 |
+
|
| 8 |
+
---
|
| 9 |
+
|
| 10 |
+
## 1. Prerequisites
|
| 11 |
+
|
| 12 |
+
| Requirement | Notes |
|
| 13 |
+
|-------------|--------|
|
| 14 |
+
| **Python 3.10 β 3.12** | Tested with **3.11** (same as Docker). 3.13+ may have wheel issues for some packages. |
|
| 15 |
+
| **Git** | Clone this repository. |
|
| 16 |
+
| **~4 GB free disk** | PyTorch (CPU), transformers model cache, and sample GeoTIFFs. |
|
| 17 |
+
| **RAM 8 GB+ recommended** | Detection loads AdaptFormer; large GeoTIFFs use more RAM. |
|
| 18 |
+
|
| 19 |
+
### Windows (GeoTIFF / rasterio)
|
| 20 |
+
|
| 21 |
+
`rasterio` needs GDAL. Easiest options:
|
| 22 |
+
|
| 23 |
+
**Option A β pip wheels (try first):**
|
| 24 |
+
```powershell
|
| 25 |
+
pip install -r requirements.txt
|
| 26 |
+
python -c "import rasterio; print('rasterio OK', rasterio.__version__)"
|
| 27 |
+
```
|
| 28 |
+
|
| 29 |
+
**Option B β if rasterio fails, use Conda for GDAL then pip for the rest:**
|
| 30 |
+
```powershell
|
| 31 |
+
conda create -n dda-cd python=3.11 -y
|
| 32 |
+
conda activate dda-cd
|
| 33 |
+
conda install -c conda-forge gdal rasterio -y
|
| 34 |
+
pip install -r requirements.txt
|
| 35 |
+
```
|
| 36 |
+
|
| 37 |
+
**Option C β OSGeo4W:** Install [OSGeo4W](https://trac.osgeo.org/osgeo4w/) and ensure `gdal` is on `PATH` before `pip install rasterio`.
|
| 38 |
+
|
| 39 |
+
### macOS / Linux
|
| 40 |
+
|
| 41 |
+
```bash
|
| 42 |
+
# macOS (Homebrew)
|
| 43 |
+
brew install gdal
|
| 44 |
+
|
| 45 |
+
# Ubuntu/Debian
|
| 46 |
+
sudo apt-get install gdal-bin libgdal-dev
|
| 47 |
+
export GDAL_CONFIG=/usr/bin/gdal-config
|
| 48 |
+
pip install -r requirements.txt
|
| 49 |
+
```
|
| 50 |
+
|
| 51 |
+
---
|
| 52 |
+
|
| 53 |
+
## 2. Clone and install
|
| 54 |
+
|
| 55 |
+
```bash
|
| 56 |
+
git clone https://github.com/Uday-at-Vedang/Change-Detection-DEV.git
|
| 57 |
+
cd Change-Detection-DEV
|
| 58 |
+
python -m venv venv
|
| 59 |
+
```
|
| 60 |
+
|
| 61 |
+
**Windows:**
|
| 62 |
+
```powershell
|
| 63 |
+
venv\Scripts\activate
|
| 64 |
+
pip install -U pip setuptools wheel
|
| 65 |
+
pip install -r requirements.txt
|
| 66 |
+
```
|
| 67 |
+
|
| 68 |
+
**macOS / Linux:**
|
| 69 |
+
```bash
|
| 70 |
+
source venv/bin/activate
|
| 71 |
+
pip install -U pip setuptools wheel
|
| 72 |
+
pip install -r requirements.txt
|
| 73 |
+
```
|
| 74 |
+
|
| 75 |
+
> First `pip install` may take 10β20 minutes (PyTorch + transformers).
|
| 76 |
+
|
| 77 |
+
---
|
| 78 |
+
|
| 79 |
+
## 3. Environment variables (optional)
|
| 80 |
+
|
| 81 |
+
Copy the template and edit if needed:
|
| 82 |
+
|
| 83 |
+
```bash
|
| 84 |
+
cp .env.example .env
|
| 85 |
+
```
|
| 86 |
+
|
| 87 |
+
| Variable | Default (local) | Purpose |
|
| 88 |
+
|----------|----------------|---------|
|
| 89 |
+
| `APP_MODE` | `dda` (set by `run.py`) | `dda` = full dev UI; `legacy` = simple upload UI |
|
| 90 |
+
| `SECRET_KEY` | random fallback | Set in production |
|
| 91 |
+
| `DATABASE_URL` | SQLite in `data/` | PostgreSQL optional |
|
| 92 |
+
| `LOCAL_LIBRARY_ROOT` | `library_sources/` | Custom image library folder |
|
| 93 |
+
| `MAX_GEOTIFF_MB` | `5120` | Max GeoTIFF upload size (MB) |
|
| 94 |
+
| `DETECTION_MAX_SIDE` | `4096` local / `2048` HF | Max pixel side for detection |
|
| 95 |
+
| `EMAIL_API_URL` | manager API | Email notifications |
|
| 96 |
+
| `SMTP_USER` / `SMTP_PASS` | β | Use SMTP if API URL empty |
|
| 97 |
+
| `PUBLIC_BASE_URL` | `http://localhost:8000` | Report links in emails |
|
| 98 |
+
|
| 99 |
+
Local dev does **not** require email config unless you test notifications.
|
| 100 |
+
|
| 101 |
+
---
|
| 102 |
+
|
| 103 |
+
## 4. Image library (local GeoTIFFs)
|
| 104 |
+
|
| 105 |
+
Place images under year folders (not committed to git β too large):
|
| 106 |
+
|
| 107 |
+
```
|
| 108 |
+
library_sources/
|
| 109 |
+
2024/
|
| 110 |
+
site_a.tif
|
| 111 |
+
2025/
|
| 112 |
+
site_b.tif
|
| 113 |
+
2026/
|
| 114 |
+
```
|
| 115 |
+
|
| 116 |
+
See `library_sources/README.md` for details. Supported: `.tif`, `.tiff`, `.png`, `.jpg`.
|
| 117 |
+
|
| 118 |
+
After adding files, start the app and click **Image Library β Refresh**.
|
| 119 |
+
|
| 120 |
+
---
|
| 121 |
+
|
| 122 |
+
## 5. Run the app
|
| 123 |
+
|
| 124 |
+
```bash
|
| 125 |
+
python run.py
|
| 126 |
+
```
|
| 127 |
+
|
| 128 |
+
Opens **http://127.0.0.1:8000** with the DDA dev UI (3 tabs: Image Library, Change Detection, Reports).
|
| 129 |
+
|
| 130 |
+
Alternative (with auto-reload during development):
|
| 131 |
+
|
| 132 |
+
```bash
|
| 133 |
+
set APP_MODE=dda # Windows
|
| 134 |
+
export APP_MODE=dda # macOS/Linux
|
| 135 |
+
uvicorn app.main:app --reload --host 127.0.0.1 --port 8000
|
| 136 |
+
```
|
| 137 |
+
|
| 138 |
+
### First run
|
| 139 |
+
|
| 140 |
+
- Creates `data/satellite_app.db` and `data/overlays/`.
|
| 141 |
+
- Downloads **AdaptFormer** model from Hugging Face on first detection (~500 MB). Requires internet.
|
| 142 |
+
- Seed data: Delhi zone/village hierarchy is loaded automatically in DDA mode.
|
| 143 |
+
|
| 144 |
+
### Health check
|
| 145 |
+
|
| 146 |
+
```bash
|
| 147 |
+
curl http://127.0.0.1:8000/health
|
| 148 |
+
```
|
| 149 |
+
|
| 150 |
+
Expected: `"appMode": "dda"`, `"status": "ok"`.
|
| 151 |
+
|
| 152 |
+
---
|
| 153 |
+
|
| 154 |
+
## 6. Using the dev UI
|
| 155 |
+
|
| 156 |
+
1. **Image Library** β scan year folders, upload GeoTIFFs (up to 5 GB), view hierarchy.
|
| 157 |
+
2. **Change Detection** β pick Base (T1) and Comparison (T2), run detection (async jobs on HF; sync locally).
|
| 158 |
+
3. **Reports** β history, PDF download, browser report at `/dda/reports/{id}`.
|
| 159 |
+
4. **Bell icon** β in-app notifications for completed jobs.
|
| 160 |
+
|
| 161 |
+
---
|
| 162 |
+
|
| 163 |
+
## 7. Project layout (DDA)
|
| 164 |
+
|
| 165 |
+
```
|
| 166 |
+
app/
|
| 167 |
+
main.py # FastAPI entry
|
| 168 |
+
detection_engine.py # Change detection pipeline
|
| 169 |
+
dda/ # DDA modules (library, jobs, reports, geo)
|
| 170 |
+
static/js/dda/ # Dev frontend
|
| 171 |
+
templates/index_dda.html
|
| 172 |
+
docs/IMPLEMENTATION_PLAN_DDA.md # SOW phase plan
|
| 173 |
+
```
|
| 174 |
+
|
| 175 |
+
---
|
| 176 |
+
|
| 177 |
+
## 8. Troubleshooting
|
| 178 |
+
|
| 179 |
+
| Issue | Fix |
|
| 180 |
+
|-------|-----|
|
| 181 |
+
| `ImportError: rasterio` | Install GDAL (see Β§1), then reinstall rasterio |
|
| 182 |
+
| Simple upload UI instead of DDA tabs | Set `APP_MODE=dda` or use `python run.py` |
|
| 183 |
+
| Library empty | Add `.tif` files under `library_sources/YYYY/` and click Refresh |
|
| 184 |
+
| Detection slow / OOM | Lower `DETECTION_MAX_SIDE=2048` or use smaller images |
|
| 185 |
+
| Model download fails | Check internet; set `HF_HOME` to a writable folder |
|
| 186 |
+
| Port 8000 in use | Change `PORT` in `run.py` or use `--port 8001` with uvicorn |
|
| 187 |
+
|
| 188 |
+
---
|
| 189 |
+
|
| 190 |
+
## 9. Deploy to Hugging Face dev Space (maintainers)
|
| 191 |
+
|
| 192 |
+
See `DEPLOYMENT.md`. Dev Space remote:
|
| 193 |
+
|
| 194 |
+
```powershell
|
| 195 |
+
git remote add hf-dev https://huggingface.co/spaces/coderuday21/satdetect-dev
|
| 196 |
+
git push hf-dev master:main
|
| 197 |
+
```
|
| 198 |
+
|
| 199 |
+
Do **not** push `master` to production `satdetect` without explicit sign-off.
|
| 200 |
+
|
| 201 |
+
---
|
| 202 |
+
|
| 203 |
+
## 10. Key API endpoints (DDA)
|
| 204 |
+
|
| 205 |
+
| Method | Path | Description |
|
| 206 |
+
|--------|------|-------------|
|
| 207 |
+
| GET | `/health` | Health + app mode |
|
| 208 |
+
| GET | `/api/dda/local/images` | Library image list |
|
| 209 |
+
| POST | `/api/dda/jobs` | Queue async detection |
|
| 210 |
+
| GET | `/api/dda/reports/{id}/pdf` | PDF export |
|
| 211 |
+
| GET | `/dda/reports/{id}` | Browser report page |
|
| 212 |
+
| GET | `/api/history` | Detection run history |
|
README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
emoji: π°οΈ
|
| 4 |
colorFrom: gray
|
| 5 |
colorTo: green
|
|
@@ -7,22 +7,54 @@ sdk: docker
|
|
| 7 |
app_port: 7860
|
| 8 |
---
|
| 9 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
# Satellite Change Detection β Standalone Web App
|
| 11 |
|
| 12 |
Standalone web application for satellite image change detection with **database storage** and a **clean, modern UI**. Opens directly on the detection page β no sign-in required.
|
| 13 |
|
| 14 |
## Features
|
| 15 |
|
|
|
|
| 16 |
- **Direct access** β upload and run detection immediately (no login)
|
| 17 |
- **Database** β SQLite (or set `DATABASE_URL` for PostgreSQL); stores detection runs
|
| 18 |
-
- **Change detection** β
|
| 19 |
-
- **
|
| 20 |
-
- **
|
| 21 |
-
- **
|
| 22 |
-
- **History** β List of past runs with overlay images and stats
|
| 23 |
-
- **UI** β Single-page app with a dark, βcontrol roomβ style and teal accents
|
| 24 |
|
| 25 |
-
## Setup
|
|
|
|
|
|
|
| 26 |
|
| 27 |
1. **Create a virtual environment (recommended)**
|
| 28 |
|
|
@@ -41,7 +73,8 @@ Standalone web application for satellite image change detection with **database
|
|
| 41 |
3. **Run the app**
|
| 42 |
|
| 43 |
```bash
|
| 44 |
-
|
|
|
|
| 45 |
```
|
| 46 |
|
| 47 |
4. Open **http://localhost:8000** in your browser.
|
|
@@ -49,55 +82,43 @@ Standalone web application for satellite image change detection with **database
|
|
| 49 |
## First run
|
| 50 |
|
| 51 |
- The SQLite DB and `data/` (overlay images) are created automatically on first use.
|
| 52 |
-
-
|
| 53 |
-
-
|
|
|
|
| 54 |
|
| 55 |
## Configuration
|
| 56 |
|
|
|
|
| 57 |
- **Database**: set `DATABASE_URL` (e.g. `postgresql://user:pass@host/db`) to use another DB; otherwise SQLite under `data/satellite_app.db` is used.
|
| 58 |
-
- **JWT**: set `SECRET_KEY`
|
| 59 |
-
- **Email**:
|
| 60 |
-
|
| 61 |
-
- **Landslide module**:
|
| 62 |
-
- Integrated at runtime through the same `/api/detect` endpoint using `detection_type=landslide_detection`.
|
| 63 |
-
- Engine code: `app/landslide_engine.py`
|
| 64 |
-
- Dataset preprocessing starter: `app/landslide_preprocessing.py`
|
| 65 |
-
- Planning/research brief: `Landslide_Detection_Uttarakhand_Integration_Plan.md`
|
| 66 |
-
|
| 67 |
-
- **Pothole module**:
|
| 68 |
-
- Integrated at runtime through the same `/api/detect` endpoint using `detection_type=pothole_detection`.
|
| 69 |
-
- Engine code: `app/pothole_engine.py`
|
| 70 |
-
- Planning/research brief: `Pothole_Detection_Integration_Plan.md`
|
| 71 |
|
| 72 |
## Project layout
|
| 73 |
|
| 74 |
```
|
| 75 |
change_detection_webapp/
|
| 76 |
βββ app/
|
| 77 |
-
β βββ main.py
|
| 78 |
-
β βββ
|
| 79 |
-
β
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
βββ
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
βββ templates/
|
| 86 |
-
β βββ index.html # Single-page UI
|
| 87 |
-
βββ data/ # Created at runtime (DB + overlays)
|
| 88 |
βββ requirements.txt
|
| 89 |
-
βββ
|
| 90 |
```
|
| 91 |
|
| 92 |
-
## API (
|
| 93 |
|
| 94 |
-
- `
|
| 95 |
-
- `
|
| 96 |
-
- `
|
| 97 |
-
- `
|
| 98 |
-
- `GET /
|
| 99 |
-
- `
|
| 100 |
-
- `GET /
|
| 101 |
|
| 102 |
## Hugging Face: Space stuck on βRestartingβ
|
| 103 |
|
|
|
|
| 1 |
---
|
| 2 |
+
title: DDA Change Detection (Dev)
|
| 3 |
emoji: π°οΈ
|
| 4 |
colorFrom: gray
|
| 5 |
colorTo: green
|
|
|
|
| 7 |
app_port: 7860
|
| 8 |
---
|
| 9 |
|
| 10 |
+
# DDA Change Detection β Development
|
| 11 |
+
|
| 12 |
+
Satellite / drone **change detection** web app for the DDA Scope of Work. This repository tracks **dev-only** features (`APP_MODE=dda`): image library, GeoTIFF comparison, async jobs, geo-referenced regions, reports, and PDF export.
|
| 13 |
+
|
| 14 |
+
> **New to the project?** Start with **[DEV_SETUP.md](DEV_SETUP.md)** β step-by-step install and run instructions for your machine.
|
| 15 |
+
|
| 16 |
+
| Environment | URL |
|
| 17 |
+
|-------------|-----|
|
| 18 |
+
| **Dev Space (HF)** | https://coderuday21-satdetect-dev.hf.space |
|
| 19 |
+
| **Local** | http://127.0.0.1:8000 after `python run.py` |
|
| 20 |
+
|
| 21 |
+
## Quick start
|
| 22 |
+
|
| 23 |
+
```bash
|
| 24 |
+
git clone https://github.com/Uday-at-Vedang/Change-Detection-DEV.git
|
| 25 |
+
cd Change-Detection-DEV
|
| 26 |
+
python -m venv venv
|
| 27 |
+
venv\Scripts\activate # Windows
|
| 28 |
+
# source venv/bin/activate # macOS/Linux
|
| 29 |
+
pip install -r requirements.txt
|
| 30 |
+
python run.py
|
| 31 |
+
```
|
| 32 |
+
|
| 33 |
+
1. Add GeoTIFFs to `library_sources/2025/` (or other year folders).
|
| 34 |
+
2. Open **Image Library β Refresh**.
|
| 35 |
+
3. Use **Change Detection** to compare T1 vs T2.
|
| 36 |
+
|
| 37 |
+
Full details: **[DEV_SETUP.md](DEV_SETUP.md)** Β· SOW plan: **`docs/IMPLEMENTATION_PLAN_DDA.md`** Β· HF deploy: **`DEPLOYMENT.md`**
|
| 38 |
+
|
| 39 |
+
---
|
| 40 |
+
|
| 41 |
# Satellite Change Detection β Standalone Web App
|
| 42 |
|
| 43 |
Standalone web application for satellite image change detection with **database storage** and a **clean, modern UI**. Opens directly on the detection page β no sign-in required.
|
| 44 |
|
| 45 |
## Features
|
| 46 |
|
| 47 |
+
- **DDA dev UI** β Library, comparison, jobs, reports, PDF (when `APP_MODE=dda`)
|
| 48 |
- **Direct access** β upload and run detection immediately (no login)
|
| 49 |
- **Database** β SQLite (or set `DATABASE_URL` for PostgreSQL); stores detection runs
|
| 50 |
+
- **Change detection** β AdaptFormer deep learning + hybrid / difference methods
|
| 51 |
+
- **GeoTIFF library** β Year-folder library, 5 GB upload limit, lat/lng on regions
|
| 52 |
+
- **Object classification** β Changed regions labeled (Water, Vegetation, Building, Road, etc.)
|
| 53 |
+
- **History & reports** β Past runs, PDF export, email notifications
|
|
|
|
|
|
|
| 54 |
|
| 55 |
+
## Setup (legacy summary)
|
| 56 |
+
|
| 57 |
+
See **[DEV_SETUP.md](DEV_SETUP.md)** for the complete guide. Minimal steps:
|
| 58 |
|
| 59 |
1. **Create a virtual environment (recommended)**
|
| 60 |
|
|
|
|
| 73 |
3. **Run the app**
|
| 74 |
|
| 75 |
```bash
|
| 76 |
+
python run.py
|
| 77 |
+
# or: uvicorn app.main:app --reload --host 0.0.0.0 --port 8000
|
| 78 |
```
|
| 79 |
|
| 80 |
4. Open **http://localhost:8000** in your browser.
|
|
|
|
| 82 |
## First run
|
| 83 |
|
| 84 |
- The SQLite DB and `data/` (overlay images) are created automatically on first use.
|
| 85 |
+
- **DDA mode:** place images in `library_sources/YYYY/` and use the Library tab.
|
| 86 |
+
- **Legacy mode:** upload Before/After PNGs on the detection page.
|
| 87 |
+
- AdaptFormer model downloads from Hugging Face on first detection (~500 MB).
|
| 88 |
|
| 89 |
## Configuration
|
| 90 |
|
| 91 |
+
- **DDA mode:** `APP_MODE=dda` (default when using `run.py`). Copy `.env.example` β `.env` for optional overrides.
|
| 92 |
- **Database**: set `DATABASE_URL` (e.g. `postgresql://user:pass@host/db`) to use another DB; otherwise SQLite under `data/satellite_app.db` is used.
|
| 93 |
+
- **JWT**: set `SECRET_KEY` via env in production.
|
| 94 |
+
- **Email**: `EMAIL_API_URL` or `SMTP_USER` / `SMTP_PASS` β see `.env.example`.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 95 |
|
| 96 |
## Project layout
|
| 97 |
|
| 98 |
```
|
| 99 |
change_detection_webapp/
|
| 100 |
βββ app/
|
| 101 |
+
β βββ main.py # FastAPI app, routes
|
| 102 |
+
β βββ dda/ # DDA dev modules (library, jobs, reports)
|
| 103 |
+
β βββ detection_engine.py # Change detection pipeline
|
| 104 |
+
βββ static/js/dda/ # DDA frontend
|
| 105 |
+
βββ templates/index_dda.html # DDA dev UI
|
| 106 |
+
βββ library_sources/ # Local GeoTIFF library (year folders)
|
| 107 |
+
βββ docs/IMPLEMENTATION_PLAN_DDA.md
|
| 108 |
+
βββ DEV_SETUP.md # Colleague setup guide
|
|
|
|
|
|
|
|
|
|
| 109 |
βββ requirements.txt
|
| 110 |
+
βββ run.py # Local launcher (APP_MODE=dda)
|
| 111 |
```
|
| 112 |
|
| 113 |
+
## API (DDA highlights)
|
| 114 |
|
| 115 |
+
- `GET /health` β app mode and version
|
| 116 |
+
- `GET /api/dda/local/images` β library image list
|
| 117 |
+
- `POST /api/dda/jobs` β queue async detection
|
| 118 |
+
- `GET /api/dda/reports/{id}/pdf` β PDF download
|
| 119 |
+
- `GET /dda/reports/{id}` β browser report page
|
| 120 |
+
- `POST /api/detect` β legacy multipart upload detect
|
| 121 |
+
- `GET /api/history` β detection run history
|
| 122 |
|
| 123 |
## Hugging Face: Space stuck on βRestartingβ
|
| 124 |
|