def _load_image_labels(self):
        """
        preprocess all ground-truths

        Returns:
        ----------
        labels packed in [num_images x max_num_objects x 5] tensor
        """
        temp = []

        # load ground-truth from xml annotations
        for idx in self.image_set_index:
            label_file = self._label_path_from_index(idx)
            tree = ET.parse(label_file)
            root = tree.getroot()
            size = root.find('size')
            width = float(size.find('width').text)
            height = float(size.find('height').text)
            label = []

            for obj in root.iter('object'):
                difficult = int(obj.find('difficult').text)
                # if not self.config['use_difficult'] and difficult == 1:
                #     continue
                cls_name = obj.find('name').text
                if cls_name not in self.classes:
                    continue
                cls_id = self.classes.index(cls_name)
                xml_box = obj.find('bndbox')
                xmin = float(xml_box.find('xmin').text) / width
                ymin = float(xml_box.find('ymin').text) / height
                xmax = float(xml_box.find('xmax').text) / width
                ymax = float(xml_box.find('ymax').text) / height
                label.append([cls_id, xmin, ymin, xmax, ymax, difficult])
            temp.append(np.array(label))
        return temp
def _load_image_labels ( self ) : temp = [ ] for idx in self . image_set_index : label_file = self . _label_path_from_index ( idx ) tree = ET . parse ( label_file ) root = tree . getroot ( ) size = root . find ( 'size' ) width = float ( size . find ( 'width' ) . text ) height = float ( size . find ( 'height' ) . text ) label = [ ] for obj in root . iter ( 'object' ) : difficult = int ( obj . find ( 'difficult' ) . text ) cls_name = obj . find ( 'name' ) . text if cls_name not in self . classes : continue cls_id = self . classes . index ( cls_name ) xml_box = obj . find ( 'bndbox' ) xmin = float ( xml_box . find ( 'xmin' ) . text ) / width ymin = float ( xml_box . find ( 'ymin' ) . text ) / height xmax = float ( xml_box . find ( 'xmax' ) . text ) / width ymax = float ( xml_box . find ( 'ymax' ) . text ) / height label . append ( [ cls_id , xmin , ymin , xmax , ymax , difficult ] ) temp . append ( np . array ( label ) ) return temp
preprocess all ground-truths

        Returns:
        ----------
        labels packed in [num_images x max_num_objects x 5] tensor