MCPcopy Index your code
hub / github.com/openimages/dataset / LoadLabelMap

Function LoadLabelMap

tools/classify_oidv2.py:124–142  ·  view source on GitHub ↗

Load index->mid and mid->display name maps. Args: labelmap_path: path to the file with the list of mids, describing predictions. dict_path: path to the dict.csv that translates from mids to display names. Returns: labelmap: an index to mid list label_dict: mid to display

(labelmap_path, dict_path)

Source from the content-addressed store, hash-verified

122
123
124def LoadLabelMap(labelmap_path, dict_path):
125 """Load index->mid and mid->display name maps.
126
127 Args:
128 labelmap_path: path to the file with the list of mids, describing
129 predictions.
130 dict_path: path to the dict.csv that translates from mids to display names.
131 Returns:
132 labelmap: an index to mid list
133 label_dict: mid to display name dictionary
134 """
135 labelmap = [line.rstrip() for line in tf.gfile.GFile(labelmap_path)]
136
137 label_dict = {}
138 for line in tf.gfile.GFile(dict_path):
139 words = [word.strip(' "\n') for word in line.split(',', 1)]
140 label_dict[words[0]] = words[1]
141
142 return labelmap, label_dict
143
144
145def main(_):

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected