VOC2007数据转为.txt文件
生成在Main文件夹下
目录内容为文件名
1 生成voc2txt
-
目录结构
- VOCdevkit / VOC2007 / Annotations / *.xml
- VOCdevkit / VOC2007 / JPEGImages / *.bmp *.jpg …
- VOCdevkit / VOC2007 / ImageSets / Main / *.txt
- VOCdevkit / VOC2007 / voc2txt.py
-
代码
import os
import random
# FILE:voc2txt.py
# NAME:@Link
# E-Mail:xhh0608@foxmail.com
xmlfilepath=r'./VOCdevkit/VOC2007/Annotations'
saveBasePath=r"./VOCdevkit/VOC2007/ImageSets/Main/"
# train & val 占总的90%,test占10%; 如:改为0,则全部生成 .text
trainval_percent=0.9
# train & val 中,分配给train的比例,1.0 即全部用来train 100%,无val
train_percent=1.0
temp_xml = os.listdir(xmlfilepath)
total_xml = []
for xml in temp_xml: