|
|
|
|
@ -6,6 +6,15 @@ from pascal_voc_writer import Writer
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def process_cvat_xml(xml_file, img_dir, annotation_dir):
|
|
|
|
|
"""
|
|
|
|
|
Transforms a single XML in CVAT format to multiple PASCAL VOC format
|
|
|
|
|
XMls.
|
|
|
|
|
|
|
|
|
|
:param xml_file: CVAT format XML
|
|
|
|
|
:param img_dir: image directory of the dataset
|
|
|
|
|
:param annotation_dir: directory of annotations with PASCAL VOC format
|
|
|
|
|
:return:
|
|
|
|
|
"""
|
|
|
|
|
os.makedirs(annotation_dir)
|
|
|
|
|
cvat_xml = xml.etree.ElementTree.parse(xml_file)
|
|
|
|
|
|
|
|
|
|
@ -33,9 +42,10 @@ def process_cvat_xml(xml_file, img_dir, annotation_dir):
|
|
|
|
|
|
|
|
|
|
parser = argparse.ArgumentParser(description='Transforms CVAT XML to Pascal '
|
|
|
|
|
'VOC format')
|
|
|
|
|
parser.add_argument('cvat_xml', type=argparse.FileType())
|
|
|
|
|
parser.add_argument('img_dir')
|
|
|
|
|
parser.add_argument('annotation_dir')
|
|
|
|
|
parser.add_argument('cvat_xml', type=argparse.FileType(), help='CVAT XML file')
|
|
|
|
|
parser.add_argument('img_dir', help='Image directory of the dataset')
|
|
|
|
|
parser.add_argument('annotation_dir', help='Output directory of '
|
|
|
|
|
'XML annotations')
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
|
args = vars(parser.parse_args())
|
|
|
|
|
|