mindspore.dataset.Dataset.get_class_indexing

View Source On Gitee
Dataset.get_class_indexing()[source]

Get the mapping dictionary from category names to category indexes.

This dictionary can be used to look up which category name corresponds to a particular category index.

Returns

Dict[str, int], the mappings from category names to category indexes.

Examples

>>> import mindspore.dataset as ds
>>> # Read image files
>>> image_folder_dataset_dir = "/path/to/image_folder_dataset_directory"
>>> dataset = ds.ImageFolderDataset(dataset_dir=image_folder_dataset_dir)
>>> # Check how many classes exist in image folder
>>> class_indexing = dataset.get_class_indexing()