MCPcopy Create free account
hub / github.com/OpenDriveLab/OpenLane / adapter

Class adapter

eval/CIPO_evaluation/adapter.py:47–342  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

45
46
47class adapter:
48 def __init__(self, txtfile=None):
49 """
50 Constructor of Microsoft COCO helper class for reading and visualizing annotations.
51 :param txtfile (str): location of annotation file
52 :return:
53 """
54 # load dataset
55 self.dataset,self.anns,self.cats,self.imgs = dict(),dict(),dict(),dict()
56 self.imgToAnns, self.catToImgs = defaultdict(list), defaultdict(list)
57
58 # anns :
59 # annid -- imgid + idx int
60 # imgid
61 # bbox
62 # levelid
63 # annid
64 # iscrowd 0
65
66 # cats :
67 # id
68 # type
69
70 # imgs :
71 # file_path
72 # imgid int
73
74 if not txtfile == None:
75 print('loading annotations into memory...')
76 tic = time.time()
77 nms = []
78 with open(txtfile, 'r') as f:
79 line = f.readline().strip('\n')
80 # print("Hello2")
81 while line:
82 nms.append(line)
83 line = f.readline().strip('\n')
84 # print(nms)
85
86 self.createIndex(nms)
87 # dataset = json.load(open(txtfile, 'r'))
88 # assert type(dataset)==dict, 'annotation file format {} not supported'.format(type(dataset))
89 # print('Done (t={:0.2f}s)'.format(time.time()- tic))
90 # self.dataset = dataset
91 # self.createIndex()
92 def createIndex(self, files):
93 print('creating index...')
94 dataset, anns, cats, imgs = {}, {}, {}, {}
95 imgToAnns,catToImgs = defaultdict(list),defaultdict(list)
96 cnt = 0
97 for file in files:
98 contents = json.load(open("./annotations/" + file, 'r'))
99 if cnt == 0:
100 # print(contents)
101 cnt = cnt + 1
102 imgid = int(file.split('/')[1].split('.')[0])
103 # print(imgid)
104

Callers 3

CIPO_evalFunction · 0.90
CIPO_evalFunction · 0.90
loadResMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected