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.
1from single_file_galileo import Encoder as SingleFileEncoder
2from src.galileo import Encoder
3
4
5src_model = Encoder.load_from_folder(DATA_FOLDER / "models/nano")
6sf_model = SingleFileEncoder.load_from_folder(
7 DATA_FOLDER / "models/nano", device=torch.device("cpu")
8)
9
10for model_p, sf_model_p in zip(src_model.parameters(), sf_model.parameters()):
11 assert torch.equal(model_p, sf_model_p)
The inputs to Galileo are described in the
MaskedOutput:
1class MaskedOutput(NamedTuple):
2 """
3 A mask can take 3 values:
4 0: seen by the encoder (i.e. makes the key and value tokens in the decoder)
5 1: not seen by the encoder, and ignored by the decoder
6 2: not seen by the encoder, and processed by the decoder (the decoder's query values)
7 """
8
9 space_time_x: torch.Tensor # [B, H, W, T, len(SPACE_TIME_BANDS)]
10 space_x: torch.Tensor # [B, H, W, len(SPACE_BANDS)]
11 time_x: torch.Tensor # [B, T, len(TIME_BANDS)]
12 static_x: torch.Tensor # [B, len(STATIC_BANDS)]
13 space_time_mask: torch.Tensor # [B, H, W, T, len(SPACE_TIME_BANDS_GROUPS_IDX)]
14 space_mask: torch.Tensor # [B, H, W, len(SPACE_BAND_GROUPS_IDX)]
15 time_mask: torch.Tensor # [B, T, len(TIME_BAND_GROUPS_IDX)]
16 static_mask: torch.Tensor # [B, len(STATIC_BAND_GROUPS_IDX)]
17 months: torch.Tensor # [B, T]
Each of these bands are described in
single_file_galileo.py.
Alternatively, a
utility function 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.
1from src.data.utils import S2_BANDS, construct_galileo_input
2
3t, h, w = 2, 4, 4
4s2 = torch.randn((t, h, w, len(S2_BANDS)))
5masked_output = construct_galileo_input(s2=s2, normalize=normalize)