Veri-776数据集处理 xml文件提取转换成txt文件
Veri-776数据集处理 xml文件提取转换成txt文件最近在做重识别工作,数据处理时需要进行文件格式转换,这里将代码记录下来from os import getcwdimport osfrom xml.dom.minidom import parseos.environ["CUDA_VISIBLE_DEVICES"] = "0"vehicleids = []def convert_annota
·
Veri-776数据集处理 xml文件提取转换成txt文件
最近在做重识别工作,数据处理时需要进行文件格式转换,这里将代码记录下来
from os import getcwd
import os
from xml.dom.minidom import parse
os.environ["CUDA_VISIBLE_DEVICES"] = "0"
vehicleids = []
def convert_annotation():
in_file = open('dataset/VeRi/train_label.xml')
list_file = open('train_list.txt','w')
tree = parse(in_file)
root = tree.documentElement
for item in root.getElementsByTagName("Item"):
if item.hasAttribute("imageName"):
name = item.getAttribute("imageName")
if item.hasAttribute("vehicleID"):
vehicleid = item.getAttribute("vehicleID")
if vehicleid not in vehicleids :
vehicleids.append(vehicleid)
vid = vehicleids.index(vehicleid)
if item.hasAttribute("colorID"):
colorid = int (item.getAttribute("colorID"))
if item.hasAttribute("typeID"):
typeid = int (item.getAttribute("typeID"))
list_file.write(name + " " + str(vid) + " " + str(colorid) + " " +str(typeid) + "\n")
list_file.close()
if __name__ == '__main__':
convert_annotation() #imagename vehiclenum colorid typeid

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。
更多推荐
所有评论(0)