mindformers.dataset.ZeroShotImageClassificationDataset¶
-
class
mindformers.dataset.ZeroShotImageClassificationDataset(dataset_config: dict = None)[源代码]¶ Zero Shot Image Classification Dataset API. output image, text, and label columns
- 参数
dataset_config (dict) – Config for dataset.
- 返回
A dataset for ZeroShotImageClassificationTrainer.
实际案例
>>> import os >>> from mindformers import MindFormerBook, MindFormerConfig, build_dataset >>> project_path = MindFormerBook.get_project_path() >>> config_path = os.path.join(project_path, "configs", "clip", >>> "run_clip_vit_b_32_zero_shot_image_classification_cifar100.yaml") >>> config = MindFormerConfig(config_path) Note: Put cifar100 dataset to ./ The detailed data setting could refer to ./configs/clip/clip.md >>> config.eval_dataset_task.dataset_config.batch_size = 1 >>> dataset = build_dataset(config.eval_dataset_task) >>> for item in dataset: >>> print(item) >>> break [Tensor(shape=[1, 3, 224, 224], dtype=Float32, value= [[[[1.11282456e+000, 1.11282456e+000, ... 1.47778523e+000, 1.47778523e+000], [1.11282456e+000, 1.11282456e+000, ... 1.47778523e+000, 1.47778523e+000], [1.11282456e+000, 1.11282456e+000, ... 1.47778523e+000, 1.47778523e+000], ... [1.97748125e-001, 1.97748125e-001, ... 1.12205243e+000, 1.12205243e+000], [1.97748125e-001, 1.97748125e-001, ... 1.12205243e+000, 1.12205243e+000], [1.97748125e-001, 1.97748125e-001, ... 1.12205243e+000, 1.12205243e+000]]]]), Tensor(shape=[1, 100, 77], dtype=Int32, value= [[[49406, 320, 1674 ... 0, 0, 0], [49406, 320, 1674 ... 0, 0, 0], [49406, 320, 1674 ... 0, 0, 0], ... [49406, 320, 1674 ... 0, 0, 0], [49406, 320, 1674 ... 0, 0, 0], [49406, 320, 1674 ... 0, 0, 0]]]), Tensor(shape=[1], dtype=Int32, value= [49])]