I am trying semantic segmentation on cityscapes dataset based on lesson-3 knowledge.
In camVid dataset there is only one class called ‘Void’ which should be ignored while calculating accuracy. But in cityscapes dataset, there are multiple classes to be ignored.
classes=['unlabeled', 'ego vehicle', 'rectification border', 'out of roi', 'static', 'dynamic', 'ground', 'road', 'sidewalk', 'parking', 'rail track', 'building', 'wall', 'fence', 'guard rail', 'bridge', 'tunnel', 'pole', 'polegroup', 'traffic light', 'traffic sign', 'vegetation', 'terrain', 'sky', 'person', 'rider', 'car', 'truck', 'bus', 'caravan', 'trailer', 'train', 'motorcycle', 'bicycle', 'license plate']
classes_to_ignore=['unlabeled', 'ego vehicle', 'rectification border', 'out of roi', 'static', 'dynamic', 'ground','polegroup', 'license plate']
I tried defining accuracy matrices like this-
name2id = {v:k for k,v in enumerate(classes)}
unlabeled = name2id['unlabeled']
ego_v = name2id['ego vehicle']
rectification = name2id['rectification border']
roi = name2id['out of roi']
static = name2id['static']
dynamic = name2id['dynamic']
ground = name2id['ground']
def acc_cityscapes(input, target):
target = target.squeeze(1)
mask = (target!=unlabeled and target!= ego_v and target!= rectification and target!=roi and target !=static and target!=dynamic and target!=ground)
return (input.argmax(dim=1)[mask]==target[mask]).float().mean()
But getting this error
How can I define accuracy ignoring those unwanted classes?