parameters: (index, pascal_root)
return_statement: return {'boxes': boxes,
              'gt_classes': gt_classes,
              'gt_overlaps': overlaps,
              'flipped': False,
              'index': index}
docstring: This code is borrowed from Ross Girshick's FAST-RCNN code
      (https://github.com/rbgirshick/fast-rcnn).
      It parses the PASCAL .xml metadata files.
      See publication for further details: (http://arxiv.org/abs/1504.08083).
  
      Thanks Ross!
docstring_summary: This code is borrowed from Ross Girshick's FAST-RCNN code
      (https://github.com/rbgirshick/fast-rcnn).
      It parses the PASCAL .xml metadata files.
      See publication for further details: (http://arxiv.org/abs/1504.08083).
docstring_tokens: This code is borrowed from Ross Girshick s FAST - RCNN code ( https : // github . com / rbgirshick / fast - rcnn ) . It parses the PASCAL . xml metadata files . See publication for further details : ( http : // arxiv . org / abs / 1504 . 08083 ) .
function: def load_pascal_annotation(index, pascal_root):
      """
      This code is borrowed from Ross Girshick's FAST-RCNN code
      (https://github.com/rbgirshick/fast-rcnn).
      It parses the PASCAL .xml metadata files.
      See publication for further details: (http://arxiv.org/abs/1504.08083).
  
      Thanks Ross!
  
      """
      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')
      class_to_ind = dict(zip(classes, xrange(21)))
  
      filename = osp.join(pascal_root, 'Annotations', index + '.xml')
      # print 'Loading: {}'.format(filename)
  
      def get_data_from_tag(node, tag):
          return node.getElementsByTagName(tag)[0].childNodes[0].data
  
      with open(filename) as f:
          data = minidom.parseString(f.read())
  
      objs = data.getElementsByTagName('object')
      num_objs = len(objs)
  
      boxes = np.zeros((num_objs, 4), dtype=np.uint16)
      gt_classes = np.zeros((num_objs), dtype=np.int32)
      overlaps = np.zeros((num_objs, 21), dtype=np.float32)
  
      # Load object bounding boxes into a data frame.
      for ix, obj in enumerate(objs):
          # Make pixel indexes 0-based
          x1 = float(get_data_from_tag(obj, 'xmin')) - 1
          y1 = float(get_data_from_tag(obj, 'ymin')) - 1
          x2 = float(get_data_from_tag(obj, 'xmax')) - 1
          y2 = float(get_data_from_tag(obj, 'ymax')) - 1
          cls = class_to_ind[
              str(get_data_from_tag(obj, "name")).lower().strip()]
          boxes[ix, :] = [x1, y1, x2, y2]
          gt_classes[ix] = cls
          overlaps[ix, cls] = 1.0
  
      overlaps = scipy.sparse.csr_matrix(overlaps)
  
      return {'boxes': boxes,
              'gt_classes': gt_classes,
              'gt_overlaps': overlaps,
              'flipped': False,
              'index': index}
function_tokens: def load_pascal_annotation ( index , pascal_root ) : 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' ) class_to_ind = dict ( zip ( classes , xrange ( 21 ) ) ) filename = osp . join ( pascal_root , 'Annotations' , index + '.xml' ) # print 'Loading: {}'.format(filename) def get_data_from_tag ( node , tag ) : return node . getElementsByTagName ( tag ) [ 0 ] . childNodes [ 0 ] . data with open ( filename ) as f : data = minidom . parseString ( f . read ( ) ) objs = data . getElementsByTagName ( 'object' ) num_objs = len ( objs ) boxes = np . zeros ( ( num_objs , 4 ) , dtype = np . uint16 ) gt_classes = np . zeros ( ( num_objs ) , dtype = np . int32 ) overlaps = np . zeros ( ( num_objs , 21 ) , dtype = np . float32 ) # Load object bounding boxes into a data frame. for ix , obj in enumerate ( objs ) : # Make pixel indexes 0-based x1 = float ( get_data_from_tag ( obj , 'xmin' ) ) - 1 y1 = float ( get_data_from_tag ( obj , 'ymin' ) ) - 1 x2 = float ( get_data_from_tag ( obj , 'xmax' ) ) - 1 y2 = float ( get_data_from_tag ( obj , 'ymax' ) ) - 1 cls = class_to_ind [ str ( get_data_from_tag ( obj , "name" ) ) . lower ( ) . strip ( ) ] boxes [ ix , : ] = [ x1 , y1 , x2 , y2 ] gt_classes [ ix ] = cls overlaps [ ix , cls ] = 1.0 overlaps = scipy . sparse . csr_matrix ( overlaps ) return { 'boxes' : boxes , 'gt_classes' : gt_classes , 'gt_overlaps' : overlaps , 'flipped' : False , 'index' : index }