(self, root, transform=None, target_transform=None, is_test=False, keep_difficult=False, label_file=None)
Dataset for VOC data.
        Args:
            root: the root of the VOC2007 or VOC2012 dataset, the directory contains the following sub-directories:
                Annotations, ImageSets, JPEGImages, SegmentationClass, SegmentationObject.
Dataset for VOC data.
        Args:
            root: the root of the VOC2007 or VOC2012 dataset, the directory contains the following sub-directories:
                Annotations, ImageSets, JPEGImages, SegmentationClass, SegmentationObject.
Dataset for VOC data . Args : root : the root of the VOC2007 or VOC2012 dataset the directory contains the following sub - directories : Annotations ImageSets JPEGImages SegmentationClass SegmentationObject .
def __init__(self, root, transform=None, target_transform=None, is_test=False, keep_difficult=False, label_file=None):
        """Dataset for VOC data.
        Args:
            root: the root of the VOC2007 or VOC2012 dataset, the directory contains the following sub-directories:
                Annotations, ImageSets, JPEGImages, SegmentationClass, SegmentationObject.
        """
        self.root = pathlib.Path(root)
        self.transform = transform
        self.target_transform = target_transform
        if is_test:
            image_sets_file = self.root / "ImageSets/Main/test.txt"
        else:
            image_sets_file = self.root / "ImageSets/Main/trainval.txt"
        self.ids = VOCDataset._read_image_ids(image_sets_file)
        self.keep_difficult = keep_difficult

        # if the labels file exists, read in the class names
        label_file_name = self.root / "labels.txt"

        if os.path.isfile(label_file_name):
            class_string = ""
            with open(label_file_name, 'r') as infile:
                for line in infile:
                    class_string += line.rstrip()

            # classes should be a comma separated list

            classes = class_string.split(',')
            # prepend BACKGROUND as first class
            classes.insert(0, 'BACKGROUND')
            classes = [elem.replace(" ", "") for elem in classes]
            self.class_names = tuple(classes)
            logging.info("VOC Labels read from file: " + str(self.class_names))

        else:
            logging.info("No labels file, using default VOC classes.")
            self.class_names = ('BACKGROUND',
                                'face')

        self.class_dict = {class_name: i for i, class_name in enumerate(self.class_names)}
def __init__ ( self , root , transform = None , target_transform = None , is_test = False , keep_difficult = False , label_file = None ) : self . root = pathlib . Path ( root ) self . transform = transform self . target_transform = target_transform if is_test : image_sets_file = self . root / "ImageSets/Main/test.txt" else : image_sets_file = self . root / "ImageSets/Main/trainval.txt" self . ids = VOCDataset . _read_image_ids ( image_sets_file ) self . keep_difficult = keep_difficult # if the labels file exists, read in the class names label_file_name = self . root / "labels.txt" if os . path . isfile ( label_file_name ) : class_string = "" with open ( label_file_name , 'r' ) as infile : for line in infile : class_string += line . rstrip ( ) # classes should be a comma separated list classes = class_string . split ( ',' ) # prepend BACKGROUND as first class classes . insert ( 0 , 'BACKGROUND' ) classes = [ elem . replace ( " " , "" ) for elem in classes ] self . class_names = tuple ( classes ) logging . info ( "VOC Labels read from file: " + str ( self . class_names ) ) else : logging . info ( "No labels file, using default VOC classes." ) self . class_names = ( 'BACKGROUND' , 'face' ) self . class_dict = { class_name : i for i , class_name in enumerate ( self . class_names ) }