Datasets:

License:
File size: 3,966 Bytes
07e4247
 
 
fbb72c8
 
0a2727f
fbb72c8
 
 
 
 
0a2727f
 
 
 
 
 
 
 
fbb72c8
e7cc0c9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
fbb72c8
e9f5a3d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
708a34a
 
 
 
 
e9f5a3d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
02a7656
 
 
 
e9f5a3d
 
 
 
02a7656
e9f5a3d
02a7656
 
 
 
 
e9f5a3d
 
 
 
02a7656
e9f5a3d
e7cc0c9
 
 
 
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
---
license: cc-by-4.0
---

<center>
  <img src="demo/logo.png" width=85%>
</center>


# SEN2NAIP

The increasing demand for high spatial resolution in remote sensing imagery has led to the necessity of super-resolution (SR) algorithms that 
convert low-resolution (LR) images into high-resolution (HR) ones. To address this need, we introduce SEN2NAIP, a large remote sensing dataset
designed to support conventional and reference-based SR model training. SEN2NAIP is structured into two components to provide a broad spectrum
of research and application needs. The first component comprises a cross-sensor dataset of 2,851 pairs of LR images from Sentinel-2 L2A and HR
images from the National Agriculture Imagery Program (NAIP). Leveraging this dataset, we developed a degradation model capable of converting NAIP
images to match the characteristics of Sentinel-2 imagery (S2like). Subsequently, this degradation model was utilized to create the second component,
a synthetic dataset comprising 17,657 NAIP and S2like image pairs. With the SEN2NAIP dataset, we aim to provide a valuable resource that facilitates
the exploration of new techniques for enhancing the spatial resolution of Sentinel-2 satellite imagery.

# DOWNLOAD DATASET

```
from huggingface_hub import hf_hub_download

# Donwload cross-sensor dataset
hf_hub_download(
    repo_id="isp-uv-es/SEN2NAIP",
    repo_type="dataset",
    filename="cross-sensor/cross-sensor.zip"
)

# Donwload synthetic dataset
for i in range(1, 19):
    hf_hub_download(
        repo_id="isp-uv-es/SEN2NAIP",
        repo_type="dataset",
        filename="synthetic/synthetic_%02d.zip" % i
    )
```



# REPRODUCIBLE EXAMPLES

## Load cross-sensor dataset

```{python}
import rioxarray
import torch

DEMO_PATH = "https://huggingface.co/datasets/isp-uv-es/SEN2NAIP/resolve/main/demo/"

cross_sensor_path = DEMO_PATH + "cross-sensor/ROI_0000/"
hr_data = rioxarray.open_rasterio(cross_sensor_path + "hr.tif")
lr_data = rioxarray.open_rasterio(cross_sensor_path + "lr.tif")
hr_torch = torch.from_numpy(hr_data.to_numpy()) / 255
lr_torch = torch.from_numpy(lr_data.to_numpy()) / 10000
```


## Load Synthetic dataset

Available methods: **vae_histogram_matching**, **vae_histogram_matching**, **gamma_multivariate_normal_90**, **gamma_multivariate_normal_75**, **gamma_multivariate_normal_50**,
**gamma_multivariate_normal_25**, **gamma_multivariate_normal_10**.



```{python}
import opensr_degradation
import rioxarray
import datasets
import requests
import tempfile
import torch
import json


def load_metadata(metadata_path: str) -> dict:
    tmpfile = tempfile.NamedTemporaryFile(suffix=".json")
    with requests.get(metadata_path) as response:
        with open(tmpfile.name, "wb") as file:
            file.write(response.content)
        metadata_json = json.load(open(tmpfile.name, "r"))
    return metadata_json

DEMO_PATH = "https://huggingface.co/datasets/isp-uv-es/SEN2NAIP/resolve/main/demo/"

# Synthetic LR and HR data ------------------------------
synthetic_path = DEMO_PATH + "synthetic/ROI_0001/"

hr_early_data = rioxarray.open_rasterio(synthetic_path + "early/01__m_4506807_nw_19_1_20110818.tif")
hr_early_torch = torch.from_numpy(hr_early_data.to_numpy()) / 255
hr_early_metadata = load_metadata(synthetic_path + "late/metadata.json")
lr_hat, hr_hat = opensr_degradation.main.get_s2like(
    image=hr_early_torch,
    table=hr_early_metadata["sim_histograms"],
    model="gamma_multivariate_normal_50"
)


import matplotlib.pyplot as plt
fig, ax = plt.subplots(1, 3, figsize=(10, 5))
ax[0].imshow(hr_early_torch[[3, 1, 2]].permute(1, 2, 0))
ax[0].set_title("NAIP")
ax[1].imshow(hr_hat[[3, 1, 2]].permute(1, 2, 0)*3)
ax[1].set_title("NAIPhat")
ax[2].imshow(lr_hat[[3, 1, 2]].permute(1, 2, 0)*3)
ax[2].set_title("S2like")
plt.show()
```

<center>
  <img src="https://github.com/ESAOpenSR/opensr-degradation/assets/16768318/c88fa16e-bbe7-4072-b518-5ab3b7278893" width=75%>
</center>

# CITATION

TODO!