MCPcopy Create free account
hub / github.com/SooLab/CGFormer / __init__

Method __init__

tools/refer.py:42–74  ·  view source on GitHub ↗
(self, data_root, dataset='refcoco', splitBy='unc')

Source from the content-addressed store, hash-verified

40
41class REFER:
42 def __init__(self, data_root, dataset='refcoco', splitBy='unc'):
43 # provide data_root folder which contains refclef, refcoco, refcoco+ and refcocog
44 # also provide dataset name and splitBy information
45 # e.g., dataset = 'refcoco', splitBy = 'unc'
46 print('loading dataset %s into memory...' % dataset)
47 self.ROOT_DIR = osp.abspath(osp.dirname(__file__))
48 self.DATA_DIR = osp.join(data_root, dataset)
49 if dataset in ['refcoco', 'refcoco+', 'refcocog']:
50 self.IMAGE_DIR = osp.join(data_root, 'images/train2014')
51 elif dataset == 'refclef':
52 self.IMAGE_DIR = osp.join(data_root, 'images/saiapr_tc-12')
53 else:
54 print('No refer dataset is called [%s]' % dataset)
55 sys.exit()
56
57 # load refs from data/dataset/refs(dataset).json
58 tic = time.time()
59 ref_file = osp.join(self.DATA_DIR, 'refs(' + splitBy + ').p')
60 self.data = {}
61 self.data['dataset'] = dataset
62
63 self.data['refs'] = pickle.load(open(ref_file, 'rb'), fix_imports=True)
64
65 # load annotations from data/dataset/instances.json
66 instances_file = osp.join(self.DATA_DIR, 'instances.json')
67 instances = json.load(open(instances_file, 'r'))
68 self.data['images'] = instances['images']
69 self.data['annotations'] = instances['annotations']
70 self.data['categories'] = instances['categories']
71
72 # create index
73 self.createIndex()
74 print('DONE (t=%.2fs)' % (time.time() - tic))
75
76 def createIndex(self):
77 # create sets of mapping

Callers

nothing calls this directly

Calls 2

createIndexMethod · 0.95
loadMethod · 0.80

Tested by

no test coverage detected