karolmajek/maxdeeplab
0
1# coding=utf-82# Copyright 2021 The Deeplab2 Authors.3#4# Licensed under the Apache License, Version 2.0 (the "License");5# you may not use this file except in compliance with the License.6# You may obtain a copy of the License at7#8# http://www.apache.org/licenses/LICENSE-2.09#10# Unless required by applicable law or agreed to in writing, software11# distributed under the License is distributed on an "AS IS" BASIS,12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.13# See the License for the specific language governing permissions and14# limitations under the License.15 16"""Provides data from segmentation datasets.17 18Currently, we support the following datasets:19 201. Cityscapes dataset (https://www.cityscapes-dataset.com).21 22The Cityscapes dataset contains 19 semantic labels (such as road, person, car,23and so on) for urban street scenes.24 25 262. KITTI-STEP (http://www.cvlibs.net/datasets/kitti/).27 28The KITTI-STEP enriches the KITTI-MOTS data with additional `stuff'29anntotations.30 313. MOTChallenge-STEP (https://motchallenge.net/).32 33The MOTChallenge-STEP enriches the MOTSChallenge data with additional `stuff'34annotations.35 364. MSCOCO panoptic segmentation (http://cocodataset.org/#panoptic-2018).37 38Panoptic segmentation annotations for MSCOCO dataset. Note that we convert the39provided MSCOCO panoptic segmentation format to the following one:40panoptic label = semantic label * 256 + instance id.41 425. Cityscapes-DVPS (https://github.com/joe-siyuan-qiao/ViP-DeepLab)43The Cityscapes-DVPS dataset augments Cityscapes-VPS44(https://github.com/mcahny/vps) with depth annotations.45 46 47References:48 49- Marius Cordts, Mohamed Omran, Sebastian Ramos, Timo Rehfeld, Markus50 Enzweiler, Rodrigo Benenson, Uwe Franke, Stefan Roth, and Bernt Schiele, "The51 Cityscapes Dataset for Semantic Urban Scene Understanding." In CVPR, 2016.52 53- Andreas Geiger and Philip Lenz and Raquel Urtasun, "Are we ready for54 Autonomous Driving? The KITTI Vision Benchmark Suite." In CVPR, 2012.55 56- Alexander Kirillov, Kaiming He, Ross Girshick, Carsten Rother, and Piotr57 Dollar, "Panoptic Segmentation." In CVPR, 2019.58 59- Tsung-Yi Lin, Michael Maire, Serge J. Belongie, Lubomir D. Bourdev, Ross B.60 Girshick, James Hays, Pietro Perona, Deva Ramanan, Piotr Dollar, and C.61 Lawrence Zitnick, "Microsoft COCO: common objects in context." In ECCV, 2014.62 63- Anton Milan, Laura Leal-Taixe, Ian Reid, Stefan Roth, and Konrad Schindler,64 "Mot16: A benchmark for multi-object tracking." arXiv:1603.00831, 2016.65 66- Paul Voigtlaender, Michael Krause, Aljosa Osep, Jonathon Luiten, Berin67 Balachandar Gnana Sekar, Andreas Geiger, and Bastian Leibe. "MOTS:68 Multi-object tracking and segmentation." In CVPR, 201969 70- Mark Weber, Jun Xie, Maxwell Collins, Yukun Zhu, Paul Voigtlaender, Hartwig71 Adam, Bradley Green, Andreas Geiger, Bastian Leibe, Daniel Cremers, Aljosa72 Osep, Laura Leal-Taixe, and Liang-Chieh Chen, "STEP: Segmenting and Tracking73 Every Pixel." arXiv: 2102.11859, 2021.74 75- Dahun Kim, Sanghyun Woo, Joon-Young Lee, and In So Kweon. "Video panoptic76 segmentation." In CVPR, 2020.77 78- Siyuan Qiao, Yukun Zhu, Hartwig Adam, Alan Yuille, and Liang-Chieh Chen.79 "ViP-DeepLab: Learning Visual Perception with Depth-aware Video Panoptic80 Segmentation." In CVPR, 2021.81"""82 83import collections84 85 86# Dataset names.87_CITYSCAPES = 'cityscapes'88_CITYSCAPES_PANOPTIC = 'cityscapes_panoptic'89_KITTI_STEP = 'kitti_step'90_MOTCHALLENGE_STEP = 'motchallenge_step'91_CITYSCAPES_DVPS = 'cityscapes_dvps'92_COCO_PANOPTIC = 'coco_panoptic'93 94# Colormap names.95_CITYSCAPES_COLORMAP = 'cityscapes'96_MOTCHALLENGE_COLORMAP = 'motchallenge'97_COCO_COLORMAP = 'coco'98 99 100# Named tuple to describe dataset properties.101DatasetDescriptor = collections.namedtuple(102 'DatasetDescriptor', [103 'dataset_name', # Dataset name.104 'splits_to_sizes', # Splits of the dataset into training, val and test.105 'num_classes', # Number of semantic classes.106 'ignore_label', # Ignore label value used for semantic segmentation.107 108 # Fields below are used for panoptic segmentation and will be None for109 # Semantic segmentation datasets.110 # Label divisor only used in panoptic segmentation annotation to infer111 # semantic label and instance id.112 'panoptic_label_divisor',113 # A tuple of classes that contains instance annotations. For example,114 # 'person' class has instance annotations while 'sky' does not.115 'class_has_instances_list',116 # A flag indicating whether the dataset is a video dataset that contains117 # sequence IDs and frame IDs.118 'is_video_dataset',119 # A string specifying the colormap that should be used for120 # visualization. E.g. 'cityscapes'.121 'colormap',122 # A flag indicating whether the dataset contains depth annotation.123 'is_depth_dataset',124 ]125)126 127CITYSCAPES_INFORMATION = DatasetDescriptor(128 dataset_name=_CITYSCAPES,129 splits_to_sizes={'train_fine': 2975,130 'train_coarse': 22973,131 'trainval_fine': 3475,132 'trainval_coarse': 23473,133 'val_fine': 500,134 'test_fine': 1525},135 num_classes=19,136 ignore_label=255,137 panoptic_label_divisor=None,138 class_has_instances_list=None,139 is_video_dataset=False,140 colormap=_CITYSCAPES_COLORMAP,141 is_depth_dataset=False,142)143 144CITYSCAPES_PANOPTIC_INFORMATION = DatasetDescriptor(145 dataset_name=_CITYSCAPES_PANOPTIC,146 splits_to_sizes={'train_fine': 2975,147 'val_fine': 500,148 'trainval_fine': 3475,149 'test_fine': 1525},150 num_classes=19,151 ignore_label=255,152 panoptic_label_divisor=1000,153 class_has_instances_list=tuple(range(11, 19)),154 is_video_dataset=False,155 colormap=_CITYSCAPES_COLORMAP,156 is_depth_dataset=False,157)158 159KITTI_STEP_INFORMATION = DatasetDescriptor(160 dataset_name=_KITTI_STEP,161 splits_to_sizes={'train': 5027,162 'val': 2981,163 'test': 11095},164 num_classes=19,165 ignore_label=255,166 panoptic_label_divisor=1000,167 class_has_instances_list=(11, 13),168 is_video_dataset=True,169 colormap=_CITYSCAPES_COLORMAP,170 is_depth_dataset=False,171)172 173MOTCHALLENGE_STEP_INFORMATION = DatasetDescriptor(174 dataset_name=_MOTCHALLENGE_STEP,175 splits_to_sizes={'train': 525, # Sequence 9.176 'val': 600, # Sequence 2.177 'test': 0},178 num_classes=7,179 ignore_label=255,180 panoptic_label_divisor=1000,181 class_has_instances_list=(4,),182 is_video_dataset=True,183 colormap=_MOTCHALLENGE_COLORMAP,184 is_depth_dataset=False,185)186 187CITYSCAPES_DVPS_INFORMATION = DatasetDescriptor(188 dataset_name=_CITYSCAPES_DVPS,189 # The numbers of images are 2400/300/300 for train/val/test. Here, the190 # sizes are the number of consecutive frame pairs. As each sequence has 6191 # frames, the number of pairs for the train split is 2400 / 6 * 5 = 2000.192 # Similarly, we get 250 pairs for the val split and the test split.193 splits_to_sizes={'train': 2000,194 'val': 250,195 'test': 250},196 num_classes=19,197 ignore_label=255,198 panoptic_label_divisor=1000,199 class_has_instances_list=tuple(range(11, 19)),200 is_video_dataset=True,201 colormap=_CITYSCAPES_COLORMAP,202 is_depth_dataset=True,203)204 205COCO_PANOPTIC_INFORMATION = DatasetDescriptor(206 dataset_name=_COCO_PANOPTIC,207 splits_to_sizes={'train': 118287,208 'val': 5000,209 'test': 40670},210 num_classes=134,211 ignore_label=0,212 panoptic_label_divisor=256,213 class_has_instances_list=tuple(range(1, 81)),214 is_video_dataset=False,215 colormap=_COCO_COLORMAP,216 is_depth_dataset=False,217)218 219MAP_NAME_TO_DATASET_INFO = {220 _CITYSCAPES: CITYSCAPES_INFORMATION,221 _CITYSCAPES_PANOPTIC: CITYSCAPES_PANOPTIC_INFORMATION,222 _KITTI_STEP: KITTI_STEP_INFORMATION,223 _MOTCHALLENGE_STEP: MOTCHALLENGE_STEP_INFORMATION,224 _CITYSCAPES_DVPS: CITYSCAPES_DVPS_INFORMATION,225 _COCO_PANOPTIC: COCO_PANOPTIC_INFORMATION,226}227 228MAP_NAMES = list(MAP_NAME_TO_DATASET_INFO.keys())229 