Skip to content

semipy.datasets.SSLDatasetFolder

Warning

This section is in construction.

    class semipy.datasets.SSLDatasetFolder(root: str,
                                           unlabelled_folder: str,
                                           loader: Callable[[str], Any],
                                           include_labelled: bool = False,
                                           extensions: Optional[Tuple[str, ...]] = None,
                                           transform: Optional[Callable] = None,
                                           target_transform: Optional[Callable] = None,
                                           is_valid_file: Optional[Callable[[str], bool]] = None
                                           )

A class based on torchvision.datasets.DatasetFolder that allows to create an iterable dataset, as DatasetDolfer, from a directory on the user's computer but with the ability to have unlabelled items. The 'find_classes' method has been overridden in order to take into account unlabelled data, and the 'make_dataset' method has been overridden in order to support labelled data inclusion option. The directory should be as the following architecture :

directory/
        ├── class_x
           ├── xxx.jpg
           ├── xxy.jpg
           └── ...
        └── class_y
            ├── img11.jpg
            ├── img12.jpg
            └── ...
        └── unlabelled
            ├── no1.jpg
            ├── no2.jpg
            └── ...

Parameters

  • root (str) – Root directory path.
  • unlabelled_folder (str) - Name of the unlabelled items' folder.
  • loader (callable) – A function to load a sample given its path.
  • include_labelled (bool) - To include labelled items into the unlabelled set. Default: False
  • extensions (tuple[str]) – A list of allowed extensions. Both extensions and is_valid_file should not be passed. Default: None
  • transform (callable, optional) – A function/transform that takes in a sample and returns a transformed version. E.g, transforms.RandomCrop for images. Default: None
  • target_transform (callable, optional) – A function/transform that takes in the target and transforms it.
  • is_valid_file - A function that takes path of a file and check if the file is a valid file (used to check of corrupt files) both extensions and is_valid_file should not be passed. Default: None