常用目标检测模型基本都是读取的PASCAL VOC格式的标签,下面代码用于生成VOC格式的代码,根据需要修改即可: from lxml import etree, objectify def gen_txt(filename, h, w, c): E = objectify.ElementMaker(annotate=False) anno_tree = E.annotation( E.folder('VOC_OPEN_IMAGE'), E.filename(filename), E.source( E.database('The VOC2007