load_data.py
Go to the documentation of this file.
00001 import numpy as np
00002 from dataset import *
00003 
00004 
00005 def load_gt_roidb(dataset_name, image_set_name, root_path, dataset_path, result_path=None,
00006                   flip=False):
00007     """ load ground truth roidb """
00008     imdb = eval(dataset_name)(image_set_name, root_path, dataset_path, result_path)
00009     roidb = imdb.gt_roidb()
00010     if flip:
00011         roidb = imdb.append_flipped_images(roidb)
00012     return roidb
00013 
00014 
00015 def load_proposal_roidb(dataset_name, image_set_name, root_path, dataset_path, result_path=None,
00016                         proposal='rpn', append_gt=True, flip=False):
00017     """ load proposal roidb (append_gt when training) """
00018     imdb = eval(dataset_name)(image_set_name, root_path, dataset_path, result_path)
00019 
00020     gt_roidb = imdb.gt_roidb()
00021     roidb = eval('imdb.' + proposal + '_roidb')(gt_roidb, append_gt)
00022     if flip:
00023         roidb = imdb.append_flipped_images(roidb)
00024     return roidb
00025 
00026 
00027 def merge_roidb(roidbs):
00028     """ roidb are list, concat them together """
00029     roidb = roidbs[0]
00030     for r in roidbs[1:]:
00031         roidb.extend(r)
00032     return roidb
00033 
00034 
00035 def filter_roidb(roidb, config):
00036     """ remove roidb entries without usable rois """
00037 
00038     def is_valid(entry):
00039         """ valid images have at least 1 fg or bg roi """
00040         overlaps = entry['max_overlaps']
00041         fg_inds = np.where(overlaps >= config.TRAIN.FG_THRESH)[0]
00042         bg_inds = np.where((overlaps < config.TRAIN.BG_THRESH_HI) & (overlaps >= config.TRAIN.BG_THRESH_LO))[0]
00043         valid = len(fg_inds) > 0 or len(bg_inds) > 0
00044         return valid
00045 
00046     num = len(roidb)
00047     filtered_roidb = [entry for entry in roidb if is_valid(entry)]
00048     num_after = len(filtered_roidb)
00049     print 'filtered %d roidb entries: %d -> %d' % (num - num_after, num, num_after)
00050 
00051     return filtered_roidb
00052 
00053 
00054 def load_gt_segdb(dataset_name, image_set_name, root_path, dataset_path, result_path=None,
00055                   flip=False):
00056     """ load ground truth segdb """
00057     imdb = eval(dataset_name)(image_set_name, root_path, dataset_path, result_path)
00058     segdb = imdb.gt_segdb()
00059     if flip:
00060         segdb = imdb.append_flipped_images_for_segmentation(segdb)
00061     return segdb
00062 
00063 
00064 def merge_segdb(segdbs):
00065     """ segdb are list, concat them together """
00066     segdb = segdbs[0]
00067     for r in segdbs[1:]:
00068         segdb.extend(r)
00069     return segdb


rail_object_detector
Author(s):
autogenerated on Sat Jun 8 2019 20:26:30