mindformers.models.BaseProcessor

class mindformers.models.BaseProcessor(**kwargs)[源代码]

Base processor

Examples:
>>> from mindformers.mindformer_book import MindFormerBook
>>> from mindformers.models.base_processor import BaseProcessor
>>> class MyProcessor(BaseProcessor):
...     _support_list = MindFormerBook.get_processor_support_list()['my_model']
...
...     def __init__(self, image_processor=None, audio_processor=None, tokenizer=None, return_tensors='ms'):
...         super(MyProcessor, self).__init__(
...             image_processor=image_processor,
...             audio_processor=audio_processor,
...             tokenizer=tokenizer,
...             return_tensors=return_tensors)
...
>>> myprocessor = MyProcessor(image_processor, audio_processor, tokenizer)
>>> output = mynet(image, audio, text)
classmethod from_pretrained(yaml_name_or_path, **kwargs)[源代码]

From pretrain method, which instantiates a processor by yaml name or path.

Args:
yaml_name_or_path (str): A supported yaml name or a path to .yaml file,

the supported model name could be selected from .show_support_list(). If yaml_name_or_path is model name, it supports model names beginning with mindspore or the model name itself, such as “mindspore/vit_base_p16” or “vit_base_p16”.

pretrained_model_name_or_path (Optional[str]): Equal to “yaml_name_or_path”,

if “pretrained_model_name_or_path” is set, “yaml_name_or_path” is useless.

Returns:

A processor which inherited from BaseProcessor.

classmethod get_support_list()[源代码]

get_support_list method

save_pretrained(save_directory=None, save_name='mindspore_model')[源代码]

Save_pretrained.

Args:

save_directory (str): a directory to save config yaml save_name (str): the name of save files.

classmethod show_support_list()[源代码]