File size: 5,527 Bytes
d70361b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
---
title: Vedangsoft Change Detection (Dev)
emoji: πŸ›°οΈ
colorFrom: gray
colorTo: green
sdk: docker
app_port: 7860
---

# Vedangsoft Change Detection β€” Development

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.

> **New to the project?** Start with **[DEV_SETUP.md](DEV_SETUP.md)** β€” step-by-step install and run instructions for your machine.

| Environment | URL |
|-------------|-----|
| **Dev Space (HF)** | https://coderuday21-satdetect-dev.hf.space |
| **Local** | http://127.0.0.1:8000 after `python run.py` |

## Quick start

```bash
git clone https://github.com/Uday-at-Vedang/Change-Detection-DEV.git
cd Change-Detection-DEV
python -m venv venv
venv\Scripts\activate          # Windows
# source venv/bin/activate     # macOS/Linux
pip install -r requirements.txt
python run.py
```

1. Add GeoTIFFs to `library_sources/2025/` (or other year folders).
2. Open **Image Library β†’ Refresh**.
3. Use **Change Detection** to compare T1 vs T2.

Full details: **[DEV_SETUP.md](DEV_SETUP.md)** Β· SOW plan: **`docs/IMPLEMENTATION_PLAN_DDA.md`** Β· HF deploy: **`DEPLOYMENT.md`**

---

# Satellite Change Detection β€” Standalone Web App

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.

## Features

- **Vedangsoft dev UI** β€” Home, Library, Detection, Reports pages (when `APP_MODE=dda`)
- **Direct access** β€” upload and run detection immediately (no login)
- **Database** β€” SQLite by default; MySQL in production via `DATABASE_URL` (PostgreSQL also supported); stores detection runs
- **Change detection** β€” AdaptFormer deep learning + hybrid / difference methods
- **GeoTIFF library** β€” Year-folder library, 5 GB upload limit, lat/lng on regions
- **Object classification** β€” Changed regions labeled (Water, Vegetation, Building, Road, etc.)
- **History & reports** β€” Past runs, PDF export, email notifications
- **Region polygons** β€” Engine footprints (`polygon` / `polygonGeo`) in the result overlay + viewer SVG; export via `GET /api/dda/reports/{id}/export.geojson` (bbox/Point fallback for older runs). Verify: `python scripts/verify_polygon_mvp.py`

## Setup (legacy summary)

See **[DEV_SETUP.md](DEV_SETUP.md)** for the complete guide. Minimal steps:

1. **Create a virtual environment (recommended)**

   ```bash
   cd change_detection_webapp
   python -m venv venv
   source venv/bin/activate   # Windows: venv\Scripts\activate
   ```

2. **Install dependencies**

   ```bash
   pip install -r requirements.txt
   ```

3. **Run the app**

   ```bash
   python run.py
   # or: uvicorn app.main:app --reload --host 0.0.0.0 --port 8000
   ```

4. Open **http://localhost:8000** in your browser.

## First run

- The DB (SQLite locally, or the configured `DATABASE_URL`) and `data/` (overlay images) are created automatically on first use.
- **DDA mode:** place images in `library_sources/YYYY/` and use the Library tab.
- **Legacy mode:** upload Before/After PNGs on the detection page.
- AdaptFormer model downloads from Hugging Face on first detection (~500 MB).

## Configuration

- **DDA mode:** `APP_MODE=dda` (default when using `run.py`). Copy `.env.example` β†’ `.env` for optional overrides.
- **Database**: set `DATABASE_URL` to use another DB β€” MySQL (production for this project): `mysql+pymysql://user:pass@host:3306/db`, or PostgreSQL: `postgresql://user:pass@host/db`. Otherwise SQLite under `data/satellite_app.db` is used.
- **JWT**: set `SECRET_KEY` via env in production.
- **Email**: `EMAIL_API_URL` or `SMTP_USER` / `SMTP_PASS` β€” see `.env.example`.

## Project layout

```
change_detection_webapp/
β”œβ”€β”€ app/
β”‚   β”œβ”€β”€ main.py              # FastAPI app, routes
β”‚   β”œβ”€β”€ dda/                 # DDA dev modules (library, jobs, reports)
β”‚   └── detection_engine.py  # Change detection pipeline
β”œβ”€β”€ static/js/dda/           # DDA frontend
β”œβ”€β”€ templates/
β”‚   β”œβ”€β”€ partials/navbar_dda.html, result_modal_dda.html  # shared includes
β”‚   β”œβ”€β”€ home_dda.html, library_dda.html, detect_dda.html,
β”‚   β”‚   reports_dda.html     # Vedangsoft dev UI pages
β”‚   β”œβ”€β”€ login_dda.html, report_dda.html
β”‚   └── index.html           # legacy (APP_MODE=legacy) UI
β”œβ”€β”€ library_sources/         # Local GeoTIFF library (year folders)
β”œβ”€β”€ docs/IMPLEMENTATION_PLAN_DDA.md
β”œβ”€β”€ DEV_SETUP.md             # Colleague setup guide
β”œβ”€β”€ requirements.txt
└── run.py                   # Local launcher (APP_MODE=dda)
```

## API (Vedangsoft highlights)

- `GET /health` β€” app mode and version
- `GET /api/dda/local/images` β€” library image list
- `POST /api/dda/jobs` β€” queue async detection
- `GET /api/dda/reports/{id}/pdf` β€” PDF download
- `GET /dda/reports/{id}` β€” browser report page
- `POST /api/detect` β€” legacy multipart upload detect
- `GET /api/history` β€” detection run history

## Hugging Face: Space stuck on β€œRestarting”

1. Open your Space β†’ **Settings** β†’ under **Build**, click **Clear build cache** β†’ Save. Then trigger a rebuild (push a commit or click **Restart**).
2. Check **Logs** (Build logs + App logs) for Python errors or β€œKilled” (out of memory).
3. In **Settings** β†’ **Hardware**, try a slightly larger CPU/memory if available.