import os
import xml.dom.minidom
gt_dict={}
Image_Path="myData/JPEGImages/test"
XML_Path="myData/Annotations/test_xml/"
imagelist=os.listdir(Image_Path)
for image in imagelist:
image_pre, ext = os.path.splitext(image)
xmlfile = XML_Path + image_pre + '.xml'
dom = xml.dom.minidom.parse(xmlfile)
root = dom.documentElement
filenamelist = root.getElementsByTagName("filename")
filename=filenamelist[0].childNodes[0].data
objectlist=root.getElementsByTagName("object")
for objects in objectlist:
namelist=objects.getElementsByTagName("name")
objectname=namelist[0].childNodes[0].data
gt_dict[filename]=objectname
print(gt_dict)