Home

Awesome

Composed Image Retrieval for Remote Sensing

Official PyTorch implementation and benchmark dataset for IGARSS 2024 ORAL paper. [arXiv]

Build Status License PWC

<div align="center"> <img width="100%" alt="WeiCom" src=".github/method.PNG"> </div>

Overview

Motivation

In recent years, earth observation (EO) through remote sensing (RS) has witnessed an enormous growth in data volume, creating a challenge in managing and extracting relevant information. Remote sensing image retrieval (RSIR), which aims to search and retrieve images from RS image archives, has emerged as a key solution. However, RSIR methods encounter a major limitation: the reliance on a query of single modality. This constraint often restricts users from fully expressing their specific requirements.

Approach

To tackle this constraint, we introduce a new task, remote sensing composed image retrieval. RSCIR, integrating both image and text in the search query, is designed to retrieve images that are not only visually similar to the query image but also relevant to the details of the accompanying query text. Our RSCIR approach, called WeiCom, is expressive, flexible and training-free based on a vision-language model, utilizing a weighting parameter λ for more image- or text-oriented results, with λ → 0 or λ → 1 respectively.

<div align="center"> <img width="100%" alt="lambda" src=".github/teaser.PNG"> </div>

In this work, we recognize, present and qualitatively evaluate the capabilities and challenges of RSCIR. We demonstrate how users can now pair a query image with a query text specifying modifications related to color, context, density, existence, quantity, shape, size or texture of one or more classes.

<div align="center"> <img width="100%" alt="Attributes" src=".github/attr_use_cases_v2.png"> </div>

Quantitatively, we focus on color, context, density, existence, quantity, and shape modifications, establishing a new benchmark dataset, called PatterCom and an evaluation protocol.

Contributions

In summary, we make the following contributions:

Pre-trained models

For our experiments, you need to download CLIP and RemoteCLIP, both with a ViT-L/14 image encoder. After downloading, place them inside the models/ folder.

This code folder structure should then look like this:

rscir/
    |-- .github/
    |-- models/
        |-- CLIP-ViT-L-14.bin
        |-- RemoteCLIP-ViT-L-14.pt
    |-- .gitignore
    |-- LICENSE
    |-- README.md
    |-- evaluate.py
    |-- extract_features.py
    |-- utils.py

Environment

Create this environment for our experiments:

conda create -n rscir python=3.9 -y
conda activate rscir
conda install pytorch torchvision torchaudio pytorch-cuda=11.7 -c pytorch -c nvidia
pip install open_clip_torch

Dataset

PatterCom is based on PatterNet, a large-scale, high-resolution remote sensing dataset that comprises 38 classes, with each class containing 800 images of 256×256 pixels.

Download PatterNet from here and unzip it into PatterNet/ folder. Download patternnet.csv for here and place it in the same folder too. Finally, download PatternCom from here and place it into the same folder too.

The PatterNet/ folder structure should look like this:

PatterNet/
    |-- images/
    |-- PatternCom/
        |-- color.csv
        |-- context.csv
        |-- density.csv
        |-- existence.csv
        |-- quantity.csv
        |-- shape.csv
    |-- patternnet.csv
    |-- patternnet_description.pdf

Feature Extraction

To extract CLIP or RemoteCLIP features from PatternNet dataset, run:

python extract_features.py --model_name clip --dataset_path /path/to/PatternNet/

Replace clip with remoteclip for RemoteCLIP features.

Note that this will save features as pickle files inside PatterNet/features/ folder. Thus, the new folder structure should look like this:

PatterNet/
    |-- features/
        |-- patternnet_clip.pkl
        |-- patternnet_remoteclip.pkl
    |-- images/
    |-- PatternCom/
    |-- patternnet.csv
    |-- patternnet_description.pdf

Evaluation

Baselines

To evaluate extracted features on PatternCom RSCIR using baselines, run:

python evaluate.py --model_name clip --dataset_path /path/to/PatternNet/ --methods "Image only" "Text only" "Average Similarities"

Replace clip with remoteclip for RemoteCLIP features.

WeiCom

To evaluate extracted features on PatternCom RSCIR using WeiCom, run:

python evaluate.py --model_name clip --dataset_path /path/to/PatternNet/ --methods "Weighted Similarities Norm" --lambdas 0.5

Replace clip with remoteclip for RemoteCLIP features.

Following our ablation, you can use optimal --lambdas 0.3 for CLIP, --lambdas 0.6 for RemoteCLIP.

Results

Running the code as described above, you should get the following results. In these tables, for each attribute value of an attribute (e.g. "rectangular" of Shape), the average mAP over all the rest attribute values (e.g. "oval" of Shape) is shown. Avg represents the average mAP over all combinations.

CLIP

MethodColorContextDensityExistenceQuantityShapeAvg
Text13.474.833.582.003.316.225.57
Image14.668.3213.4916.477.8415.7612.74
Text & Image23.1311.0215.8716.9310.1321.3816.41
$WeiCom_{\lambda=0.5}$46.0817.4516.498.3618.1523.9721.75
$WeiCom_{\lambda=0.3}$46.7420.9722.0713.2220.9626.2225.03

RemoteCLIP

MethodColorContextDensityExistenceQuantityShapeAvg
Text10.758.8722.166.988.2524.1213.52
Image14.406.6215.1113.106.9915.1811.90
Text & Image23.6710.0118.4513.987.9719.6315.62
$WeiCom_{\lambda=0.5}$43.6831.4539.9414.9220.5129.7830.05
$WeiCom_{\lambda=0.6}$41.0431.5941.5614.5620.7931.2430.13

Acknowledgement

NTUA thanks NVIDIA for the support with the donation of GPU hardware.

License

This repository is released under the Apache 2.0 license as found in the LICENSE file.

Citation

If you find this repository useful, please consider giving a star 🌟 and citation:

@inproceedings{psomas2024composed,
      title={Composed Image Retrieval for Remote Sensing}, 
      author={Psomas, B. and Kakogeorgiou, I. and Efthymiadis, N. and Tolias, G. and Chum, O. and Avrithis, Y. and Karantzalos, K.},
      booktitle={IGARSS 2024 - 2024 IEEE International Geoscience and Remote Sensing Symposium}, 
      year={2024}
}