该部分代码功能在于实现了一个pascol _voc的类,该类继承自imdb,用于负责数据交互部分。
初始化函数
在初始化自身的同时,先调用了父类的初始化方法,将imdb _name传入,例如(‘voc _2007 _trainval’)
下面是成员变量的初始化:
{
year:’2007’
image _set:’trainval’
devkit _path:’data/VOCdevkit2007’
data _path:’data /VOCdevkit2007/VOC2007’
classes:(…)_如果想要训练自己的数据,需要修改这里_
class _to _ind:{…} _一个将类名转换成下标的字典 _
image _ext:’.jpg’
image _index: [‘000001’,’000003’,……]_根据trainval.txt获取到的image索引_
roidb _handler: <Method gt_roidb >
salt: <Object uuid >
comp _id:’comp4’
config:{…}
}
class pascal _voc(imdb):
def __init__(self, image_set, year, devkit_path=None):
imdb.__init__(self, 'voc_' + year + '_' + image_set)
self._year = year
self._image_set = image_set
self._devkit_path = self._get_default_path() if devkit_path is None
else devkit_path
self._data_path = os.path.join(self._devkit_path, 'VOC' + self._year)
self._classes = ('__background__', # always index 0
'aeroplane', 'bicycle', 'bird', 'boat',
'bottle', 'bus', 'car', 'cat', 'chair',
'cow', 'diningtable', 'dog', 'horse',
'motorbike', 'person', 'pottedplant',
'sheep', 'sofa', 'train', 'tvmonitor')
self._class_to_ind = dict(zip(self.classes, xrange(self.num_classes)))
self._image_ext = '.jpg'
self._image_index = self._load_image_set_index()
# Default to roidb handler
self._roidb_handler = self.selective_search_roidb
self._salt = str(uuid.uuid4())
self._comp_id = 'comp4'
# PASCAL specific config options
self.config = {
'cleanup' : True,
'use_salt' : True,
'use_diff' : False,
'matlab_eval' :