MCPcopy Index your code
hub / github.com/lazyprogrammer/machine_learning_examples / get_image_info

Function get_image_info

kerascv/pascal2coco.py:38–59  ·  view source on GitHub ↗
(annotation_root, extract_num_from_imgid=True)

Source from the content-addressed store, hash-verified

36
37
38def get_image_info(annotation_root, extract_num_from_imgid=True):
39 path = annotation_root.findtext('path')
40 if path is None:
41 filename = annotation_root.findtext('filename')
42 else:
43 filename = os.path.basename(path)
44 img_name = os.path.basename(filename)
45 img_id = os.path.splitext(img_name)[0]
46 if extract_num_from_imgid and isinstance(img_id, str):
47 img_id = int(re.findall(r'\d+', img_id)[0])
48
49 size = annotation_root.find('size')
50 width = int(size.findtext('width'))
51 height = int(size.findtext('height'))
52
53 image_info = {
54 'file_name': filename,
55 'height': height,
56 'width': width,
57 'id': img_id
58 }
59 return image_info
60
61
62def get_coco_annotation_from_obj(obj, label2id):

Callers 1

convert_xmls_to_cocojsonFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected