whyen-wang commited on
Commit
bedf15d
·
1 Parent(s): 7c9a8ef
Files changed (1) hide show
  1. coco_captions.py +13 -9
coco_captions.py CHANGED
@@ -38,7 +38,8 @@ class COCOCaptionsConfig(datasets.BuilderConfig):
38
  url = 'http://images.cocodataset.org/zips/'
39
  self.train_image_url = url + 'train2017.zip'
40
  self.val_image_url = url + 'val2017.zip'
41
- self.annotation_urls = annotation_urls
 
42
 
43
 
44
  class COCOCaptions(datasets.GeneratorBasedBuilder):
@@ -47,8 +48,8 @@ class COCOCaptions(datasets.GeneratorBasedBuilder):
47
  description=_DESCRIPTION,
48
  homepage=_HOMEPAGE,
49
  annotation_urls={
50
- 'train': 'data/captions_train.jsonl',
51
- 'validation': 'data/captions_validation.jsonl'
52
  },
53
  )
54
  ]
@@ -73,25 +74,28 @@ class COCOCaptions(datasets.GeneratorBasedBuilder):
73
  train_image_path = dl_manager.download_and_extract(
74
  self.config.train_image_url
75
  )
76
- validation_image_path = dl_manager.download_and_extract(
77
  self.config.val_image_url
78
  )
79
- annotation_paths = dl_manager.download_and_extract(
80
- self.config.annotation_urls
 
 
 
81
  )
82
  return [
83
  datasets.SplitGenerator(
84
  name=datasets.Split.TRAIN,
85
  gen_kwargs={
86
  'image_path': f'{train_image_path}/train2017',
87
- 'annotation_path': annotation_paths['train']
88
  }
89
  ),
90
  datasets.SplitGenerator(
91
  name=datasets.Split.VALIDATION,
92
  gen_kwargs={
93
- 'image_path': f'{validation_image_path}/val2017',
94
- 'annotation_path': annotation_paths['validation']
95
  }
96
  )
97
  ]
 
38
  url = 'http://images.cocodataset.org/zips/'
39
  self.train_image_url = url + 'train2017.zip'
40
  self.val_image_url = url + 'val2017.zip'
41
+ self.train_annotation_urls = annotation_urls['train']
42
+ self.val_annotation_urls = annotation_urls['validation']
43
 
44
 
45
  class COCOCaptions(datasets.GeneratorBasedBuilder):
 
48
  description=_DESCRIPTION,
49
  homepage=_HOMEPAGE,
50
  annotation_urls={
51
+ 'train': 'data/captions_train.zip',
52
+ 'validation': 'data/captions_validation.zip'
53
  },
54
  )
55
  ]
 
74
  train_image_path = dl_manager.download_and_extract(
75
  self.config.train_image_url
76
  )
77
+ val_image_path = dl_manager.download_and_extract(
78
  self.config.val_image_url
79
  )
80
+ train_annotation_paths = dl_manager.download_and_extract(
81
+ self.config.train_annotation_urls
82
+ )
83
+ val_annotation_paths = dl_manager.download_and_extract(
84
+ self.config.val_annotation_urls
85
  )
86
  return [
87
  datasets.SplitGenerator(
88
  name=datasets.Split.TRAIN,
89
  gen_kwargs={
90
  'image_path': f'{train_image_path}/train2017',
91
+ 'annotation_path': f'{train_annotation_paths}/captions_train.jsonl'
92
  }
93
  ),
94
  datasets.SplitGenerator(
95
  name=datasets.Split.VALIDATION,
96
  gen_kwargs={
97
+ 'image_path': f'{val_image_path}/val2017',
98
+ 'annotation_path': f'{val_annotation_paths}/captions_validation.jsonl'
99
  }
100
  )
101
  ]