提取txt文件(Yolo格式标注文件)中特定类别的信息
import xml.etree.ElementTree as ET
import pickle
import os
from os import listdir, getcwd
from os.path import join
sets=[('2007','train'),('2007','test'),('2007','val')]
classes = ["bicycle", "bird", "cat", "car"] #标记的名字,需要与labelImg里的名字一致
def convert(size, box):
dw = 1./size[0]
dh = 1./size[1]
x = (box[0] + box[1]

这段代码用于从VOC2007数据集的XML标注文件中提取指定类别的信息,并转换为Yolo格式的txt文件。它遍历XML文件,查找指定的类别,如'bicycle'、'bird'等,然后将这些信息写入新的txt文件中,用于后续的物体检测训练。程序首先读取XML文件,解析尺寸信息和边界框坐标,然后进行坐标转换并写入到目标txt文件。
最低0.47元/天 解锁文章
188

被折叠的 条评论
为什么被折叠?



