voc_lable.py文件代码解读
下载python脚本:
wget https://pjreddie.com/media/files/voc_label.py
代码解读:
import xml.etree.ElementTree as ET
import pickle
import os
from os import listdir, getcwd
from os.path import join
#数据集
sets=[('2012', 'train'), ('2012', 'val'), ('2007', 'train'), ('2007', 'val'), ('2007', 'test')]
#要检测的类别
classes = ["aeroplane", "bicycle", "bird", "boat", "bottle", "bus", "car", "cat", "chair", "cow", "diningtable", "dog", "horse", "motorbike", "person", "pottedplant", "sheep", "sofa", "train", "tvmonitor"]
def convert(size, box):
#box中存的是框的xmin,xmax,ymin,ymax
dw = 1./(size[0])#size[0]是图片的宽度
dh = 1./(size[1])#size