diart.features#

Module Contents#

Classes#

TemporalFeatureFormatterState

Represents the recorded type of a temporal feature formatter.

SlidingWindowFeatureFormatterState

Represents the recorded type of a temporal feature formatter.

NumpyArrayFormatterState

Represents the recorded type of a temporal feature formatter.

PytorchTensorFormatterState

Represents the recorded type of a temporal feature formatter.

TemporalFeatureFormatter

Manages the typing and format of temporal features.

Attributes#

diart.features.TemporalFeatures#
class diart.features.TemporalFeatureFormatterState#

Bases: abc.ABC

Represents the recorded type of a temporal feature formatter. Its job is to transform temporal features into tensors and recover the original format on other features.

abstract to_tensor(features)#
Parameters:

features (TemporalFeatures) –

Return type:

torch.Tensor

abstract to_internal_type(features)#

Cast features to the representing type and remove batch dimension if required.

Parameters:

features (torch.Tensor, shape (batch, frames, dim)) – Batched temporal features.

Returns:

new_features

Return type:

SlidingWindowFeature or numpy.ndarray or torch.Tensor, shape (batch, frames, dim)

class diart.features.SlidingWindowFeatureFormatterState(duration)#

Bases: TemporalFeatureFormatterState

Represents the recorded type of a temporal feature formatter. Its job is to transform temporal features into tensors and recover the original format on other features.

Parameters:

duration (float) –

to_tensor(features)#
Parameters:

features (pyannote.core.SlidingWindowFeature) –

Return type:

torch.Tensor

to_internal_type(features)#

Cast features to the representing type and remove batch dimension if required.

Parameters:

features (torch.Tensor, shape (batch, frames, dim)) – Batched temporal features.

Returns:

new_features

Return type:

SlidingWindowFeature or numpy.ndarray or torch.Tensor, shape (batch, frames, dim)

class diart.features.NumpyArrayFormatterState#

Bases: TemporalFeatureFormatterState

Represents the recorded type of a temporal feature formatter. Its job is to transform temporal features into tensors and recover the original format on other features.

to_tensor(features)#
Parameters:

features (numpy.ndarray) –

Return type:

torch.Tensor

to_internal_type(features)#

Cast features to the representing type and remove batch dimension if required.

Parameters:

features (torch.Tensor, shape (batch, frames, dim)) – Batched temporal features.

Returns:

new_features

Return type:

SlidingWindowFeature or numpy.ndarray or torch.Tensor, shape (batch, frames, dim)

class diart.features.PytorchTensorFormatterState#

Bases: TemporalFeatureFormatterState

Represents the recorded type of a temporal feature formatter. Its job is to transform temporal features into tensors and recover the original format on other features.

to_tensor(features)#
Parameters:

features (torch.Tensor) –

Return type:

torch.Tensor

to_internal_type(features)#

Cast features to the representing type and remove batch dimension if required.

Parameters:

features (torch.Tensor, shape (batch, frames, dim)) – Batched temporal features.

Returns:

new_features

Return type:

SlidingWindowFeature or numpy.ndarray or torch.Tensor, shape (batch, frames, dim)

class diart.features.TemporalFeatureFormatter#

Manages the typing and format of temporal features. When casting temporal features as torch.Tensor, it remembers its type and format so it can lately restore it on other temporal features.

set_state(features)#
Parameters:

features (TemporalFeatures) –

cast(features)#

Transform features into a torch.Tensor and add batch dimension if missing.

Parameters:

features (SlidingWindowFeature or numpy.ndarray or torch.Tensor) – Shape (frames, dim) or (batch, frames, dim)

Returns:

features

Return type:

torch.Tensor, shape (batch, frames, dim)

restore_type(features)#

Cast features to the internal type and remove batch dimension if required.

Parameters:

features (torch.Tensor, shape (batch, frames, dim)) – Batched temporal features.

Returns:

new_features

Return type:

SlidingWindowFeature or numpy.ndarray or torch.Tensor, shape (batch, frames, dim)