egrecho.pipeline.base#

class egrecho.pipeline.base.DeviceMode(value)[source]#

Bases: StrEnum

An enumeration.

class egrecho.pipeline.base.PipeLine(model, feature_extractor=None, tokenizer=None, device=None, **kwargs)[source]#

Bases: ABC

Base class for other pipelines, where defines the common pipeline logics here.

Pipeline workflow is defined as a sequence of the following operations:

Input -> Pre-Processing -> Model Inference -> Post-Processing -> Output

Parameters:
  • model (TopVirtualModel) -- inputs model

  • feature_extractor (Optional[BaseFeature]) -- extractor

  • tokenizer (Optional[Callable]) -- tokenizer

  • device (Union[str, int, device, DeviceMode, None]) -- specified device

Note

This class follows the structure of the Hugging Face Pipeline.

abstract preprocess(input, **preprocess_params)[source]#

[Abstract] Take care of input and preprocess it to a dict which will be fed to model.

Return type:

Dict[str, Tensor]

abstract postprocess(model_outputs, **postprocess_params)[source]#

[Abstract] Recive dict contains tensor from _forward() and results the final form.

Return type:

Any

forward(model_inputs, **forward_params)[source]#

Before forward: Set inference mode and move inputs to desired device. After forward: move model output to cpu.

to(device)[source]#

Send pipeline to device

egrecho.pipeline.speaker_embedding#