mindformers.pipeline.BasePipeline¶
- class mindformers.pipeline.BasePipeline(model: Union[str, BaseModel, Model], tokenizer: Optional[BaseTokenizer] = None, image_processor: Optional[BaseImageProcessor] = None, **kwargs)[源代码]¶
Base Pipeline For All Task Pipelines
- Args:
- model (Union[str, BaseModel]): The model used to perform task,
the input could be a supported model name, or a model instance inherited from BaseModel.
- tokenizer (Optional[BaseTokenizer]): The tokenizer of model, it could be
None if the model do not need tokenizer.
- image_processor (Optional[BaseImageProcessor]): The image_processor of model,
it could be None if the model do not need image_processor.
- abstract forward(model_inputs: Union[dict, str, array, Tensor], **forward_params)[源代码]¶
The Forward Process of Model
- Args:
- model_inputs (Union[dict, str, etc]): The output of preprocess,
the type of model_inputs depends on task.
forward_params (dict): The parameter dict for model forward.
- Raises:
NotImplementedError: If the method is not implemented.
- abstract postprocess(model_outputs: Union[dict, str, array, Tensor], **postprocess_params)[源代码]¶
The Postprocess of Task
- Args:
- model_outputs (Union[dict, str, etc]): The output of model forward,
the type of model_outputs depends on task.
postprocess_params (dict): The parameter dict for post process.
- Raises:
NotImplementedError: If the method is not implemented.
- abstract preprocess(inputs: Union[dict, str, array, Tensor], **preprocess_params)[源代码]¶
The Preprocess For Task
- Args:
- inputs (Union[dict, str, etc]): The inputs of pipeline,
the type of inputs depends on task.
preprocess_params (dict): The parameter dict for preprocess.
- Raises:
NotImplementedError: If the method is not implemented.
- run_multi(inputs: Union[list, tuple], preprocess_params: dict, forward_params: dict, postprocess_params: dict)[源代码]¶
Run Multiple Method This function is used to run a list input for task.
- Args:
inputs (Union[list, tuple, iterator]): The iterable input for pipeline. preprocess_params (dict): The parameter dict for preprocess. forward_params (dict): The parameter dict for model forward process. postprocess_params (dict): The parameter dict for postprocess.
- run_single(inputs: Union[dict, str, array, Tensor], preprocess_params: dict, forward_params: dict, postprocess_params: dict)[源代码]¶
Run Single method This function is used to run a single forward process for task.
- Args:
- inputs (Union[dict, str, etc]): The inputs of pipeline,
the type of inputs depends on task.
preprocess_params (dict): The parameter dict for preprocess. forward_params (dict): The parameter dict for model forward process. postprocess_params (dict): The parameter dict for postprocess.