Загрузка
Cityscapes Dataset.
root (str or pathlib.Path) – Root directory of dataset where directory leftImg8bit
and gtFine or gtCoarse are located.
split (string, optional) – The image split to use, train, test or val if mode=”fine”
otherwise train, train_extra or val
mode (string, optional) – The quality mode to use, fine or coarse
target_type (string or list, optional) – Type of target to use, instance, semantic, polygon
or color. Can also be a list to output a tuple with all specified target types.
transform (callable, optional) – A function/transform that takes in a PIL image
and returns a transformed version. E.g, transforms.RandomCrop
target_transform (callable, optional) – A function/transform that takes in the target and transforms it.
transforms (callable, optional) – A function/transform that takes input sample and its target as entry and returns a transformed version.
Get semantic segmentation target
dataset = Cityscapes('./data/cityscapes', split='train', mode='fine',
target_type='semantic')
img, smnt = dataset[0]
Get multiple targets
dataset = Cityscapes('./data/cityscapes', split='train', mode='fine',
target_type=['instance', 'color', 'polygon'])
img, (inst, col, poly) = dataset[0]
Validate on the “coarse” set
dataset = Cityscapes('./data/cityscapes', split='val', mode='coarse',
target_type='semantic')
img, smnt = dataset[0]
(image, target) where target is a tuple of all target types if target_type is a list with more than one item. Otherwise, target is a json object if target_type=”polygon”, else the image segmentation.