plismbench.models.extractor module#

Core abstract method for feature extractors.

class plismbench.models.extractor.Extractor(*args, **kwargs)[source]#

Bases: ABC

A base class for plismbench extractors.

property feature_extractor: Module#

Feature extractor module.

Returns:

feature_extractor

Return type:

torch.nn.Module

property transform: Callable[[ndarray], Tensor]#

Transform method to apply element wise. Inputs should be numpy.ndarray.

This function is applied on numpy.ndarray and not PIL.Image.Image as HuggingFace data is stored as numpy arrays for pickle checking purposes. If your model needs image resizing, then you will need to add a first transforms.ToPILImage() operation, then resizing and finally transforms.ToTensor(). If your model is best working on images of shape 224x224, then no need for rescaling as PLISM tiles have 224x224 shapes.

Default is identity.

Returns:

transform

Return type:

collections.abc.Callable[[numpy.ndarray], torch.Tensor]