Skip to main content

header

A comprehensive benchmark for real-world Sentinel-2 imagery super-resolution

PyPI License Documentation Status Black isort


GitHub: https://github.com/ESAOpenSR/opensr-test

Documentation: https://opensr-test.readthedocs.io/

PyPI: https://pypi.org/project/opensr-test/

Paper: Coming soon!


Overview

In remote sensing, Super-Resolution goal is to artificially increase the ground sampling distance (GSD) of a low-resolution (LR) image. However, assessing the GSD is not a trivial task. In literature, we find two main points of concern.

Firstly, most models are tested on synthetic data, raising doubts about their real-world applicability and performance. Secondly, traditional evaluation metrics such as PSNR, LPIPS, and SSIM are not designed for assessing SR performance. These metrics fall short, especially in conditions involving changes in reflectance intensity or spatial misalignments - scenarios that are frequently encountered when working with real-world data.

To address these challenges, 'opensr-test' provides a fresh and fair approach for SR benchmark. On one front, we provide three datasets that were carefully crafted to minimize spatial and spectral misalignment. On the other front, we provide a comprehensive set of metrics grouped into three categories: spectral and spatial consistency, the distance between the SR, HR and LR images, and overall correctness. These metrics are designed to assess the performance of SR models in real-world scenarios.

How to use

The example below shows how to use opensr-test to benchmark your SR model.

import torch
import opensr_test

lr = torch.rand(4, 64, 64)
hr = torch.rand(4, 256, 256)
sr = torch.rand(4, 256, 256)

metrics = opensr_test.Metrics()
metrics.setup(lr=lr, sr=sr, hr=hr)
metrics.compute() # Compute the metrics
metrics.summary() # Print the metrics

Installation

Install the latest version from PyPI:

pip install opensr-test

Upgrade opensr-test by running:

pip install -U opensr-test

Install the latest dev version from GitHub by running:

pip install git+https://github.com/ESAOpenSR/opensr-test

Examples

The following examples show how to use opensr-test to benchmark your SR model.

  • Use opensr-test with a custom SR TensorFlow model Open In Colab

  • Use opensr-test with a custom PyTorch model Open In Colab

  • Use opensr-test with a diffuser model Open In Colab

  • Use opensr-test to test a multi-image SR model (Satlas Super Resolution) Open In Colab

  • Use opensr-test to create a animated GIF of the SR correctness Open In Colab

Visualizations

The opensr-test package provides a set of visualizations to help you understand the performance of your SR model.

import torch
import opensr_test
from super_image import HanModel
import matplotlib.pyplot as plt

# Define the SR model
srmodel = HanModel.from_pretrained('eugenesiow/han', scale=4)
srmodel.eval()

# Load the data
lr, hr, landuse, parameters = opensr_test.load("spot").values()

# Define the benchmark experiment
metrics = opensr_test.Metrics()

# Define the image to be tested
idx = 0
lr_img = torch.from_numpy(lr[idx, 0:3])
hr_img = torch.from_numpy(hr[idx, 0:3])
land_img = torch.from_numpy(landuse[idx, 0])
with torch.no_grad():
    sr_img = srmodel(lr_img[None]).squeeze()

# Compute the metrics
metrics.setup(lr=lr_img, sr=sr_img, hr=hr_img, landuse=land_img)
metrics.compute()

Now, we can visualize the results using the opensr_test.visualize module. fDisplay the triplets LR, SR and HR images:

metrics.plot_triplets()

Display the quadruplets LR, SR, HR and landuse images:

metrics.plot_quadruplets()

Display the matching points between the LR and SR images:

metrics.plot_spatial_matches()

Display a summary of all the metrics:

metrics.plot_summary()

Display the correctness of the SR image:

metrics.plot_tc()

Deeper understanding

Explore the API section for more details about personalizing your benchmark experiments.

opensr-test

Citation

If you use opensr-test in your research, please cite our paper:

Coming soon!

Acknowledgements

This work was make with the support of the European Space Agency (ESA) under the project “Explainable AI: application to trustworthy super-resolution (OpenSR)”. Cesar Aybar acknowledges support by the National Council of Science, Technology, and Technological Innovation (CONCYTEC, Peru) through the “PROYECTOS DE INVESTIGACIÓN BÁSICA – 2023-01” program with contract number PE501083135-2023-PROCIENCIA.

opensr-test

Metadata

Release files for opensr-test 0.0.999999

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for opensr-test 0.0.999999
File Size Uploaded
opensr-test-0.0.999999.tar.gz 50.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for opensr-test 0.0.999999
File Interpreter ABI Platform
opensr_test-0.0.999999-py3-none-any.whl Python 3 none any Details

Total release size: 104.3 kB

Release files / opensr-test-0.0.999999.tar.gz

Download URL opensr-test-0.0.999999.tar.gz
Size 50.0 kB
Tags Source
SHA-256 checksum
How to use checksums
c50de589d51353d78d8a4c38720a6c4845370e1ca923bd37ac8e27b373b50849
BLAKE2b-256 checksum
How to use checksums
990f82af7e8f4771d34e6eb4e3bedb49d64a9b82ecb8b8b1c4883251093980e4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.4.2 requests/2.31.0 setuptools/68.2.2 requests-toolbelt/0.8.0 tqdm/4.65.0 CPython/3.8.10

Release files / opensr_test-0.0.999999-py3-none-any.whl

Download URL opensr_test-0.0.999999-py3-none-any.whl
Size 54.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
15c01ff1e3f8710a86983b091a7f3d80d77d527cbe7fe81126ef5841f994d337
BLAKE2b-256 checksum
How to use checksums
8a211e549b0d735221c289902b5d3e3a6cdd306167d918f350a3a1179327affb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.4.2 requests/2.31.0 setuptools/68.2.2 requests-toolbelt/0.8.0 tqdm/4.65.0 CPython/3.8.10

Release history Release notifications | RSS feed

1.3.3

2 release files

1.3.2

2 release files

1.2.1

2 release files

1.2.0

2 release files

1.1.0

2 release files

1.0.0

2 release files

0.9.0

2 release files

0.2.9

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

This release

0.0.999999 This release

2 release files

0.0.7

1 release file

0.0.6

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page