This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<annotation verified="yes"> | |
<folder>MARMOT_ANNOTATION</folder> | |
<filename>10.1.1.1.2006_3.bmp</filename> | |
<path>MARMOT_ANNOTATION/10.1.1.1.2006_3.bmp</path> | |
<source> | |
<database>Unknown</database> | |
</source> | |
<size> | |
<width>793</width> | |
<height>1123</height> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import xmltodict | |
import xml.etree.ElementTree as ET | |
dataset_file = r'/content/sample.xml' # The path to the XML file | |
xml_tree = ET.parse(dataset_file) # Parse the XML file | |
root = xml_tree.getroot() # Find the root element | |
assert root.tag == 'annotation' or root.attrib['verified'] == 'yes', "PASCAL VOC does not contain a root element" # Check if the root element is "annotation" | |
assert len(root.findtext('folder')) > 0, "XML file does not contain a 'folder' element" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
coco_file = r'/content/sample.json' | |
with open(coco_file) as json_file: | |
coco_data = json.load(json_file) | |
def assertions(key, values, required_keys, unique_key=None): | |
unique_key_id_mapper = {} | |
for value in values: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"images": [{ | |
"file_name": "10.1.1.1.2006_3.bmp", | |
"height": 1123, | |
"width": 793, | |
"id": "10.1.1.1.2006_3" | |
}], | |
"type": "instances", | |
"annotations": [{ | |
"area": 4560, |
OlderNewer