mindformers.AutoProcessor¶
-
class
mindformers.AutoProcessor[源代码]¶ helps instantiates a processor by yaml model name or path. If using a model name, the config yaml will be downloaded from obs to ./checkpoint_download dir
实际案例
>>> from mindformers.auto_class import AutoProcessor >>> >>> # 1) instantiates a processor by yaml model name >>> pro_a = AutoProcessor.from_pretrained('clip_vit_b_32') >>> # 2) instantiates a processor by yaml model path >>> from mindformers.mindformer_book import MindFormerBook >>> config_path = os.path.join(MindFormerBook.get_project_path(), ... 'configs', 'clip', 'run_clip_vit_b_32_pretrain_flickr8k.yaml') >>> pro_b = AutoProcessor.from_pretrained(config_path)
-
classmethod
from_pretrained(yaml_name_or_path, **kwargs)[源代码]¶ From pretrain method, which instantiated a processor by yaml name or path.
- 参数
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.
- 返回
A processor which inherited from BaseProcessor.
-
classmethod