File size: 14,959 Bytes
b34d1d6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
import copy
from typing import List

from mmdet.registry import DATASETS
from mmdet.datasets.coco_panoptic import CocoPanopticDataset
from mmengine import get_local_path


@DATASETS.register_module()
class ADEPanopticOVDataset(CocoPanopticDataset):
    """ADE Open Vocabulary dataset for Panoptic segmentation.
    The class names are changed.
    """

    METAINFO = {
        'classes':
            (
                'bed,beds',
                'windowpane,window,windows',
                'cabinet,cabinets,wall mounted cabine',
                'person,child,girl,boy,woman,man,people,children,girls,boys,women,men',
                'door,double door,doors',
                'table,tables,tablecloth',
                'curtain,drape,drapery,mantle,pall',
                'chair,chairs',
                'car,automobile,cars',
                'painting,picture,paintings,pictures,wallart,framed canvas',
                'sofa,couch,sofas,couches',
                'shelf,shelves',
                'mirror,mirrors',
                'armchair,armchairs',
                'seat,seats',
                'fence,fencing',
                'desk,desks',
                'wardrobe,closet,press,wardrobes,closets',
                'lamp,lamps',
                'bathtub,bathing tub,bath,tub',
                'railing,rail',
                'cushion,cushions',
                'box,boxes',
                'column,pillar',
                'signboard,sign,signboards,signs',
                'chest of drawers,chest,bureau,dresser',
                'counter',
                'sink',
                'fireplace,hearth,open fireplace',
                'refrigerator,icebox',
                'stairs,steps',
                'case,display case,showcase,vitrine',
                'pool table,billiard table,snooker table',
                'pillow,pillows',
                'screen door,shower door',
                'bookcase',
                'coffee table,cocktail table',
                'toilet,commode,crapper,potty',
                'flower,flowers',
                'book,books',
                'bench,benches',
                'countertop,counter top,worktop',
                'stove,kitchen stove,kitchen range,kitchen range,cooking stove',
                'palm tree,palm trees',
                'kitchen island',
                'computer,computing machine,computing device,data processor,electronic computer,information processing system',
                'swivel chair',
                'boat',
                'arcade machine,arcade machines',
                'bus,autobus,double-decker,jitney,motorbus,motorcoach,omnibus,passenger vehicle',
                'towel',
                'light bulb,lightbulb,bulb,incandescent lamp,electric light,electric-light bulb',
                'truck,motortruck',
                'chandelier,pendant,pendent',
                'awning,sunshade,sunblind',
                'streetlight,street lamp',
                'booth,cubicle,stall,kiosk',
                'television receiver,television,television set,tv,tv set',
                'airplane,aeroplane,airplanes,aeroplanes',
                'apparel,wearing apparel,dress,clothes',
                'pole',
                'bannister,banister,balustrade,balusters,handrail',
                'ottoman,pouf,pouffe,puff,hassock',
                'bottle,bottles,water bottle',
                'van',
                'ship',
                'fountain',
                'washer,automatic washer,washing machine',
                'plaything,toy,toys',
                'stool,stools',
                'barrel,cask,barrels,casks',
                'basket,handbasket',
                'bag,bags,gift bag,paper bag',
                'minibike,motorbike',
                'oven',
                'ball,balls',
                'food,solid food',
                'step,stair',
                'trade name,brand name,brand,marque',
                'microwave,microwave oven',
                'plant pots,plant pot,flower pot,flowerpot,planter',
                'animal,animate being,dog,cat,horse,cow,sheep,zebra,girraffe,bird',
                'bicycle,bike',
                'dishwasher,dish washer,dishwashing machine',
                'projection screen',
                'sculpture,sculptures',
                'exhaust hood',
                'sconce,sconce lamp,sconce light',
                'vase,vases',
                'traffic light,traffic signal,traffic lights',
                'tray,trays',
                'ashcan,trash can,garbage can,wastebin,ash bin,ash-bin,ashbin,dustbin,trash barrel,trash bin',
                'ceiling fan,floor fan',
                'plate,plates',
                'monitor,monitoring device,monitors',
                'bulletin board,notice board',
                'radiator',
                'cup,cups,drinking glass,drinking glasses',
                'clock',
                'flag,flags',

                'wall,walls,brick wall,stone wall,interior wall',
                'building,buildings,edifice,edifices',
                'sky,clouds',
                'floor,flooring',
                'tree,trees',
                'ceiling',
                'road,route,street,roads,streets,routes',
                'grass,grass field',
                'sidewalk,pavement',
                'earth,ground',
                'mountain,mount,mountains',
                'plant,flora,plant life,plants,bushes',
                'water',
                'house exterior',
                'sea,ocean',
                'rug,carpet,carpeting',
                'field',
                'rock,stone,rocks,stones',
                'pedestal',
                'sand',
                'skyscraper,skyscrapers',
                'grandstand,covered stand',
                'path',
                'runway',
                'stairway,staircase',
                'river',
                'bridge,span',
                'window screen,door screen',
                'hill',
                'bar',
                'hovel,hut,hutch,shack,shanty',
                'tower,towers',
                'dirt track',
                'land,soil',
                'escalator,moving staircase,moving stairway',
                'buffet,sideboard',
                'poster,posting,placard,notice,bill,card',
                'stage',
                'conveyer belt,conveyor belt,conveyer,conveyor,transporter',
                'canopy',
                'swimming pool,swimming bath',
                'waterfall,falls',
                'tent,collapsible shelter',
                'cradle',
                'tank,storage tank',
                'lake',
                'blanket,cover',
                'pier,wharf,wharfage,dock',
                'crt screen',
                'shower',
            ),
        'thing_classes':
            (
                'bed,beds',
                'windowpane,window,windows',
                'cabinet,cabinets,wall mounted cabine',
                'person,child,girl,boy,woman,man,people,children,girls,boys,women,men',
                'door,double door,doors',
                'table,tables,tablecloth',
                'curtain,drape,drapery,mantle,pall',
                'chair,chairs',
                'car,automobile,cars',
                'painting,picture,paintings,pictures,wallart,framed canvas',
                'sofa,couch,sofas,couches',
                'shelf,shelves',
                'mirror,mirrors',
                'armchair,armchairs',
                'seat,seats',
                'fence,fencing',
                'desk,desks',
                'wardrobe,closet,press,wardrobes,closets',
                'lamp,lamps',
                'bathtub,bathing tub,bath,tub',
                'railing,rail',
                'cushion,cushions',
                'box,boxes',
                'column,pillar',
                'signboard,sign,signboards,signs',
                'chest of drawers,chest,bureau,dresser',
                'counter',
                'sink',
                'fireplace,hearth,open fireplace',
                'refrigerator,icebox',
                'stairs,steps',
                'case,display case,showcase,vitrine',
                'pool table,billiard table,snooker table',
                'pillow,pillows',
                'screen door,shower door',
                'bookcase',
                'coffee table,cocktail table',
                'toilet,commode,crapper,potty',
                'flower,flowers',
                'book,books',
                'bench,benches',
                'countertop,counter top,worktop',
                'stove,kitchen stove,kitchen range,kitchen range,cooking stove',
                'palm tree,palm trees',
                'kitchen island',
                'computer,computing machine,computing device,data processor,electronic computer,information processing system',
                'swivel chair',
                'boat',
                'arcade machine,arcade machines',
                'bus,autobus,double-decker,jitney,motorbus,motorcoach,omnibus,passenger vehicle',
                'towel',
                'light bulb,lightbulb,bulb,incandescent lamp,electric light,electric-light bulb',
                'truck,motortruck',
                'chandelier,pendant,pendent',
                'awning,sunshade,sunblind',
                'streetlight,street lamp',
                'booth,cubicle,stall,kiosk',
                'television receiver,television,television set,tv,tv set',
                'airplane,aeroplane,airplanes,aeroplanes',
                'apparel,wearing apparel,dress,clothes',
                'pole',
                'bannister,banister,balustrade,balusters,handrail',
                'ottoman,pouf,pouffe,puff,hassock',
                'bottle,bottles,water bottle',
                'van',
                'ship',
                'fountain',
                'washer,automatic washer,washing machine',
                'plaything,toy,toys',
                'stool,stools',
                'barrel,cask,barrels,casks',
                'basket,handbasket',
                'bag,bags,gift bag,paper bag',
                'minibike,motorbike',
                'oven',
                'ball,balls',
                'food,solid food',
                'step,stair',
                'trade name,brand name,brand,marque',
                'microwave,microwave oven',
                'plant pots,plant pot,flower pot,flowerpot,planter',
                'animal,animate being,dog,cat,horse,cow,sheep,zebra,girraffe,bird',
                'bicycle,bike',
                'dishwasher,dish washer,dishwashing machine',
                'projection screen',
                'sculpture,sculptures',
                'exhaust hood',
                'sconce,sconce lamp,sconce light',
                'vase,vases',
                'traffic light,traffic signal,traffic lights',
                'tray,trays',
                'ashcan,trash can,garbage can,wastebin,ash bin,ash-bin,ashbin,dustbin,trash barrel,trash bin',
                'ceiling fan,floor fan',
                'plate,plates',
                'monitor,monitoring device,monitors',
                'bulletin board,notice board',
                'radiator',
                'cup,cups,drinking glass,drinking glasses',
                'clock',
                'flag,flags',
            ),
        'stuff_classes':
            (
                'wall,walls,brick wall,stone wall,interior wall',
                'building,buildings,edifice,edifices',
                'sky,clouds',
                'floor,flooring',
                'tree,trees',
                'ceiling',
                'road,route,street,roads,streets,routes',
                'grass,grass field',
                'sidewalk,pavement',
                'earth,ground',
                'mountain,mount,mountains',
                'plant,flora,plant life,plants,bushes',
                'water',
                'house exterior',
                'sea,ocean',
                'rug,carpet,carpeting',
                'field',
                'rock,stone,rocks,stones',
                'pedestal',
                'sand',
                'skyscraper,skyscrapers',
                'grandstand,covered stand',
                'path',
                'runway',
                'stairway,staircase',
                'river',
                'bridge,span',
                'window screen,door screen',
                'hill',
                'bar',
                'hovel,hut,hutch,shack,shanty',
                'tower,towers',
                'dirt track',
                'land,soil',
                'escalator,moving staircase,moving stairway',
                'buffet,sideboard',
                'poster,posting,placard,notice,bill,card',
                'stage',
                'conveyer belt,conveyor belt,conveyer,conveyor,transporter',
                'canopy',
                'swimming pool,swimming bath',
                'waterfall,falls',
                'tent,collapsible shelter',
                'cradle',
                'tank,storage tank',
                'lake',
                'blanket,cover',
                'pier,wharf,wharfage,dock',
                'crt screen',
                'shower',
            ),
    }

    def load_data_list(self) -> List[dict]:
        """Load annotations from an annotation file named as ``self.ann_file``

        Returns:
            List[dict]: A list of annotation.
        """  # noqa: E501
        with get_local_path(
                self.ann_file, backend_args=self.backend_args) as local_path:
            self.coco = self.COCOAPI(local_path)
            for idx, name in enumerate(self.metainfo['classes']):
                if not (self.coco.cats[idx]['name'].strip() in name.split(',')):
                    print(f"Warning {idx} !!:\n{self.coco.cats[idx]['name']} vs {name}")
        # use all classes, cannot use self.metainfo anymore.
        self.cat_ids = self.coco.get_cat_ids()
        self.cat2label = {cat_id: i for i, cat_id in enumerate(self.cat_ids)}
        self.cat_img_map = copy.deepcopy(self.coco.cat_img_map)

        img_ids = self.coco.get_img_ids()
        data_list = []
        total_ann_ids = []
        for img_id in img_ids:
            raw_img_info = self.coco.load_imgs([img_id])[0]
            raw_img_info['img_id'] = img_id

            ann_ids = self.coco.get_ann_ids(img_ids=[img_id])
            raw_ann_info = self.coco.load_anns(ann_ids)
            total_ann_ids.extend(ann_ids)

            parsed_data_info = self.parse_data_info({
                'raw_ann_info':
                    raw_ann_info,
                'raw_img_info':
                    raw_img_info
            })
            data_list.append(parsed_data_info)
        if self.ANN_ID_UNIQUE:
            assert len(set(total_ann_ids)) == len(
                total_ann_ids
            ), f"Annotation ids in '{self.ann_file}' are not unique!"

        del self.coco

        return data_list