diff --git a/convert.py b/convert.py new file mode 100644 index 000000000..2adeb673a --- /dev/null +++ b/convert.py @@ -0,0 +1,52 @@ +import xml.etree.ElementTree as ET +from os import listdir +from tqdm import tqdm +from os.path import isfile, join +def fun(fname): + tree = ET.parse('/content/drive/My Drive/workspace/11march/ann/'+fname) + root = tree.getroot() + + f = open('/content/drive/My Drive/workspace/11march/txts/'+fname.replace(".xml",".txt"), "w") + for child in root: + if(child.tag == 'object'): + f.write(child[0].text + ' ' + child[1][0].text + ' ' + child[1][1].text + ' ' + child[1][2].text + ' ' + child[1][3].text+ '\n') + + f.close() + +mypath = '/content/drive/My Drive/workspace/11march/ann/' +onlyfiles = [f for f in listdir(mypath) if isfile(join(mypath, f))] +print(onlyfiles) +for p in tqdm(onlyfiles): + fun(p) + + + +#xml in form +# +#000144_r.jpg +#BLR-2018-03-22_17-39-26_2_frontNear_right_2 +# +#1920 +#1080 +#3 +# +# +#car +# +#987 +#624 +#999 +#611 +# +# +# +#car +# +#995 +#640 +#1024 +#617 +# +# +# +