def _load_items(self, subset):

    def _get_label(path):
        label_name = path.split('/')[0]
        label = None
        if (label_name != VggFace2Path.IMAGES_DIR_NO_LABEL):
            label = self._categories[AnnotationType.label].find(label_name)[0]
        return label
    items = {}
    image_dir = osp.join(self._dataset_dir, subset)
    if osp.isdir(image_dir):
        images = {osp.splitext(osp.relpath(p, image_dir))[0].replace('\\', '/'): p for p in find_images(image_dir, recursive=True)}
    else:
        images = {}
    landmarks_path = osp.join(self._dataset_dir, VggFace2Path.ANNOTATION_DIR, ((VggFace2Path.LANDMARKS_FILE + subset) + '.csv'))
    if osp.isfile(landmarks_path):
        with open(landmarks_path, encoding='utf-8') as content:
            landmarks_table = list(csv.DictReader(content))
        for row in landmarks_table:
            item_id = row['NAME_ID']
            label = None
            if ('/' in item_id):
                label = _get_label(item_id)
            if (item_id not in items):
                items[item_id] = DatasetItem(id=item_id, subset=subset, image=images.get(row['NAME_ID']))
            annotations = items[item_id].annotations
            if [a for a in annotations if (a.type == AnnotationType.points)]:
                raise Exception(('Item %s: an image can have only one set of landmarks' % item_id))
            if ((len([p for p in row if (row[p] == '')]) == 0) and (len(row) == 11)):
                annotations.append(Points([float(row[p]) for p in row if (p != 'NAME_ID')], label=label))
            elif (label is not None):
                annotations.append(Label(label=label))
    bboxes_path = osp.join(self._dataset_dir, VggFace2Path.ANNOTATION_DIR, ((VggFace2Path.BBOXES_FILE + subset) + '.csv'))
    if osp.isfile(bboxes_path):
        with open(bboxes_path, encoding='utf-8') as content:
            bboxes_table = list(csv.DictReader(content))
        for row in bboxes_table:
            item_id = row['NAME_ID']
            label = None
            if ('/' in item_id):
                label = _get_label(item_id)
            if (item_id not in items):
                items[item_id] = DatasetItem(id=item_id, subset=subset, image=images.get(row['NAME_ID']))
            annotations = items[item_id].annotations
            if [a for a in annotations if (a.type == AnnotationType.bbox)]:
                raise Exception(('Item %s: an image can have only one bbox' % item_id))
            if ((len([p for p in row if (row[p] == '')]) == 0) and (len(row) == 5)):
                annotations.append(Bbox(float(row['X']), float(row['Y']), float(row['W']), float(row['H']), label=label))
    return items
def _load_items(self, subset):

    def _get_label(path):
        label_name = path.split('/')[0]
        label = None
        if (label_name != VggFace2Path.IMAGES_DIR_NO_LABEL):
            label = self._categories[AnnotationType.label].find(label_name)[0]
        return label
    items = {}
    image_dir = osp.join(self._dataset_dir, subset)
    if osp.isdir(image_dir):
        images = {osp.splitext(osp.relpath(p, image_dir))[0].replace('\\', '/'): p for p in find_images(image_dir, recursive=True)}
    else:
        images = {}
    landmarks_path = osp.join(self._dataset_dir, VggFace2Path.ANNOTATION_DIR, ((VggFace2Path.LANDMARKS_FILE + subset) + '.csv'))
    if osp.isfile(landmarks_path):
        with open(landmarks_path, encoding='utf-8') as content:
            landmarks_table = list(csv.DictReader(content))
        for row in landmarks_table:
            item_id = row['NAME_ID']
            label = None
            if ('/' in item_id):
                label = _get_label(item_id)
            if (item_id not in items):
                items[item_id] = DatasetItem(id=item_id, subset=subset, image=images.get(row['NAME_ID']))
            annotations = items[item_id].annotations
            if [a for a in annotations if (a.type == AnnotationType.points)]:
                raise Exception(('Item %s: an image can have only one set of landmarks' % item_id))
            if ((len([p for p in row if (row[p] == )]) == 0) and (len(row) == 11)):
                annotations.append(Points([float(row[p]) for p in row if (p != 'NAME_ID')], label=label))
            elif (label is not None):
                annotations.append(Label(label=label))
    bboxes_path = osp.join(self._dataset_dir, VggFace2Path.ANNOTATION_DIR, ((VggFace2Path.BBOXES_FILE + subset) + '.csv'))
    if osp.isfile(bboxes_path):
        with open(bboxes_path, encoding='utf-8') as content:
            bboxes_table = list(csv.DictReader(content))
        for row in bboxes_table:
            item_id = row['NAME_ID']
            label = None
            if ('/' in item_id):
                label = _get_label(item_id)
            if (item_id not in items):
                items[item_id] = DatasetItem(id=item_id, subset=subset, image=images.get(row['NAME_ID']))
            annotations = items[item_id].annotations
            if [a for a in annotations if (a.type == AnnotationType.bbox)]:
                raise Exception(('Item %s: an image can have only one bbox' % item_id))
            if ((len([p for p in row if (row[p] == )]) == 0) and (len(row) == 5)):
                annotations.append(Bbox(float(row['X']), float(row['Y']), float(row['W']), float(row['H']), label=label))
    return items