Update README.md
Browse files
README.md
CHANGED
|
@@ -1,6 +1,72 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
| 4 |
|
| 5 |
|
| 6 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
## GeoRSCLIP Model
|
| 2 |
+
* **GeoRSCLIP with ViT-B-32 and ViT-H-14 backbone**
|
| 3 |
+
* **GeoRSCLIP-FT for retrieval**
|
| 4 |
|
| 5 |
|
| 6 |
+
### Installation
|
| 7 |
+
|
| 8 |
+
* Install Pytorch following instructions from the official website (We tested in torch 2.0.1 with CUDA 11.8 and 2.1.0 with CUDA 12.1)
|
| 9 |
+
|
| 10 |
+
```bash
|
| 11 |
+
pip install torch==2.0.1 torchvision==0.15.2 torchaudio==2.0.2 --index-url https://download.pytorch.org/whl/cu118
|
| 12 |
+
```
|
| 13 |
+
|
| 14 |
+
* Install other dependencies
|
| 15 |
+
|
| 16 |
+
```bash
|
| 17 |
+
pip install pillow pandas scikit-learn ftfy tqdm matplotlib transformers adapter-transformers open_clip_torch pycocotools timm clip-benchmark torch-rs
|
| 18 |
+
```
|
| 19 |
+
|
| 20 |
+
### Usage
|
| 21 |
+
|
| 22 |
+
* Clone the repo from: https://huggingface.co/Zilun/GeoRSCLIP
|
| 23 |
+
|
| 24 |
+
```bash
|
| 25 |
+
git clone https://huggingface.co/Zilun/GeoRSCLIP
|
| 26 |
+
cd GeoRSCLIP
|
| 27 |
+
```
|
| 28 |
+
|
| 29 |
+
* Unzip the test data
|
| 30 |
+
```bash
|
| 31 |
+
unzip data/rs5m_test_data.zip
|
| 32 |
+
```
|
| 33 |
+
|
| 34 |
+
* Run the inference script:
|
| 35 |
+
```bash
|
| 36 |
+
python codebase/inference.py --ckpt-path /your/local/path/to/RS5M_ViT-B-32.pt --test-dataset-dir /your/local/path/to/rs5m_test_data
|
| 37 |
+
```
|
| 38 |
+
|
| 39 |
+
* (Optional) If you just want to load the GeoRSCLIP model:
|
| 40 |
+
|
| 41 |
+
```python
|
| 42 |
+
|
| 43 |
+
import open_clip
|
| 44 |
+
import torch
|
| 45 |
+
from inference_tool import get_preprocess
|
| 46 |
+
|
| 47 |
+
|
| 48 |
+
ckpt_path = "/your/local/path/to/RS5M_ViT-B-32.pt"
|
| 49 |
+
model, _, _ = open_clip.create_model_and_transforms("ViT-B/32", pretrained="openai")
|
| 50 |
+
checkpoint = torch.load(ckpt_path, map_location="cpu")
|
| 51 |
+
msg = model.load_state_dict(checkpoint, strict=False)
|
| 52 |
+
model = model.to("cuda")
|
| 53 |
+
img_preprocess = get_preprocess(
|
| 54 |
+
image_resolution=224,
|
| 55 |
+
)
|
| 56 |
+
```
|
| 57 |
+
|
| 58 |
+
```python
|
| 59 |
+
|
| 60 |
+
import open_clip
|
| 61 |
+
import torch
|
| 62 |
+
from inference_tool import get_preprocess
|
| 63 |
+
|
| 64 |
+
ckpt_path = "/your/local/path/to/RS5M_ViT-H-14.pt"
|
| 65 |
+
model, _, _ = open_clip.create_model_and_transforms("ViT-H/14", pretrained="laion2b_s32b_b79k")
|
| 66 |
+
checkpoint = torch.load(ckpt_path, map_location="cpu")
|
| 67 |
+
msg = model.load_state_dict(checkpoint, strict=False)
|
| 68 |
+
model = model.to("cuda")
|
| 69 |
+
img_preprocess = get_preprocess(
|
| 70 |
+
image_resolution=224,
|
| 71 |
+
)
|
| 72 |
+
```
|