def prepare_roidb(imdb):
 sizes = [PIL.Image.open(imdb.image_path_at(i)).size for i in xrange(imdb.num_images)]
 roidb = imdb.roidb
 for i in xrange(len(imdb.image_index)):
  roidb[i]['image'] = imdb.image_path_at(i)
  roidb[i]['width'] = sizes[i][0]
  roidb[i]['height'] = sizes[i][1]
  gt_overlaps = roidb[i]['gt_overlaps'].toarray()
  max_overlaps = gt_overlaps.max(axis=1)
  max_classes = gt_overlaps.argmax(axis=1)
  roidb[i]['max_classes'] = max_classes
  roidb[i]['max_overlaps'] = max_overlaps
  zero_inds = np.where((max_overlaps == 0))[0]
  assert all((max_classes[zero_inds] == 0))
  nonzero_inds = np.where((max_overlaps > 0))[0]
  assert all((max_classes[nonzero_inds] != 0))

def prepare_roidb ( imdb ) : sizes = [ PIL . Image . open ( imdb . image_path_at ( i ) ) . size for i in xrange ( imdb . num_images ) ] roidb = imdb . roidb for i in xrange ( len ( imdb . image_index ) ) : roidb [ i ] [ 'image' ] = imdb . image_path_at ( i ) roidb [ i ] [ 'width' ] = sizes [ i ] [ 0 ] roidb [ i ] [ 'height' ] = sizes [ i ] [ 1 ] gt_overlaps = roidb [ i ] [ 'gt_overlaps' ] . toarray ( ) max_overlaps = gt_overlaps . max ( axis = 1 ) max_classes = gt_overlaps . argmax ( axis = 1 ) roidb [ i ] [ 'max_classes' ] = max_classes roidb [ i ] [ 'max_overlaps' ] = max_overlaps zero_inds = np . where ( ( max_overlaps == 0 ) ) [ 0 ] assert all ( ( max_classes [ zero_inds ] == 0 ) ) nonzero_inds = np . where ( ( max_overlaps > 0 ) ) [ 0 ] assert all ( ( max_classes [ nonzero_inds ] != 0 ) )
enrich the imdbs roidb by adding some derived quantities that are useful for training .