Update README.md
Browse files
README.md
CHANGED
|
@@ -1,3 +1,62 @@
|
|
| 1 |
-
---
|
| 2 |
-
license: mit
|
| 3 |
-
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: mit
|
| 3 |
+
---
|
| 4 |
+
# Galileo
|
| 5 |
+
|
| 6 |
+
Learning Global and Local Features in Pretrained Remote Sensing Models
|
| 7 |
+
|
| 8 |
+
<img src="diagrams/figure2.png" alt="Galileo_diagram" height="300px"/>
|
| 9 |
+
|
| 10 |
+
Galileo is a family of pretrained remote sensing models. These models have been pretrained on a diversity of remote sensing inputs, and perform well on a range of benchmark tasks. For more information, please see our paper.
|
| 11 |
+
|
| 12 |
+
### Using Galileo
|
| 13 |
+
|
| 14 |
+
Galileo can be loaded either from `src`, or from `single_file_galileo.py` for easy porting to other codebases:
|
| 15 |
+
|
| 16 |
+
```python
|
| 17 |
+
from single_file_galileo import Encoder as SingleFileEncoder
|
| 18 |
+
from src.galileo import Encoder
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
src_model = Encoder.load_from_folder(DATA_FOLDER / "models/nano")
|
| 22 |
+
sf_model = SingleFileEncoder.load_from_folder(
|
| 23 |
+
DATA_FOLDER / "models/nano", device=torch.device("cpu")
|
| 24 |
+
)
|
| 25 |
+
|
| 26 |
+
for model_p, sf_model_p in zip(src_model.parameters(), sf_model.parameters()):
|
| 27 |
+
assert torch.equal(model_p, sf_model_p)
|
| 28 |
+
```
|
| 29 |
+
|
| 30 |
+
The inputs to Galileo are described in the [`MaskedOutput`](src/masking.py#L116):
|
| 31 |
+
|
| 32 |
+
```python
|
| 33 |
+
class MaskedOutput(NamedTuple):
|
| 34 |
+
"""
|
| 35 |
+
A mask can take 3 values:
|
| 36 |
+
0: seen by the encoder (i.e. makes the key and value tokens in the decoder)
|
| 37 |
+
1: not seen by the encoder, and ignored by the decoder
|
| 38 |
+
2: not seen by the encoder, and processed by the decoder (the decoder's query values)
|
| 39 |
+
"""
|
| 40 |
+
|
| 41 |
+
space_time_x: torch.Tensor # [B, H, W, T, len(SPACE_TIME_BANDS)]
|
| 42 |
+
space_x: torch.Tensor # [B, H, W, len(SPACE_BANDS)]
|
| 43 |
+
time_x: torch.Tensor # [B, T, len(TIME_BANDS)]
|
| 44 |
+
static_x: torch.Tensor # [B, len(STATIC_BANDS)]
|
| 45 |
+
space_time_mask: torch.Tensor # [B, H, W, T, len(SPACE_TIME_BANDS_GROUPS_IDX)]
|
| 46 |
+
space_mask: torch.Tensor # [B, H, W, len(SPACE_BAND_GROUPS_IDX)]
|
| 47 |
+
time_mask: torch.Tensor # [B, T, len(TIME_BAND_GROUPS_IDX)]
|
| 48 |
+
static_mask: torch.Tensor # [B, len(STATIC_BAND_GROUPS_IDX)]
|
| 49 |
+
months: torch.Tensor # [B, T]
|
| 50 |
+
```
|
| 51 |
+
|
| 52 |
+
Each of these bands are described in [`single_file_galileo.py`](single_file_galileo.py#L24).
|
| 53 |
+
|
| 54 |
+
Alternatively, a [utility function](src/data/utils.py#L36) is provided to transform the bands into `MaskedOutput` objects. This transformation is for a single instance (i.e. it omits the `B` dimension above). This function optionally normalizes the data against the Galileo pre-training statistics.
|
| 55 |
+
|
| 56 |
+
```python
|
| 57 |
+
from src.data.utils import S2_BANDS, construct_galileo_input
|
| 58 |
+
|
| 59 |
+
t, h, w = 2, 4, 4
|
| 60 |
+
s2 = torch.randn((t, h, w, len(S2_BANDS)))
|
| 61 |
+
masked_output = construct_galileo_input(s2=s2, normalize=normalize)
|
| 62 |
+
```
|