Home

Awesome

A Prior Instruction Representation Framework for Remote Sensing Image-text Retrieval (MM'23 Oral)

By Jiancheng Pan, Qing Ma, Cong Bai.

This repo is the official implementation of "A Prior Instruction Representation Framework for Remote Sensing Image-text Retrieval"(MM'23 Oral).

PWC PWC

ā„¹ļø Introduction

This paper presents a prior instruction representation framework (PIR) for remote sensing image-text retrieval, aimed at remote sensing vision-language understanding tasks to solve the semantic noise problem. Our highlight is the proposal of a paradigm that draws on prior knowledge to instruct adaptive learning of vision and text representations. Concretely, two progressive attention encoder (PAE) structures, Spatial-PAE and Temporal-PAE, are proposed to perform long-range dependency modeling to enhance key feature representation. In vision representation, Vision Instruction Representation (VIR) based on Spatial-PAE exploits the prior-guided knowledge of the remote sensing scene recognition by building a belief matrix to select key features for reducing the impact of semantic noise. In text representation, Language Cycle Attention (LCA) based on Temporal-PAE uses the previous time step to cyclically activate the current time step to enhance text representation capability. A cluster-wise affiliation loss is proposed to constrain the inter-classes and to reduce the semantic confusion zones in the common subspace. Comprehensive experiments demonstrate that using prior knowledge instruction could enhance vision and text representations and could outperform the state-of-the-art methods on two benchmark datasets, RSICD and RSITMD.

pipline

šŸŽÆ Implementation

Project Files

The directory hierarchy is shown below, where the checkpoints and data files can be downloaded from here [Baidu Disk] .

.
ā”œā”€ā”€ checkpoints
ā”‚Ā Ā  ā””ā”€ā”€ PIR
ā”‚Ā Ā      ā”œā”€ā”€ full_rsicd
ā”‚Ā Ā      ā”‚Ā Ā  ā”œā”€ā”€ checkpoint_49.pth
ā”‚Ā Ā      ā”‚Ā Ā  ā”œā”€ā”€ checkpoint_best.pth
ā”‚Ā Ā      ā”‚Ā Ā  ā”œā”€ā”€ config.yaml
ā”‚Ā Ā      ā”‚Ā Ā  ā””ā”€ā”€ log.txt
ā”‚Ā Ā      ā””ā”€ā”€ full_rsitmd
ā”‚Ā Ā          ā”œā”€ā”€ checkpoint_49.pth
ā”‚Ā Ā          ā”œā”€ā”€ checkpoint_best.pth
ā”‚Ā Ā          ā”œā”€ā”€ config.yaml
ā”‚Ā Ā          ā””ā”€ā”€ log.txt
ā”œā”€ā”€ configs
ā”‚Ā Ā  ā”œā”€ā”€ config_bert.json
ā”‚Ā Ā  ā”œā”€ā”€ config_swinT_224.json
ā”‚Ā Ā  ā”œā”€ā”€ Retrieval_rsicd.yaml
ā”‚Ā Ā  ā””ā”€ā”€ Retrieval_rsitmd.yaml
ā”œā”€ā”€ data
ā”œā”€ā”€ dataset
ā”œā”€ā”€ models
ā”œā”€ā”€ utils
ā”œā”€ā”€ mytools.py
ā”œā”€ā”€ optim.py
ā”œā”€ā”€ Pretrain.py
ā”œā”€ā”€ Retrieval.py
ā”œā”€ā”€ run.py
ā”œā”€ā”€ scheduler.py
ā””ā”€ā”€ requirements.txt

Environments

pip install -r requirements.txt

Train

If you encounter environmental problems, you can directly modify the get_dist_launch function of run.py, for example:(2 card GPU)

elif args.dist == 'f2':
    return "CUDA_VISIBLE_DEVICES=0,1 WORLD_SIZE=2 /home/pjc/.conda/envs/xlvm/bin/python -W ignore -m torch.distributed.launch --master_port 9999 --nproc_per_node=2 " \
            "--nnodes=1 "

For training, run cmd as follow:

python run.py --task 'itr_rsitmd' --dist "f2" --config 'configs/Retrieval_rsitmd.yaml' --output_dir './checkpoints/PIR/full_rsitmd'

python run.py --task 'itr_rsicd' --dist "f2" --config 'configs/Retrieval_rsicd.yaml' --output_dir './checkpoints/PIR/full_rsicd'

Test

python run.py --task 'itr_rsitmd' --dist "f2" --config 'configs/Retrieval_rsitmd.yaml' --output_dir './checkpoints/PIR/test' --checkpoint './checkpoints/PIR/full_rsitmd/checkpoint_best.pth' --evaluate

python run.py --task 'itr_rsicd' --dist "f2" --config 'configs/Retrieval_rsicd.yaml' --output_dir './checkpoints/PIR/test' --checkpoint './checkpoints/PIR/full_rsicd/checkpoint_best.pth' --evaluate

šŸŒŽ Datasets

All experiments are based on RSITMD and RSICD datasets.

you also can download the images form Baidu Desk, and correspondingly modify the yaml file under configs files as follows: image_root: './images/datasets_name/'

šŸ“Š Results

image-20230814214836481

šŸ™ Acknowledgement

šŸ“ Citation

If you find this code useful for your work or use it in your project, please cite our paper as:

@inproceedings{pan2023prior,
  title={A Prior Instruction Representation Framework for Remote Sensing Image-text Retrieval},
  author={Pan, Jiancheng and Ma, Qing and Bai, Cong},
  booktitle={Proceedings of the 31st ACM International Conference on Multimedia},
  pages={611--620},
  year={2023}
}