'Load image and bounding boxes info from XML file in the PASCAL VOC
format.'

def _load_pascal_annotation(self, index):

    filename = os.path.join(self._data_path, 'Annotations', (index + '.xml'))
    tree = ET.parse(filename)
    objs = tree.findall('object')
    if (not self.config['use_diff']):
        non_diff_objs = [obj for obj in objs if (int(obj.find('difficult').text) == 0)]
        objs = non_diff_objs
    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, self.num_classes), dtype=np.float32)
    seg_areas = np.zeros(num_objs, dtype=np.float32)
    for (ix, obj) in enumerate(objs):
        bbox = obj.find('bndbox')
        x1 = (float(bbox.find('xmin').text) - 1)
        y1 = (float(bbox.find('ymin').text) - 1)
        x2 = (float(bbox.find('xmax').text) - 1)
        y2 = (float(bbox.find('ymax').text) - 1)
        cls = self._class_to_ind[obj.find('name').text.lower().strip()]
        boxes[ix, :] = [x1, y1, x2, y2]
        gt_classes[ix] = cls
        overlaps[(ix, cls)] = 1.0
        seg_areas[ix] = (((x2 - x1) + 1) * ((y2 - y1) + 1))
    overlaps = scipy.sparse.csr_matrix(overlaps)
    return {'boxes': boxes, 'gt_classes': gt_classes, 'gt_overlaps': overlaps, 'flipped': False, 'seg_areas': seg_areas}
