Returns SplitGenerators.
(self, dl_manager)
| 229 | ) |
| 230 | |
| 231 | def _split_generators(self, dl_manager): |
| 232 | """Returns SplitGenerators.""" |
| 233 | |
| 234 | # Merge urls from all splits together |
| 235 | urls = {} |
| 236 | for split in self.builder_config.splits: |
| 237 | urls['{}_images'.format(split.name)] = 'zips/{}.zip'.format(split.images) |
| 238 | urls['{}_annotations'.format(split.name)] = 'annotations/{}.zip'.format( |
| 239 | split.annotations |
| 240 | ) |
| 241 | |
| 242 | # DownloadManager memoize the url, so duplicate urls will only be downloaded |
| 243 | # once. |
| 244 | root_url = 'http://images.cocodataset.org/' |
| 245 | extracted_paths = dl_manager.download_and_extract( |
| 246 | {key: root_url + url for key, url in urls.items()} |
| 247 | ) |
| 248 | |
| 249 | splits = [] |
| 250 | for split in self.builder_config.splits: |
| 251 | image_dir = extracted_paths['{}_images'.format(split.name)] |
| 252 | annotations_dir = extracted_paths['{}_annotations'.format(split.name)] |
| 253 | if self.builder_config.has_panoptic: |
| 254 | panoptic_image_zip_path = os.path.join( |
| 255 | annotations_dir, |
| 256 | 'annotations', |
| 257 | 'panoptic_{}.zip'.format(split.images), |
| 258 | ) |
| 259 | panoptic_dir = dl_manager.extract(panoptic_image_zip_path) |
| 260 | panoptic_dir = os.path.join( |
| 261 | panoptic_dir, 'panoptic_{}'.format(split.images) |
| 262 | ) |
| 263 | else: |
| 264 | panoptic_dir = None |
| 265 | splits.append( |
| 266 | tfds.core.SplitGenerator( |
| 267 | name=split.name, |
| 268 | gen_kwargs=dict( |
| 269 | image_dir=image_dir, |
| 270 | annotation_dir=annotations_dir, |
| 271 | split_name=split.images, |
| 272 | annotation_type=split.annotation_type, |
| 273 | panoptic_dir=panoptic_dir, |
| 274 | ), |
| 275 | ) |
| 276 | ) |
| 277 | return splits |
| 278 | |
| 279 | def _generate_examples( |
| 280 | self, image_dir, annotation_dir, split_name, annotation_type, panoptic_dir |
nothing calls this directly
no test coverage detected