Spaces:
Configuration error
Configuration error
File size: 15,199 Bytes
4b76f6f ffe942e 4b76f6f ffe942e 4b76f6f d5ae627 4b76f6f d5ae627 4b76f6f d5ae627 4b76f6f d5ae627 4b76f6f d5ae627 4b76f6f d5ae627 4b76f6f d5ae627 4b76f6f d5ae627 4b76f6f d5ae627 4b76f6f d5ae627 4b76f6f d5ae627 4b76f6f d5ae627 4b76f6f d5ae627 4b76f6f | 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 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 |
# ๐ TerraVision
### Sharper Earth. Brighter Decisions.
**TerraVision** is a GIS-based satellite imagery analysis platform that uses **Sentinel-2 satellite data** and the official **ESA OpenSR LDSR-S2 + SEN2SR super-resolution pipeline** to generate model-based **2.5 m resolution imagery** from freely available Sentinel-2 data.
The platform combines satellite image super-resolution, geospatial processing, spectral analysis, visualization, and GeoTIFF export into a single web-based workflow.
---
## ๐ Overview
Sentinel-2 provides freely available multispectral imagery, but its spatial resolution can be limiting for detailed geospatial analysis.
TerraVision addresses this challenge by:
1. Selecting a location using latitude/longitude or an interactive map.
2. Selecting a date range for Sentinel-2 imagery.
3. Retrieving Sentinel-2 L2A data.
4. Applying the **ESA LDSR-S2 + SEN2SR** super-resolution pipeline.
5. Generating a model-based **2.5 m resolution, 10-band output**.
6. Producing multiple GIS analysis layers.
7. Providing an original-vs-super-resolved comparison.
8. Exporting georeferenced GeoTIFF files and a ZIP containing all outputs.
> **Important:** The 2.5 m imagery generated by TerraVision is a model-based reconstruction. It is not native 2.5 m satellite observation.
---
# โจ Key Features
### ๐ฐ๏ธ Sentinel-2 Data
- Sentinel-2 L2A imagery
- 10 spectral bands
- User-defined geographical location
- User-defined date range
### ๐ฌ AI-Based Super Resolution
- ESA OpenSR **LDSR-S2 + SEN2SR**
- 10 m input
- Model-generated 2.5 m output
- 4ร spatial upscaling
- 10-band super-resolved output
### ๐บ๏ธ GIS Visualization
TerraVision generates:
- Super-Resolved RGB
- Original Sentinel-2 RGB
- False Color / Infrared
- SWIR Composite
- NDVI
- NDWI
- NDBI
- NBR
- LDSR-S2 Uncertainty
### ๐ Image Comparison
An interactive before/after comparison allows users to visually compare:
**Original Sentinel-2 โ Super-Resolved Output**
### ๐พ Geospatial Export
Users can download:
- Individual GeoTIFF layers
- Complete ZIP package containing all generated layers
All exported layers preserve their geospatial reference information.
---
# ๐ง Super-Resolution Pipeline
TerraVision uses the official ESA OpenSR approach combining:
```text
Sentinel-2 L2A
โ
โผ
Data Retrieval
โ
โผ
10-band Sentinel-2 Input
โ
โผ
LDSR-S2 + SEN2SR
โ
โผ
2.5 m Super-Resolved Output
โ
โโโ B02
โโโ B03
โโโ B04
โโโ B05
โโโ B06
โโโ B07
โโโ B08
โโโ B8A
โโโ B11
โโโ B12
โ
โผ
GIS Analysis Layers
````
The pipeline combines the strengths of:
### LDSR-S2
Latent diffusion super-resolution for Sentinel-2 RGB-NIR information.
### SEN2SR
Super-resolution processing for the additional Sentinel-2 spectral bands.
Together, they provide the 10-band super-resolved output used by TerraVision.
---
# ๐ฐ๏ธ Sentinel-2 Bands
| Band | Description | Resolution |
| ---- | ------------------- | ---------- |
| B02 | Blue | 10 m |
| B03 | Green | 10 m |
| B04 | Red | 10 m |
| B05 | Vegetation Red Edge | 20 m |
| B06 | Vegetation Red Edge | 20 m |
| B07 | Vegetation Red Edge | 20 m |
| B08 | NIR | 10 m |
| B8A | Narrow NIR | 20 m |
| B11 | SWIR 1 | 20 m |
| B12 | SWIR 2 | 20 m |
The super-resolution pipeline produces these bands at the model-generated 2.5 m output scale.
---
# ๐ Spectral Analysis
TerraVision converts the super-resolved bands into several commonly used remote-sensing indices.
## ๐ฑ NDVI
**Normalized Difference Vegetation Index**
```text
NDVI = (B08 - B04) / (B08 + B04)
```
Used to analyze vegetation density and vegetation condition.
---
## ๐ง NDWI
TerraVision uses the Green-NIR formulation:
```text
NDWI = (B03 - B08) / (B03 + B08)
```
Used to highlight water-related features.
---
## ๐๏ธ NDBI
**Normalized Difference Built-up Index**
```text
NDBI = (B11 - B08) / (B11 + B08)
```
Used for identifying built-up and urban areas.
---
## ๐ฅ NBR
**Normalized Burn Ratio**
```text
NBR = (B08 - B12) / (B08 + B12)
```
Useful for analyzing burn-affected areas and vegetation disturbance.
---
# ๐จ Visualization Layers
TerraVision provides several visualization products.
### RGB Composite
```text
R = B04
G = B03
B = B02
```
Provides a natural-color representation.
### False Color Composite
```text
R = B08
G = B04
B = B03
```
Useful for vegetation analysis.
### SWIR Composite
```text
R = B12
G = B11
B = B04
```
Useful for analyzing moisture, soil, built-up areas and burned regions.
---
# ๐ Uncertainty Map
TerraVision also exposes the uncertainty estimation available from the underlying **LDSR-S2 RGB-NIR component**.
The uncertainty map highlights areas where the super-resolution model has greater variation across generated samples.
```text
Dark โ Lower estimated uncertainty
Bright โ Higher estimated uncertainty
```
### Important limitation
This should **not** be interpreted as a calibrated confidence score for the complete 10-band output.
The current implementation calculates uncertainty from the underlying **4-band LDSR-S2 RGB-NIR model**.
---
# ๐บ๏ธ TerraVision Workflow
```text
User
โ
โโโ Select Location
โ โโโ Latitude / Longitude
โ
โโโ Select Date Range
โ
โผ
Sentinel-2 L2A Data
โ
โผ
Preprocessing
โ
โผ
ESA LDSR-S2 + SEN2SR
โ
โผ
2.5 m Super-Resolved Imagery
โ
โโโ RGB
โโโ False Color
โโโ SWIR
โโโ NDVI
โโโ NDWI
โโโ NDBI
โโโ NBR
โโโ Uncertainty
โ
โผ
Interactive Visualization
โ
โผ
GeoTIFF / ZIP Export
```
---
# ๐ ๏ธ Technology Stack
## Frontend / UI
* Python
* Gradio
* Interactive visualization
* Image comparison slider
* GIS map integration
## Machine Learning
* PyTorch
* ESA OpenSR
* LDSR-S2
* SEN2SR
## Geospatial Processing
* Rasterio
* Rioxarray
* GeoPandas
* PyProj
* Xarray
* Dask
* Cubo
## Satellite Data
* Sentinel-2 L2A
* STAC-based data access
## Model / Data Management
* MLSTAC
* Hugging Face ecosystem
## Deployment
* Hugging Face Spaces
* Gradio
* ZeroGPU-compatible architecture
---
# ๐ฆ Installation
Clone the repository:
```bash
git clone https://github.com/prateeksharmacoder-sys/satellite-LDRS-SEN2SR.git
cd TerraVision
```
Create a virtual environment:
```bash
python -m venv venv
```
Activate it.
### Windows
```bash
venv\Scripts\activate
```
### Linux / macOS
```bash
source venv/bin/activate
```
Install dependencies:
```bash
pip install -r requirements.txt
```
---
# โถ๏ธ Running the Application
Run:
```bash
python app.py
```
The Gradio interface will provide a local web address.
For development, the application can also be launched with:
```python
demo.launch()
```
---
# ๐ Project Structure
```text
TerraVision/
โ
โโโ app.py
โโโ requirements.txt
โโโ README.md
โ
โโโ models/
โ โโโ model configuration / model assets
โ
โโโ utils/
โ โโโ preprocessing.py
โ โโโ visualization.py
โ โโโ geotiff.py
โ โโโ analysis.py
โ
โโโ outputs/
โ โโโ generated products
โ
โโโ assets/
โโโ UI images / project assets
```
> The exact structure may vary depending on the final deployment version.
---
# ๐ฌ Technical Implementation
### 1. Data Retrieval
TerraVision retrieves Sentinel-2 L2A imagery using a STAC-based workflow.
The application requests:
```text
B02
B03
B04
B05
B06
B07
B08
B8A
B11
B12
```
---
### 2. Preprocessing
Sentinel-2 reflectance values are converted into normalized floating-point values before inference.
```python
low_resolution = low_resolution / 10000
```
---
### 3. Super Resolution
The combined model is loaded and executed using SEN2SR:
```python
super_resolution = sen2sr.predict_large(
model=model,
X=low_resolution,
overlap=16
)
```
The model converts:
```text
10 ร 128 ร 128
```
into approximately:
```text
10 ร 512 ร 512
```
---
### 4. Spectral Products
The generated bands are used to calculate spectral indices such as:
```python
NDVI = (B08 - B04) / (B08 + B04)
NDWI = (B03 - B08) / (B03 + B08)
NDBI = (B11 - B08) / (B11 + B08)
NBR = (B08 - B12) / (B08 + B12)
```
---
### 5. Geospatial Export
Generated products are exported as GeoTIFF files while preserving:
* CRS
* Spatial transform
* Resolution
* Geographic bounds
The prototype output was verified at:
```text
Resolution: 2.5 m
CRS: EPSG:32630
Output size: 512 ร 512
```
The exact CRS changes according to the selected geographic location.
---
# ๐ฅ Output Files
A typical output package contains:
```text
terravision_layers.zip
โ
โโโ sr_rgb.tif
โโโ false_color.tif
โโโ swir.tif
โโโ ndvi.tif
โโโ ndwi.tif
โโโ ndbi.tif
โโโ nbr.tif
โโโ uncertainty.tif
```
---
# โก Performance
The current prototype has been successfully tested end-to-end with:
```text
Sentinel-2 input: 10 ร 128 ร 128
Super-resolution: 10 ร 512 ร 512
Output resolution: 2.5 m
Analysis layers: 8
GeoTIFF export: Successful
ZIP generation: Successful
```
The super-resolution inference is the computationally expensive part of the pipeline.
Uncertainty estimation requires additional inference and is therefore treated as an optional computational component for deployment optimization.
---
# โ ๏ธ Limitations
TerraVision currently has several limitations.
### 1. Model-Based Resolution
The 2.5 m output is reconstructed by an AI model and is not equivalent to native 2.5 m satellite imagery.
### 2. Reconstruction Errors
Super-resolution models can introduce artifacts or reconstruct details that are not directly observed in the original imagery.
### 3. Cloud and Atmospheric Effects
Clouds, haze and poor-quality Sentinel-2 observations can affect the output.
### 4. Scientific Validation
The current prototype has been technically validated for:
* successful model inference
* correct output dimensions
* spectral layer generation
* GeoTIFF generation
* geospatial referencing
A comprehensive validation against independent high-resolution reference imagery using metrics such as **PSNR, SSIM and spectral consistency** remains future work.
### 5. Uncertainty
The current uncertainty output represents the LDSR-S2 RGB-NIR component rather than a calibrated uncertainty estimate for all 10 bands.
### 6. Temporal Analysis
Change detection such as **dNBR** requires pre-event and post-event imagery and is not part of the current single-image workflow.
---
# ๐ฎ Future Scope
Potential future improvements include:
* Multi-date satellite analysis
* Automated change detection
* dNDVI / dNBR analysis
* Cloud masking
* Larger-area processing
* Batch processing
* More advanced GIS layers
* Scientific validation using higher-resolution reference imagery
* Performance optimization
* GPU acceleration
* Caching of satellite data
* Production-scale deployment
* User accounts and project history
* Export to additional GIS formats
---
# ๐ Deployment
TerraVision is designed to be deployed as a Gradio application.
The planned deployment architecture is:
```text
User
โ
โผ
TerraVision Web Interface
โ
โผ
Gradio Application
โ
โโโ Satellite Data Retrieval
โ
โโโ GPU Inference
โ
โโโ Spectral Analysis
โ
โโโ GeoTIFF Generation
โ
โผ
Results + Downloads
```
The application can be adapted for GPU-backed deployment using **Hugging Face Spaces ZeroGPU**.
---
# ๐งช Validation Status
| Component | Status |
| ------------------------------- | -------------- |
| Sentinel-2 data retrieval | โ
Tested |
| 10-band input generation | โ
Tested |
| LDSR-S2 + SEN2SR inference | โ
Tested |
| 2.5 m output generation | โ
Tested |
| RGB generation | โ
Tested |
| False Color | โ
Tested |
| SWIR | โ
Tested |
| NDVI | โ
Tested |
| NDWI | โ
Tested |
| NDBI | โ
Tested |
| NBR | โ
Tested |
| LDSR-S2 uncertainty | โ
Tested |
| GeoTIFF export | โ
Tested |
| Georeferencing | โ
Verified |
| ZIP export | โ
Tested |
| Interactive web UI | โ
Prototype |
| Scientific benchmark validation | ๐ Future work |
| Production-scale deployment | ๐ Planned |
---
# ๐ฏ Use Cases
TerraVision can support exploratory analysis in areas such as:
* ๐ฑ Vegetation monitoring
* ๐ง Water-body analysis
* ๐๏ธ Urban expansion studies
* ๐ฅ Burn-area analysis
* ๐พ Agricultural monitoring
* ๐ฐ๏ธ Remote-sensing research
* ๐บ๏ธ GIS analysis
* ๐ Environmental monitoring
---
# ๐ Acknowledgements
TerraVision builds upon open-source satellite super-resolution research and software from the **European Space Agency (ESA) OpenSR project**, including LDSR-S2 and SEN2SR.
The project also uses open geospatial and satellite-data technologies including:
* Sentinel-2
* Cubo
* MLSTAC
* PyTorch
* Rasterio
* Xarray
* Gradio
---
# ๐ Disclaimer
TerraVision is a research and demonstration project.
The generated 2.5 m imagery should not automatically be treated as equivalent to native high-resolution satellite imagery. Results may contain model reconstruction artifacts and should be independently validated before being used for critical scientific, commercial, legal, or operational decisions.
---
# ๐จโ๐ป Project
**TerraVision**
> *Sharper Earth. Brighter Decisions.*
Built as a geospatial AI project for exploring the potential of satellite-image super-resolution and GIS analysis.
---
## โญ If you find TerraVision interesting
Consider giving the repository a โญ and exploring the implementation.
````
### Recommended GitHub repository files
For your current project, I would keep the repository clean like this:
```text
TerraVision/
โ
โโโ README.md โ this file
โโโ app.py โ main Gradio application
โโโ requirements.txt
โโโ .gitignore
โ
โโโ utils/
โ โโโ satellite.py
โ โโโ analysis.py
โ โโโ visualization.py
โ โโโ geotiff.py
โ
โโโ assets/
โโโ screenshots/
````
**One important point:** don't upload the ~1.4 GB model file directly into GitHub. Your code can download/load the model from its Hugging Face model repository at runtime.
If you want, I can also create the **actual `README.md` file for you as a downloadable file**, ready to put directly into your GitHub repository.
|