COSIE.image_preprocessing.extract_features

extract_features(model, batch)[source]

Extracts both global and local visual features from an input image batch using a pretrained model.

Return type:

Tuple[Tensor, Tensor]

Parameters

modeltorch.nn.Module

A pretrained vision transformer model with a method forward_intermediates() that allows access to token-level outputs.

batchtorch.Tensor

A batch of input images.

Returns

feature_embtorch.Tensor

The final global feature embedding.

patch_embtorch.Tensor

The final local feature embedding.