File size: 7,230 Bytes
7002f4e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
---
frameworks: PyTorch
language:
- en
license: apache-2.0
tags:
- OneScience
- Earth Science
- Remote Sensing
- Vision-Language Model
- Image-Text Retrieval
- RemoteCLIP
- arxiv:2306.11029
tasks: []
datasets:
- RSITMD
- RSICD
- UCM-Captions
---
<p align="center">
  <strong>
    <span style="font-size: 30px;">RemoteCLIP</span>
  </strong>
</p>

# Model Introduction

RemoteCLIP is a vision-language foundation model for remote sensing. It learns semantically rich visual representations by aligning remote sensing images with text descriptions and supports image-text retrieval, zero-shot classification, few-shot classification, linear probing, k-NN classification, and remote sensing object counting.

Paper: RemoteCLIP: A Vision Language Foundation Model for Remote Sensing

https://arxiv.org/abs/2306.11029

# Model Description

RemoteCLIP was proposed by researchers from Hohai University, the Hong Kong University of Science and Technology, Nanjing Forestry University, the Chinese Academy of Forestry, and Griffith University. It is continually pretrained on RSITMD, RSICD, UCM-Captions, and remote sensing detection, segmentation, and UAV imagery converted into image-text pairs through B2C and M2B, and is suitable for remote sensing image-text retrieval and open-vocabulary recognition.

# Use Cases

| Scenario | Description |
| :---: | :--- |
| Remote sensing image-text contrastive training | Train RemoteCLIP with paired remote sensing images and text descriptions. |
| Remote sensing image-text retrieval | Retrieve text from images or remote sensing images from text queries. |
| Local quick validation | Use synthetic image-text pairs to validate training, inference, evaluation, and visualization. |
| Hugging Face / OneCode execution | Download the standalone model package, install dependencies, and run the scripts directly. |
| Multi-GPU training | Launch distributed multi-process training with `torchrun`. |

# Usage Guide

## 1. OneCode Usage

Experience intelligent one-click AI4S programming through the OneCode online environment:

[Click to Experience Intelligent One-Click AI4S Programming](https://web-2069360198568017922-iaaj.ksai.scnet.cn:58043/home)

## 2. Manual Installation and Usage

**Hardware Requirements**

- A GPU or DCU is recommended.
- CPU can be used for import and small-scale connectivity verification; full training and inference will be slow.
- DCU users must install DTK in advance. DTK 25.04.2 or above, or the OneScience recommended version matching the cluster, is recommended.

### Download the Model Package

```bash
hf download OneScience-Group/RemoteCLIP --local-dir ./RemoteCLIP
cd RemoteCLIP
```

### Install the Runtime Environment

**DCU Environment**

```bash
# Please activate DTK and CONDA first
conda create -n onescience311 python=3.11 -y
conda activate onescience311
# uv installation is supported
pip install onescience[earth-dcu] -i http://mirrors.onescience.ai:3141/pypi/simple/ --trusted-host mirrors.onescience.ai
```

**GPU Environment**

```bash
# Please activate CONDA first
conda create -n onescience311 python=3.11 -y libstdcxx-ng=12 libgcc-ng=12 gcc_linux-64=12 gxx_linux-64=12
conda activate onescience311
# uv installation is supported
pip install onescience[earth-gpu] -i http://mirrors.onescience.ai:3141/pypi/simple/ --trusted-host mirrors.onescience.ai
```

### Training Data Introduction

The paper unifies three groups of heterogeneous remote sensing datasets into paired image-text data. RET-3 contains RSITMD, RSICD, and UCM-Captions; DET-10 contains satellite and UAV object detection datasets; SEG-4 contains the iSAID, LoveDA, Potsdam, and Vaihingen semantic segmentation datasets. Detection annotations are converted into descriptions through Box-to-Caption, while segmentation masks are converted to boxes through Mask-to-Box before caption generation. The resulting pretraining collection is approximately 12 times larger than the original remote sensing image-text datasets combined.

The paper datasets remain subject to their respective download and usage licenses. The authors' official code and model resources are available at:

```text
https://github.com/ChenDelong1999/RemoteCLIP
```

The complete paper pretraining dataset is not included in this model repository. Generate compact synthetic data for local validation with:

```bash
python scripts/fake_data.py
```

This command creates 32 training pairs and 8 test pairs in `data/remoteclip.npz`. Synthetic data only validates image and text encoding, bidirectional InfoNCE training, checkpoint loading, retrieval inference, evaluation, and similarity-matrix visualization. The complete synthetic pipeline has been verified successfully, but synthetic training values are not reported as model performance.

For real-data training, organize remote sensing images and text descriptions into paired samples following the paper or the official repository and convert them to `data/remoteclip.npz`. Do not run `scripts/fake_data.py` for real-data training. Set `data.protocol` in `conf/config.yaml` to `real_remoteclip` and update the image size, vocabulary size, context length, and training parameters for the converted dataset.

### Training

Generate synthetic data before local quick validation:

```bash
python scripts/fake_data.py
```

Single GPU or CPU:

```bash
python scripts/train.py
```

Multi-GPU:

```bash
torchrun --nproc_per_node=8 --nnodes=1 --rdzv_id=1000 --rdzv_backend=c10d --max_restarts=0 --master_addr="localhost" --master_port=29500 scripts/train.py
```

Training outputs:

```text
result/checkpoints/remoteclip.pt
result/training/metrics.json
```

### Training Weights

Pretrained weights based on paired remote sensing image-text data will be provided under `weight/`. The weight file will be uploaded in a future update. Checkpoints produced from synthetic data validate the pipeline only and do not provide real remote sensing image-text retrieval capability.

### Inference

```bash
python scripts/inference.py
```

Inference extracts image features, text features, and the cross-modal similarity matrix from the test pairs.

Prediction output:

```text
result/output/retrieval.npz
```

### Evaluation and Visualization

```bash
python scripts/result.py
```

Evaluation outputs:

```text
result/evaluation/metrics.json
result/evaluation/similarity_matrix.png
```

The evaluation script computes image-to-text and text-to-image R@1, R@5, and mean recall, and renders the image-text similarity matrix. Synthetic data is used only to confirm that evaluation and visualization outputs can be generated successfully; its numerical values are not reported as model performance.

# Official OneScience Resources

| Platform | OneScience Main Repository | Skills Repository |
| --- | --- | --- |
| Gitee | https://gitee.com/onescience-ai/onescience | https://gitee.com/onescience-ai/oneskills |
| GitHub | https://github.com/onescience-ai/OneScience | https://github.com/onescience-ai/oneskills |

# Citation and License

- This repository is a reproduction of the original RemoteCLIP paper.
- The reproduction code is released under Apache License 2.0. The original datasets and official model weights remain subject to their respective source licenses.