| 175 | ] |
| 176 | |
| 177 | def _info(self): |
| 178 | features = { |
| 179 | # Images can have variable shape |
| 180 | 'image': tfds.features.Image(encoding_format='jpeg'), |
| 181 | 'image/filename': tfds.features.Text(), |
| 182 | 'image/id': tf.int64, |
| 183 | } |
| 184 | # Either uses panotptic or original annotations |
| 185 | if self.builder_config.has_panoptic: |
| 186 | features.update({ |
| 187 | 'panoptic_image': tfds.features.Image(encoding_format='png'), |
| 188 | 'panoptic_image/filename': tfds.features.Text(), |
| 189 | 'panoptic_objects': tfds.features.Sequence({ |
| 190 | 'id': np.int64, |
| 191 | # Coco has unique id for each annotation. The id can be used |
| 192 | # for mapping panoptic image to semantic segmentation label. |
| 193 | 'area': np.int64, |
| 194 | 'bbox': tfds.features.BBoxFeature(), |
| 195 | # Coco2017 has 200 categories but only 133 are present in the |
| 196 | # dataset |
| 197 | 'label': tfds.features.ClassLabel(num_classes=133), |
| 198 | 'is_crowd': np.bool_, |
| 199 | }), |
| 200 | }) |
| 201 | else: |
| 202 | features.update( |
| 203 | { |
| 204 | 'objects': tfds.features.Sequence({ |
| 205 | 'id': np.int64, |
| 206 | # Coco has unique id for each annotation. The id can be used |
| 207 | # for mapping panoptic image to semantic segmentation label. |
| 208 | 'area': np.int64, |
| 209 | 'bbox': tfds.features.BBoxFeature(), |
| 210 | # Coco has 91 categories but only 80 appear in the dataset |
| 211 | 'label': tfds.features.ClassLabel(num_classes=80), |
| 212 | 'is_crowd': np.bool_, |
| 213 | }), |
| 214 | } |
| 215 | ) |
| 216 | # More info could be added, like segmentation (as png mask), captions, |
| 217 | # person key-points, more metadata (original flickr url,...). |
| 218 | |
| 219 | return tfds.core.DatasetInfo( |
| 220 | builder=self, |
| 221 | description=_DESCRIPTION, |
| 222 | # More info could be added, like the segmentation (as png mask), |
| 223 | # captions, person key-points. For caption encoding, it would probably |
| 224 | # be better to have a separate class CocoCaption2014 to avoid poluting |
| 225 | # the main class with builder config for each encoder. |
| 226 | features=tfds.features.FeaturesDict(features), |
| 227 | homepage='http://cocodataset.org/#home', |
| 228 | citation=_CITATION, |
| 229 | ) |
| 230 | |
| 231 | def _split_generators(self, dl_manager): |
| 232 | """Returns SplitGenerators.""" |