ocl.feature_extractors.utils
Utility functions used for feature extractors.
FeatureExtractor
Abstract base class for Feature Extractors.
We expect that the forward method returns a flattened representation of the features, to make outputs consistent and not dependent on equal spacing or the dimensionality of the spatial information.
Source code in ocl/feature_extractors/utils.py
ImageFeatureExtractor
Bases: FeatureExtractor
Base class that allows operation of image based feature extractors on videos.
This is implemented by reshaping the frame dimesion into the batch dimension and inversing the process after extraction of the features.
Subclasses override the forward_images
method.
Source code in ocl/feature_extractors/utils.py
forward_images
abstractmethod
Apply feature extractor to image tensor.
Returns:
Type | Description |
---|---|
Union[Tuple[ocl.typing.ImageFeatures, ocl.typing.Positions], Tuple[ocl.typing.ImageFeatures, ocl.typing.Positions, Dict]]
|
|
Union[Tuple[ocl.typing.ImageFeatures, ocl.typing.Positions], Tuple[ocl.typing.ImageFeatures, ocl.typing.Positions, Dict]]
|
|
Union[Tuple[ocl.typing.ImageFeatures, ocl.typing.Positions], Tuple[ocl.typing.ImageFeatures, ocl.typing.Positions, Dict]]
|
|
Source code in ocl/feature_extractors/utils.py
forward
Apply subclass image feature extractor to potential video data.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
video |
ocl.typing.ImageOrVideoData
|
5D tensor for video data or 4D tensor for image data. |
required |
Returns:
Type | Description |
---|---|
ocl.typing.FeatureExtractorOutput
|
ocl.typing.FeatureExtractorOutput: The extracted features with positiional information and potential auxilliary features. |
Source code in ocl/feature_extractors/utils.py
cnn_compute_positions_and_flatten
Flatten CNN features to remove spatial dims and return them with correspoding positions.
Source code in ocl/feature_extractors/utils.py
transformer_compute_positions
Compute positions for Transformer features.