XML 格式的图像标注文件转换为 YOLO 所需的 txt 格式
发布时间
阅读量:
阅读量
import os
import xml.etree.ElementTree as ET
dirpath = 'G:aug_label_xml/' #原来存放xml文件的目录
newdir = 'G:aug_label_yolo/' #修改label后形成的txt目录
if not os.path.exists(newdir):
os.makedirs(newdir)
for fp in os.listdir(dirpath):
root = ET.parse(os.path.join(dirpath,fp)).getroot()
xmin, ymin, xmax, ymax = 0,0,0,0
sz = root.find('size')
width = float(sz[0].text)
height = float(sz[1].text)
filename = root.find('filename').text
for child in
全部评论 (0)
还没有任何评论哟~
