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

Method __init__

eval/CIPO_evaluation/adapter.py:48–91  ·  view source on GitHub ↗

Constructor of Microsoft COCO helper class for reading and visualizing annotations. :param txtfile (str): location of annotation file :return:

(self, txtfile=None)

Source from the content-addressed store, hash-verified

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 = {}, {}, {}, {}

Callers

nothing calls this directly

Calls 1

createIndexMethod · 0.95

Tested by

no test coverage detected