torchgeo_bench.utils#

General-purpose helpers shared across the framework.

torchgeo_bench.utils.extract_features(model, dataloader, device, transforms=None, verbose=True)[source][source]#

Extract feature embeddings and labels from a dataloader.

Parameters:
  • model (Module) – Model to use for feature extraction.

  • dataloader (DataLoader) – DataLoader yielding dicts with "image" and "label" keys.

  • device (str | device) – Device to run inference on.

  • transforms (object | None) – Optional transform applied to images before the model.

  • verbose (bool) – Whether to display a progress bar.

Returns:

Tuple of (features, labels) as NumPy arrays.

Return type:

tuple[ndarray, ndarray]