# anandraj239/srm-sentinel2-superresolution architecture

> Architecture diagram of the GitHub repository anandraj239/srm-sentinel2-superresolution, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-18). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/anandraj239/srm-sentinel2-superresolution
- Repository: https://github.com/anandraj239/srm-sentinel2-superresolution

## Overview

This repository presents a Sentinel-2 super-resolution and land-cover mapping workflow: prepare synthetic low-/high-resolution patch pairs, train or run 4× SwinIR enhancement, classify the enhanced image with SegFormer, and evaluate or visualize outputs. The clearest executable end-to-end path is in `scripts/full_inference.py`; dataset preparation, segmentation, metrics, and comparison tools are separate scripts. Training and the broader download-to-classify capability are documented, but no downloader or training implementation is present in the supplied tree, so those links rely on README evidence.

Main entry points: [`scripts/full_inference.py`](https://github.com/anandraj239/srm-sentinel2-superresolution/blob/main/scripts/full_inference.py) (Enhanced image), [`scripts/prepare_dataset.py`](https://github.com/anandraj239/srm-sentinel2-superresolution/blob/main/scripts/prepare_dataset.py) (Training pairs), [`scripts/train_swinir_satellite.yml`](https://github.com/anandraj239/srm-sentinel2-superresolution/blob/main/scripts/train_swinir_satellite.yml) (SwinIR training setup), [`scripts/calculate_metrics.py`](https://github.com/anandraj239/srm-sentinel2-superresolution/blob/main/scripts/calculate_metrics.py) (Image metrics)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_data["Satellite Data Preparation"]
  node_sentinel["Sentinel-2 imagery"]
  node_patch_crop["Patch cropping<br/>[crop_patch.py]"]
  node_dataset["Training pairs<br/>[prepare_dataset.py]"]
end

subgraph group_models["Enhancement and Classification"]
  node_train_config["SwinIR training setup"]
  node_swinir["SwinIR super-resolution<br/>[full_inference.py]"]
  node_segformer["SegFormer classification<br/>[full_inference.py]"]
  node_seg_standalone["Segmentation runner"]
  node_sr_output["Enhanced image<br/>[full_inference.py]"]
  node_seg_output["Class map and overlay<br/>[full_inference.py]"]
end

subgraph group_evaluation["Evaluation and Results"]
  node_metrics["Image metrics"]
  node_metrics_report["Metrics report<br/>[metrics_report.txt]"]
  node_comparison["Result comparisons<br/>[compare_results.py]"]
  node_final_comparison["Pipeline comparison"]
end

subgraph group_demo["Presentation"]
  node_demo["Interactive demo<br/>[demo.py]"]
end

node_user(("Analyst"))

node_sentinel -->|"reads bands"| node_patch_crop
node_sentinel -->|"extracts patches"| node_dataset
node_dataset -.->|"supplies pairs"| node_train_config
node_train_config -.->|"configures training"| node_swinir
node_user -->|"requests inference"| node_swinir
node_swinir -->|"writes enhancement"| node_sr_output
node_sr_output -->|"classifies image"| node_segformer
node_segformer -->|"writes map and overlay"| node_seg_output
node_sr_output -->|"loads SR image"| node_seg_standalone
node_user -->|"requests evaluation"| node_metrics
node_metrics -->|"writes metrics"| node_metrics_report
node_user -->|"requests comparison"| node_comparison
node_user -->|"requests panel"| node_final_comparison
node_user -->|"starts demo"| node_demo

click node_patch_crop "https://github.com/anandraj239/srm-sentinel2-superresolution/blob/main/scripts/crop_patch.py"
click node_dataset "https://github.com/anandraj239/srm-sentinel2-superresolution/blob/main/scripts/prepare_dataset.py"
click node_train_config "https://github.com/anandraj239/srm-sentinel2-superresolution/blob/main/scripts/train_swinir_satellite.yml"
click node_swinir "https://github.com/anandraj239/srm-sentinel2-superresolution/blob/main/scripts/full_inference.py"
click node_segformer "https://github.com/anandraj239/srm-sentinel2-superresolution/blob/main/scripts/full_inference.py"
click node_seg_standalone "https://github.com/anandraj239/srm-sentinel2-superresolution/blob/main/scripts/segformer_inference.py"
click node_sr_output "https://github.com/anandraj239/srm-sentinel2-superresolution/blob/main/scripts/full_inference.py"
click node_seg_output "https://github.com/anandraj239/srm-sentinel2-superresolution/blob/main/scripts/full_inference.py"
click node_metrics "https://github.com/anandraj239/srm-sentinel2-superresolution/blob/main/scripts/calculate_metrics.py"
click node_metrics_report "https://github.com/anandraj239/srm-sentinel2-superresolution/blob/main/results/metrics_report.txt"
click node_comparison "https://github.com/anandraj239/srm-sentinel2-superresolution/blob/main/scripts/compare_results.py"
click node_final_comparison "https://github.com/anandraj239/srm-sentinel2-superresolution/blob/main/scripts/final_comparison.py"
click node_demo "https://github.com/anandraj239/srm-sentinel2-superresolution/blob/main/demo.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_sentinel,node_patch_crop,node_dataset toneBlue
class node_train_config,node_swinir,node_segformer,node_seg_standalone,node_sr_output,node_seg_output toneAmber
class node_metrics,node_metrics_report,node_comparison,node_final_comparison toneMint
class node_demo toneRose
class node_user toneIndigo
```

## Components

### Satellite Data Preparation

- **Sentinel-2 imagery**
- [Patch cropping](https://github.com/anandraj239/srm-sentinel2-superresolution/blob/main/scripts/crop_patch.py): `scripts/crop_patch.py`
- [Training pairs](https://github.com/anandraj239/srm-sentinel2-superresolution/blob/main/scripts/prepare_dataset.py): `scripts/prepare_dataset.py`

### Enhancement and Classification

- [SwinIR training setup](https://github.com/anandraj239/srm-sentinel2-superresolution/blob/main/scripts/train_swinir_satellite.yml): `scripts/train_swinir_satellite.yml`
- [SwinIR super-resolution](https://github.com/anandraj239/srm-sentinel2-superresolution/blob/main/scripts/full_inference.py): `scripts/full_inference.py`
- [SegFormer classification](https://github.com/anandraj239/srm-sentinel2-superresolution/blob/main/scripts/full_inference.py): `scripts/full_inference.py`
- [Segmentation runner](https://github.com/anandraj239/srm-sentinel2-superresolution/blob/main/scripts/segformer_inference.py): `scripts/segformer_inference.py`
- [Enhanced image](https://github.com/anandraj239/srm-sentinel2-superresolution/blob/main/scripts/full_inference.py): `scripts/full_inference.py`
- [Class map and overlay](https://github.com/anandraj239/srm-sentinel2-superresolution/blob/main/scripts/full_inference.py): `scripts/full_inference.py`

### Evaluation and Results

- [Image metrics](https://github.com/anandraj239/srm-sentinel2-superresolution/blob/main/scripts/calculate_metrics.py): `scripts/calculate_metrics.py`
- [Metrics report](https://github.com/anandraj239/srm-sentinel2-superresolution/blob/main/results/metrics_report.txt): `results/metrics_report.txt`
- [Result comparisons](https://github.com/anandraj239/srm-sentinel2-superresolution/blob/main/scripts/compare_results.py): `scripts/compare_results.py`
- [Pipeline comparison](https://github.com/anandraj239/srm-sentinel2-superresolution/blob/main/scripts/final_comparison.py): `scripts/final_comparison.py`

### Presentation

- [Interactive demo](https://github.com/anandraj239/srm-sentinel2-superresolution/blob/main/demo.py): `demo.py`

### Other components

- **Analyst**

## Connections

- Sentinel-2 imagery → Patch cropping: reads bands (evidence: `scripts/crop_patch.py`)
- Sentinel-2 imagery → Training pairs: extracts patches (evidence: `scripts/prepare_dataset.py`)
- Training pairs → SwinIR training setup: supplies pairs (evidence: `README.md`)
- SwinIR training setup → SwinIR super-resolution: configures training (evidence: `README.md`)
- Analyst → SwinIR super-resolution: requests inference (evidence: `README.md`)
- SwinIR super-resolution → Enhanced image: writes enhancement (evidence: `scripts/full_inference.py`)
- Enhanced image → SegFormer classification: classifies image (evidence: `scripts/full_inference.py`)
- SegFormer classification → Class map and overlay: writes map and overlay (evidence: `scripts/full_inference.py`)
- Enhanced image → Segmentation runner: loads SR image (evidence: `scripts/segformer_inference.py`)
- Analyst → Image metrics: requests evaluation (evidence: `README.md`)
- Image metrics → Metrics report: writes metrics (evidence: `scripts/calculate_metrics.py`)
- Analyst → Result comparisons: requests comparison (evidence: `scripts/compare_results.py`)
- Analyst → Pipeline comparison: requests panel (evidence: `scripts/final_comparison.py`)
- Analyst → Interactive demo: starts demo (evidence: `demo.py`)
