Update README.md
Browse files
README.md
CHANGED
|
@@ -12,3 +12,79 @@ license: cc-by-4.0
|
|
| 12 |
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 ($S2_{like}$). Subsequently, this degradation model was utilized to create the second component, a synthetic dataset comprising 17,657 NAIP and $S2_{like}$ 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.
|
| 13 |
|
| 14 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
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 ($S2_{like}$). Subsequently, this degradation model was utilized to create the second component, a synthetic dataset comprising 17,657 NAIP and $S2_{like}$ 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.
|
| 13 |
|
| 14 |
|
| 15 |
+
## Load cross-sensor dataset
|
| 16 |
+
|
| 17 |
+
```{python}
|
| 18 |
+
import rioxarray
|
| 19 |
+
import torch
|
| 20 |
+
|
| 21 |
+
DEMO_PATH = "https://huggingface.co/datasets/isp-uv-es/SEN2NAIP/resolve/main/demo/"
|
| 22 |
+
|
| 23 |
+
cross_sensor_path = DEMO_PATH + "cross-sensor/ROI_0000/"
|
| 24 |
+
hr_data = rioxarray.open_rasterio(cross_sensor_path + "hr.tif")
|
| 25 |
+
lr_data = rioxarray.open_rasterio(cross_sensor_path + "lr.tif")
|
| 26 |
+
hr_torch = torch.from_numpy(hr_data.to_numpy()) / 255
|
| 27 |
+
lr_torch = torch.from_numpy(lr_data.to_numpy()) / 10000
|
| 28 |
+
```
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
## Load Synthetic dataset
|
| 32 |
+
|
| 33 |
+
```{python}
|
| 34 |
+
import opensr_degradation
|
| 35 |
+
import rioxarray
|
| 36 |
+
import datasets
|
| 37 |
+
import requests
|
| 38 |
+
import tempfile
|
| 39 |
+
import torch
|
| 40 |
+
import json
|
| 41 |
+
|
| 42 |
+
|
| 43 |
+
def load_metadata(metadata_path: str) -> dict:
|
| 44 |
+
tmpfile = tempfile.NamedTemporaryFile(suffix=".json")
|
| 45 |
+
with requests.get(metadata_path) as response:
|
| 46 |
+
with open(tmpfile.name, "wb") as file:
|
| 47 |
+
file.write(response.content)
|
| 48 |
+
metadata_json = json.load(open(tmpfile.name, "r"))
|
| 49 |
+
return metadata_json
|
| 50 |
+
|
| 51 |
+
DEMO_PATH = "https://huggingface.co/datasets/isp-uv-es/SEN2NAIP/resolve/main/demo/"
|
| 52 |
+
|
| 53 |
+
# Synthetic LR and HR data ------------------------------
|
| 54 |
+
synthetic_path = DEMO_PATH + "synthetic/ROI_0001/"
|
| 55 |
+
|
| 56 |
+
hr_early_data = rioxarray.open_rasterio(synthetic_path + "early/01__m_4506807_nw_19_1_20110818.tif")
|
| 57 |
+
hr_early_torch = torch.from_numpy(hr_early_data.to_numpy()) / 255
|
| 58 |
+
hr_early_metadata = load_metadata(synthetic_path + "late/metadata.json")
|
| 59 |
+
hr_early_torch_hat = opensr_degradation.main.predict_table(
|
| 60 |
+
hr_early_torch, hr_early_metadata["sim_histograms"], "gamma_multivariate_normal_50"
|
| 61 |
+
)
|
| 62 |
+
|
| 63 |
+
hr_late_data = rioxarray.open_rasterio(synthetic_path + "late/02__m_4506807_nw_19_060_20210920.tif")
|
| 64 |
+
hr_late_torch = torch.from_numpy(hr_late_data.to_numpy()) / 255
|
| 65 |
+
hr_late_metadata = load_metadata(synthetic_path + "late/metadata.json")
|
| 66 |
+
hr_late_torch_hat = opensr_degradation.main.predict_table(
|
| 67 |
+
hr_late_torch, hr_late_metadata["sim_histograms"], "gamma_multivariate_normal_50"
|
| 68 |
+
)
|
| 69 |
+
|
| 70 |
+
import matplotlib.pyplot as plt
|
| 71 |
+
fig, ax = plt.subplots(2, 2, figsize=(10, 5))
|
| 72 |
+
ax = ax.flatten()
|
| 73 |
+
ax[0].imshow(hr_early_torch[[3, 1, 2]].permute(1, 2, 0))
|
| 74 |
+
ax[0].set_title("Original")
|
| 75 |
+
ax[1].imshow(hr_early_torch_hat[[3, 1, 2]].permute(1, 2, 0)*3)
|
| 76 |
+
ax[1].set_title("Degraded")
|
| 77 |
+
ax[2].imshow(hr_late_torch[[3, 1, 2]].permute(1, 2, 0))
|
| 78 |
+
ax[2].set_title("Original")
|
| 79 |
+
ax[3].imshow(hr_late_torch_hat[[3, 1, 2]].permute(1, 2, 0)*3)
|
| 80 |
+
ax[3].set_title("Degraded")
|
| 81 |
+
# remove axis and space
|
| 82 |
+
for a in ax:
|
| 83 |
+
a.axis("off")
|
| 84 |
+
plt.tight_layout()
|
| 85 |
+
plt.show()
|
| 86 |
+
```
|
| 87 |
+
|
| 88 |
+
<center>
|
| 89 |
+
<img src="demo/image_demo.png" width=70%>
|
| 90 |
+
</center>
|