File size: 4,782 Bytes
20e1b5d
7eb5b75
20e1b5d
 
1f893f3
20e1b5d
 
 
 
7eb5b75
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
401aaf2
 
c506ed2
401aaf2
 
 
7eb5b75
c506ed2
 
7eb5b75
 
 
 
401aaf2
7eb5b75
 
 
401aaf2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7eb5b75
 
401aaf2
 
 
 
 
 
 
7eb5b75
 
 
401aaf2
 
 
7eb5b75
401aaf2
7eb5b75
 
4e9c6ba
401aaf2
 
 
 
 
7eb5b75
 
 
 
 
 
 
 
401aaf2
7eb5b75
401aaf2
 
7eb5b75
401aaf2
7eb5b75
 
 
 
 
 
 
717d61b
 
 
 
 
 
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
---
title: DDA Change Detection (Dev)
emoji: πŸ›°οΈ
colorFrom: gray
colorTo: green
sdk: docker
app_port: 7860
---

# DDA 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

- **DDA dev UI** β€” Library, comparison, jobs, reports, PDF (when `APP_MODE=dda`)
- **Direct access** β€” upload and run detection immediately (no login)
- **Database** β€” SQLite (or set `DATABASE_URL` for PostgreSQL); 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

## 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 SQLite DB 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` (e.g. `postgresql://user:pass@host/db`) to use another 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/index_dda.html # DDA dev 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 (DDA 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.