本文整理汇总了Python中datasets.imdb方法的典型用法代码示例。如果您正苦于以下问题:Python datasets.imdb方法的具体用法?Python datasets.imdb怎么用?Python datasets.imdb使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类datasets
的用法示例。
在下文中一共展示了datasets.imdb方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: selective_search_IJCV_roidb
# 需要导入模块: import datasets [as 别名]
# 或者: from datasets import imdb [as 别名]
def selective_search_IJCV_roidb(self):
"""
Return the database of selective search regions of interest.
Ground-truth ROIs are also included.
This function loads/saves from/to a cache file to speed up future calls.
"""
cache_file = os.path.join(self.cache_path,
'{:s}_selective_search_IJCV_top_{:d}_roidb.pkl'.
format(self.name, self.config['top_k']))
if os.path.exists(cache_file):
with open(cache_file, 'rb') as fid:
roidb = cPickle.load(fid)
print '{} ss roidb loaded from {}'.format(self.name, cache_file)
return roidb
gt_roidb = self.gt_roidb()
ss_roidb = self._load_selective_search_IJCV_roidb(gt_roidb)
roidb = datasets.imdb.merge_roidbs(gt_roidb, ss_roidb)
with open(cache_file, 'wb') as fid:
cPickle.dump(roidb, fid, cPickle.HIGHEST_PROTOCOL)
print 'wrote ss roidb to {}'.format(cache_file)
return roidb
示例2: __init__
# 需要导入模块: import datasets [as 别名]
# 或者: from datasets import imdb [as 别名]
def __init__(self, image_set, year, devkit_path=None):
datasets.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 = ('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
# PASCAL specific config options
self.config = {'cleanup' : True,
'use_salt' : True,
'use_diff' : False,
'top_k' : 2000}
assert os.path.exists(self._devkit_path), \
'VOCdevkit path does not exist: {}'.format(self._devkit_path)
assert os.path.exists(self._data_path), \
'Path does not exist: {}'.format(self._data_path)
示例3: selective_search_roidb
# 需要导入模块: import datasets [as 别名]
# 或者: from datasets import imdb [as 别名]
def selective_search_roidb(self):
"""
Return the database of selective search regions of interest.
Ground-truth ROIs are also included.
This function loads/saves from/to a cache file to speed up future calls.
"""
cache_file = os.path.join(self.cache_path,
self.name + '_selective_search_roidb.pkl')
if os.path.exists(cache_file):
with open(cache_file, 'rb') as fid:
roidb = cPickle.load(fid)
print '{} ss roidb loaded from {}'.format(self.name, cache_file)
return roidb
if int(self._year) == 2007 or self._image_set != 'test':
gt_roidb = self.gt_roidb()
# ss_roidb = self._load_selective_search_roidb(gt_roidb)
# roidb = datasets.imdb.merge_roidbs(gt_roidb, ss_roidb)
roidb = self._load_selective_search_roidb(gt_roidb)
else:
roidb = self._load_selective_search_roidb(None)
with open(cache_file, 'wb') as fid:
cPickle.dump(roidb, fid, cPickle.HIGHEST_PROTOCOL)
print 'wrote ss roidb to {}'.format(cache_file)
return roidb
示例4: __init__
# 需要导入模块: import datasets [as 别名]
# 或者: from datasets import imdb [as 别名]
def __init__(self, image_set, imagenet3d_path=None):
datasets.imdb.__init__(self, 'imagenet3d_' + image_set)
self._image_set = image_set
self._imagenet3d_path = self._get_default_path() if imagenet3d_path is None \
else imagenet3d_path
self._data_path = os.path.join(self._imagenet3d_path, 'Images')
self._classes = ('__background__', 'aeroplane', 'ashtray', 'backpack', 'basket', \
'bed', 'bench', 'bicycle', 'blackboard', 'boat', 'bookshelf', 'bottle', 'bucket', \
'bus', 'cabinet', 'calculator', 'camera', 'can', 'cap', 'car', 'cellphone', 'chair', \
'clock', 'coffee_maker', 'comb', 'computer', 'cup', 'desk_lamp', 'diningtable', \
'dishwasher', 'door', 'eraser', 'eyeglasses', 'fan', 'faucet', 'filing_cabinet', \
'fire_extinguisher', 'fish_tank', 'flashlight', 'fork', 'guitar', 'hair_dryer', \
'hammer', 'headphone', 'helmet', 'iron', 'jar', 'kettle', 'key', 'keyboard', 'knife', \
'laptop', 'lighter', 'mailbox', 'microphone', 'microwave', 'motorbike', 'mouse', \
'paintbrush', 'pan', 'pen', 'pencil', 'piano', 'pillow', 'plate', 'pot', 'printer', \
'racket', 'refrigerator', 'remote_control', 'rifle', 'road_pole', 'satellite_dish', \
'scissors', 'screwdriver', 'shoe', 'shovel', 'sign', 'skate', 'skateboard', 'slipper', \
'sofa', 'speaker', 'spoon', 'stapler', 'stove', 'suitcase', 'teapot', 'telephone', \
'toaster', 'toilet', 'toothbrush', 'train', 'trash_bin', 'trophy', 'tub', 'tvmonitor', \
'vending_machine', 'washing_machine', 'watch', 'wheelchair')
self._class_to_ind = dict(zip(self.classes, xrange(self.num_classes)))
self._image_ext = '.JPEG'
self._image_index = self._load_image_set_index()
# Default to roidb handler
if cfg.IS_RPN:
self._roidb_handler = self.gt_roidb
else:
self._roidb_handler = self.region_proposal_roidb
self.config = {'top_k': 100000}
# statistics for computing recall
self._num_boxes_all = np.zeros(self.num_classes, dtype=np.int)
self._num_boxes_covered = np.zeros(self.num_classes, dtype=np.int)
self._num_boxes_proposal = 0
assert os.path.exists(self._imagenet3d_path), \
'imagenet3d path does not exist: {}'.format(self._imagenet3d_path)
assert os.path.exists(self._data_path), \
'Path does not exist: {}'.format(self._data_path)
示例5: region_proposal_roidb
# 需要导入模块: import datasets [as 别名]
# 或者: from datasets import imdb [as 别名]
def region_proposal_roidb(self):
"""
Return the database of regions of interest.
Ground-truth ROIs are also included.
This function loads/saves from/to a cache file to speed up future calls.
"""
cache_file = os.path.join(self.cache_path,
self.name + '_' + cfg.SUBCLS_NAME + '_' + cfg.REGION_PROPOSAL + '_region_proposal_roidb.pkl')
if os.path.exists(cache_file):
with open(cache_file, 'rb') as fid:
roidb = cPickle.load(fid)
print '{} roidb loaded from {}'.format(self.name, cache_file)
return roidb
if self._image_set != 'test':
gt_roidb = self.gt_roidb()
print 'Loading region proposal network boxes...'
model = cfg.REGION_PROPOSAL
rpn_roidb = self._load_rpn_roidb(gt_roidb, model)
print 'Region proposal network boxes loaded'
roidb = datasets.imdb.merge_roidbs(rpn_roidb, gt_roidb)
else:
print 'Loading region proposal network boxes...'
model = cfg.REGION_PROPOSAL
roidb = self._load_rpn_roidb(None, model)
print 'Region proposal network boxes loaded'
print '{} region proposals per image'.format(self._num_boxes_proposal / len(self.image_index))
with open(cache_file, 'wb') as fid:
cPickle.dump(roidb, fid, cPickle.HIGHEST_PROTOCOL)
print 'wrote roidb to {}'.format(cache_file)
return roidb
示例6: selective_search_roidb
# 需要导入模块: import datasets [as 别名]
# 或者: from datasets import imdb [as 别名]
def selective_search_roidb(self):
"""
Return the database of selective search regions of interest.
Ground-truth ROIs are also included.
This function loads/saves from/to a cache file to speed up future calls.
"""
cache_file = os.path.join(self.cache_path,
self.name + '_selective_search_roidb.pkl')
if os.path.exists(cache_file):
with open(cache_file, 'rb') as fid:
roidb = cPickle.load(fid)
print '{} ss roidb loaded from {}'.format(self.name, cache_file)
return roidb
if int(self._year) == 2007 or self._image_set != 'test':
gt_roidb = self.gt_roidb()
ss_roidb = self._load_selective_search_roidb(gt_roidb)
roidb = datasets.imdb.merge_roidbs(gt_roidb, ss_roidb)
else:
roidb = self._load_selective_search_roidb(None)
with open(cache_file, 'wb') as fid:
cPickle.dump(roidb, fid, cPickle.HIGHEST_PROTOCOL)
print 'wrote ss roidb to {}'.format(cache_file)
return roidb
示例7: region_proposal_roidb
# 需要导入模块: import datasets [as 别名]
# 或者: from datasets import imdb [as 别名]
def region_proposal_roidb(self):
"""
Return the database of regions of interest.
Ground-truth ROIs are also included.
This function loads/saves from/to a cache file to speed up future calls.
"""
cache_file = os.path.join(self.cache_path,
self.name + '_' + cfg.SUBCLS_NAME + '_' + cfg.REGION_PROPOSAL + '_region_proposal_roidb.pkl')
if os.path.exists(cache_file):
with open(cache_file, 'rb') as fid:
roidb = cPickle.load(fid)
print '{} roidb loaded from {}'.format(self.name, cache_file)
return roidb
if self._image_set != 'testing':
gt_roidb = self.gt_roidb()
print 'Loading region proposal network boxes...'
if self._image_set == 'trainval':
model = cfg.REGION_PROPOSAL + '_trainval/'
else:
model = cfg.REGION_PROPOSAL + '_train/'
rpn_roidb = self._load_rpn_roidb(gt_roidb, model)
print 'Region proposal network boxes loaded'
roidb = datasets.imdb.merge_roidbs(rpn_roidb, gt_roidb)
else:
print 'Loading region proposal network boxes...'
model = cfg.REGION_PROPOSAL + '_trainval/'
roidb = self._load_rpn_roidb(None, model)
print 'Region proposal network boxes loaded'
print '{} region proposals per image'.format(self._num_boxes_proposal / len(self.image_index))
with open(cache_file, 'wb') as fid:
cPickle.dump(roidb, fid, cPickle.HIGHEST_PROTOCOL)
print 'wrote roidb to {}'.format(cache_file)
return roidb
示例8: region_proposal_roidb
# 需要导入模块: import datasets [as 别名]
# 或者: from datasets import imdb [as 别名]
def region_proposal_roidb(self):
"""
Return the database of regions of interest.
Ground-truth ROIs are also included.
This function loads/saves from/to a cache file to speed up future calls.
"""
cache_file = os.path.join(self.cache_path,
self.name + '_' + cfg.REGION_PROPOSAL + '_region_proposal_roidb.pkl')
if os.path.exists(cache_file):
with open(cache_file, 'rb') as fid:
roidb = cPickle.load(fid)
print '{} roidb loaded from {}'.format(self.name, cache_file)
return roidb
if self._image_set != 'test':
gt_roidb = self.gt_roidb()
print 'Loading region proposal network boxes...'
model = cfg.REGION_PROPOSAL
rpn_roidb = self._load_rpn_roidb(gt_roidb, model)
print 'Region proposal network boxes loaded'
roidb = datasets.imdb.merge_roidbs(rpn_roidb, gt_roidb)
else:
print 'Loading region proposal network boxes...'
model = cfg.REGION_PROPOSAL
roidb = self._load_rpn_roidb(None, model)
print 'Region proposal network boxes loaded'
print '{} region proposals per image'.format(self._num_boxes_proposal / len(self.image_index))
with open(cache_file, 'wb') as fid:
cPickle.dump(roidb, fid, cPickle.HIGHEST_PROTOCOL)
print 'wrote roidb to {}'.format(cache_file)
return roidb
示例9: __init__
# 需要导入模块: import datasets [as 别名]
# 或者: from datasets import imdb [as 别名]
def __init__(self, image_set, year, devkit_path=None):
datasets.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 = ('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, range(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' : False,
'top_k' : 2000}
assert os.path.exists(self._devkit_path), \
'VOCdevkit path does not exist: {}'.format(self._devkit_path)
assert os.path.exists(self._data_path), \
'Path does not exist: {}'.format(self._data_path)
示例10: selective_search_roidb
# 需要导入模块: import datasets [as 别名]
# 或者: from datasets import imdb [as 别名]
def selective_search_roidb(self):
"""
Return the database of selective search regions of interest.
Ground-truth ROIs are also included.
This function loads/saves from/to a cache file to speed up future calls.
"""
cache_file = os.path.join(self.cache_path,
self.name + '_selective_search_roidb.pkl')
if os.path.exists(cache_file):
with open(cache_file, 'rb') as fid:
roidb = pickle.load(fid)
print ('{} ss roidb loaded from {}'.format(self.name, cache_file))
return roidb
if int(self._year) == 2007 or self._image_set != 'test':
gt_roidb = self.gt_roidb()
# ss_roidb = self._load_selective_search_roidb(gt_roidb)
# roidb = datasets.imdb.merge_roidbs(gt_roidb, ss_roidb)
roidb = self._load_selective_search_roidb(gt_roidb)
elif int(self._year) == 2007 :
gt_roidb = self.gt_roidb()
roidb = self._load_selective_search_roidb(gt_roidb)
else:
roidb = self._load_selective_search_roidb(None)
with open(cache_file, 'wb') as fid:
pickle.dump(roidb, fid, pickle.HIGHEST_PROTOCOL)
print ('wrote ss roidb to {}'.format(cache_file))
return roidb
示例11: region_proposal_roidb
# 需要导入模块: import datasets [as 别名]
# 或者: from datasets import imdb [as 别名]
def region_proposal_roidb(self):
"""
Return the database of regions of interest.
Ground-truth ROIs are also included.
This function loads/saves from/to a cache file to speed up future calls.
"""
cache_file = os.path.join(self.cache_path,
self.name + '_' + cfg.SUBCLS_NAME + '_' + cfg.REGION_PROPOSAL + '_region_proposal_roidb.pkl')
if os.path.exists(cache_file):
with open(cache_file, 'rb') as fid:
roidb = cPickle.load(fid)
print '{} roidb loaded from {}'.format(self.name, cache_file)
return roidb
if self._image_set != 'test':
gt_roidb = self.gt_roidb()
print 'Loading region proposal network boxes...'
model = 'train/'
rpn_roidb = self._load_rpn_roidb(gt_roidb, model)
print 'Region proposal network boxes loaded'
roidb = datasets.imdb.merge_roidbs(rpn_roidb, gt_roidb)
else:
print 'Loading region proposal network boxes...'
model = 'test/'
roidb = self._load_rpn_roidb(None, model)
print 'Region proposal network boxes loaded'
print '{} region proposals per image'.format(self._num_boxes_proposal / len(self.image_index))
with open(cache_file, 'wb') as fid:
cPickle.dump(roidb, fid, cPickle.HIGHEST_PROTOCOL)
print 'wrote roidb to {}'.format(cache_file)
return roidb
示例12: __init__
# 需要导入模块: import datasets [as 别名]
# 或者: from datasets import imdb [as 别名]
def __init__(self, image_set, year, devkit_path=None):
datasets.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 = ('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' : False,
'top_k' : 2000}
assert os.path.exists(self._devkit_path), \
'VOCdevkit path does not exist: {}'.format(self._devkit_path)
assert os.path.exists(self._data_path), \
'Path does not exist: {}'.format(self._data_path)
示例13: __init__
# 需要导入模块: import datasets [as 别名]
# 或者: from datasets import imdb [as 别名]
def __init__(self, image_set, year, devkit_path=None):
datasets.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.gt_roidb
self._comp_id = 'comp4'
# PASCAL specific config options
self.config = {'cleanup' : True,
'use_salt' : True}
assert os.path.exists(self._devkit_path), \
'VOCdevkit path does not exist: {}'.format(self._devkit_path)
assert os.path.exists(self._data_path), \
'Path does not exist: {}'.format(self._data_path)
示例14: __init__
# 需要导入模块: import datasets [as 别名]
# 或者: from datasets import imdb [as 别名]
def __init__(self, image_set, year, devkit_path=None):
datasets.imdb.__init__(self, 'coco_' + year + '_' + image_set)
# COCO specific config options
self.config = {'top_k' : 2000,
'use_salt' : True,
'cleanup' : True,
'crowd_thresh' : 0.7,
'min_size' : 2}
# name, paths
self._year = year
self._image_set = image_set
self._data_path = self._get_default_path() if devkit_path is None \
else devkit_path
# load COCO API, classes, class <-> id mappings
self._COCO = COCO(self._get_ann_file())
cats = self._COCO.loadCats(self._COCO.getCatIds())
self._classes = tuple(['__background__'] + [c['name'] for c in cats])
self._class_to_ind = dict(zip(self.classes, xrange(self.num_classes)))
self._class_to_coco_cat_id = dict(zip([c['name'] for c in cats],
self._COCO.getCatIds()))
self._image_index = self._load_image_set_index()
# Default to roidb handler
self._roidb_handler = self.gt_roidb
self.competition_mode(False)
self._data_name = image_set + year # e.g., "val2014"
if self._data_name == 'test-dev2015':
self._data_name_path = 'test2015'
else:
self._data_name_path = self._data_name
示例15: __init__
# 需要导入模块: import datasets [as 别名]
# 或者: from datasets import imdb [as 别名]
def __init__(self, image_set, devkit_path, data_path):
imdb.__init__(self, image_set)
self._image_set = image_set
self._devkit_path = devkit_path
self._data_path = data_path
synsets_image = sio.loadmat(os.path.join(self._devkit_path, 'data', 'meta_det.mat'))
synsets_video = sio.loadmat(os.path.join(self._devkit_path, 'data', 'meta_vid.mat'))
self._classes_image = ('__background__',)
self._wnid_image = (0,)
self._classes = ('__background__',)
self._wnid = (0,)
for i in xrange(200):
self._classes_image = self._classes_image + (synsets_image['synsets'][0][i][2][0],)
self._wnid_image = self._wnid_image + (synsets_image['synsets'][0][i][1][0],)
for i in xrange(30):
self._classes = self._classes + (synsets_video['synsets'][0][i][2][0],)
self._wnid = self._wnid + (synsets_video['synsets'][0][i][1][0],)
self._wnid_to_ind_image = dict(zip(self._wnid_image, xrange(201)))
self._class_to_ind_image = dict(zip(self._classes_image, xrange(201)))
self._wnid_to_ind = dict(zip(self._wnid, xrange(31)))
self._class_to_ind = dict(zip(self._classes, xrange(31)))
#check for valid intersection between video and image classes
self._valid_image_flag = [0]*201
for i in range(1,201):
if self._wnid_image[i] in self._wnid_to_ind:
self._valid_image_flag[i] = 1
self._image_ext = ['.JPEG']
self._image_index = self._load_image_set_index()
# Default to roidb handler
self._roidb_handler = self.gt_roidb
# Specific config options
self.config = {'cleanup' : True,
'use_salt' : True,
'top_k' : 2000}
assert os.path.exists(self._devkit_path), 'Devkit path does not exist: {}'.format(self._devkit_path)
assert os.path.exists(self._data_path), 'Path does not exist: {}'.format(self._data_path)