egrecho.pipeline.base#
- 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 modelfeature_extractor (
Optional
[BaseFeature
]) -- extractortokenizer (
Optional
[Callable
]) -- tokenizerdevice (
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