25
25
import numpy as np
26
26
import tensorflow_datasets .public_api as tfds
27
27
28
- _URLS = {
28
+ _EXTRACT_URLS = {
29
29
'train_annotation' : (
30
30
'https://dl.fbaipublicfiles.com/LVIS/lvis_v1_train.json.zip'
31
31
),
34
34
'https://dl.fbaipublicfiles.com/LVIS/lvis_v1_val.json.zip'
35
35
),
36
36
'validation_images' : 'http://images.cocodataset.org/zips/val2017.zip' ,
37
- 'test_annotation' : 'https://dl.fbaipublicfiles.com/LVIS/lvis_v1_image_info_test_dev.json.zip' ,
37
+ 'test_annotation' : (
38
+ 'https://dl.fbaipublicfiles.com/LVIS/lvis_v1_image_info_test_dev.json.zip'
39
+ ),
38
40
'test_images' : 'http://images.cocodataset.org/zips/test2017.zip' ,
39
- # Minival from https://github.com/ashkamath/mdetr/blob/main/.github/lvis.md:
41
+ }
42
+ _URLS = {
43
+ # Minival from
44
+ # https://gitlab.com/YuanHuan_Pro/YOLO-World/-/blob/master/docs/data.md:
40
45
'minival_annotation' : (
41
- 'https://nyu.box.com/shared/static/2yk9x8az9pnlsy2v8gd95yncwn2q7vj6.zip '
46
+ 'https://huggingface.co/GLIPModel/GLIP/resolve/main/lvis_v1_minival_inserted_image_name.json '
42
47
),
43
48
}
44
49
71
76
class Builder (tfds .core .GeneratorBasedBuilder ):
72
77
"""DatasetBuilder for lvis dataset."""
73
78
74
- VERSION = tfds .core .Version ('1.3 .0' )
79
+ VERSION = tfds .core .Version ('1.4 .0' )
75
80
RELEASE_NOTES = {
76
81
'1.1.0' : (
77
82
'Added fields `neg_category_ids` and `not_exhaustive_category_ids`.'
78
83
),
79
84
'1.2.0' : 'Added class names.' ,
80
85
'1.3.0' : 'Added minival split.' ,
86
+ '1.4.0' : 'Added segmentation masks to the minival split.' ,
81
87
}
82
88
83
89
def _info (self ) -> tfds .core .DatasetInfo :
@@ -116,7 +122,10 @@ def _info(self) -> tfds.core.DatasetInfo:
116
122
117
123
def _split_generators (self , dl_manager : tfds .download .DownloadManager ):
118
124
"""Returns SplitGenerators."""
119
- paths = dl_manager .download_and_extract (_URLS )
125
+ paths = {
126
+ ** dl_manager .download_and_extract (_EXTRACT_URLS ),
127
+ ** dl_manager .download (_URLS ),
128
+ }
120
129
image_dirs = [
121
130
paths ['train_images' ] / 'train2017' ,
122
131
paths ['validation_images' ] / 'val2017' ,
@@ -135,7 +144,7 @@ def _split_generators(self, dl_manager: tfds.download.DownloadManager):
135
144
),
136
145
'minival' : self ._generate_examples (
137
146
image_dirs ,
138
- paths ['minival_annotation' ] / 'lvis_v1_minival.json' ,
147
+ paths ['minival_annotation' ],
139
148
),
140
149
}
141
150
@@ -169,7 +178,7 @@ def _process_example(image_info):
169
178
'bbox' : _build_bbox (image_info , * inst ['bbox' ]),
170
179
'label' : inst ['category_id' ] - 1 ,
171
180
'segmentation' : _build_segmentation_mask (
172
- image_info , inst . get ( 'segmentation' , []) # No segs in minival.
181
+ image_info , inst [ 'segmentation' ]
173
182
),
174
183
})
175
184
return image_info ['id' ], example
0 commit comments