-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
Input?
- Should we generate chips (tensors) of size (1, C, 224, 224) and then pass them to the model one by one, or should we stack them into a batch and pass the batches? If yes, should a batch include multitemporal data for one location, or can it contain data gathered from many places and times?
- or it's just the matter of how many tensors can be passed to used gpu?
in below example, IBM is passing 1 tensor of batch size equal to one per iteration.
# Load input data
examples = [
'38D_378R_2_3.tif',
'282D_485L_3_3.tif',
'433D_629L_3_1.tif',
'637U_59R_1_3.tif',
'609U_541L_3_0.tif',
]
# Select example between 0 and 4
file = examples[0]
# Define modalities
modalities = ['S2L2A', 'S1RTC', 'DEM', 'LULC', 'NDVI']
data = {m: rxr.open_rasterio(f'../examples/{m}/{file}') for m in modalities}
# Tensor with shape [B, C, 224, 224]
data = {
k: torch.Tensor(v.values, device='cpu').unsqueeze(0)
for k, v in data.items()
}
# Run any-to-any generation (this can take a while without a GPU, consider reducing timesteps for faster inference)
outputs = {}
for m in modalities:
print(f'Processing {m}')
out_modalities = modalities[:]
out_modalities.remove(m)
# Init model
model = FULL_MODEL_REGISTRY.build(
'terramind_v1_base_generate',
modalities=[m],
output_modalities=out_modalities,
pretrained=True,
standardize=True,
)
_ = model.to(device)
input = data[m].clone().to(device)
with torch.no_grad():
generated = model(input, verbose=True, timesteps=10)
outputs[m] = generatedReactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels