avalanche.benchmarks.generators.paths_benchmark

avalanche.benchmarks.generators.paths_benchmark(train_lists_of_files: Sequence[Sequence[Union[Tuple[Union[str, pathlib.Path], int], Tuple[Union[str, pathlib.Path], int, Sequence]]]], test_lists_of_files: Union[Sequence[Union[Tuple[Union[str, pathlib.Path], int], Tuple[Union[str, pathlib.Path], int, Sequence]]], Sequence[Sequence[Union[Tuple[Union[str, pathlib.Path], int], Tuple[Union[str, pathlib.Path], int, Sequence]]]]], *, other_streams_lists_of_files: Optional[Dict[str, Sequence[Sequence[Union[Tuple[Union[str, pathlib.Path], int], Tuple[Union[str, pathlib.Path], int, Sequence]]]]]] = None, task_labels: Sequence[int], complete_test_set_only: bool = False, train_transform=None, train_target_transform=None, eval_transform=None, eval_target_transform=None, other_streams_transforms: Optional[Dict[str, Tuple[Any, Any]]] = None, dataset_type: avalanche.benchmarks.utils.avalanche_dataset.AvalancheDatasetType = AvalancheDatasetType.UNDEFINED) avalanche.benchmarks.scenarios.classification_scenario.GenericCLScenario

Creates a benchmark instance given a sequence of lists of files. A separate dataset will be created for each list. Each of those datasets will be considered a separate experience.

This is very similar to create_generic_benchmark_from_filelists(), with the main difference being that create_generic_benchmark_from_filelists() accepts, for each experience, a file list formatted in Caffe-style. On the contrary, this accepts a list of tuples where each tuple contains two elements: the full path to the pattern and its label. Optionally, the tuple may contain a third element describing the bounding box of the element to crop. This last bounding box may be useful when trying to extract the part of the image depicting the desired element.

Apart from that, the same limitations of create_generic_benchmark_from_filelists() regarding task labels apply.

The label of each pattern doesn’t have to be an int. Also, a dataset type can be defined.

Parameters
  • train_lists_of_files – A list of lists. Each list describes the paths and labels of patterns to include in that training experience, as tuples. Each tuple must contain two elements: the full path to the pattern and its class label. Optionally, the tuple may contain a third element describing the bounding box to use for cropping (top, left, height, width).

  • test_lists_of_files – A list of lists. Each list describes the paths and labels of patterns to include in that test experience, as tuples. Each tuple must contain two elements: the full path to the pattern and its class label. Optionally, the tuple may contain a third element describing the bounding box to use for cropping (top, left, height, width).

  • other_streams_lists_of_files – A dictionary describing the content of custom streams. Keys must be valid stream names (letters and numbers, not starting with a number) while the value follow the same structure of train_lists_of_files and test_lists_of_files parameters. If this dictionary contains the definition for “train” or “test” streams then those definition will override the train_lists_of_files and test_lists_of_files parameters.

  • task_labels – A list of task labels. Must contain at least a value for each experience. Each value describes the task label that will be applied to all patterns of a certain experience. For more info on that, see the function description.

  • complete_test_set_only – If True, only the complete test set will be returned by the benchmark. This means that the test_list_of_files parameter must define a single experience (the complete test set). Defaults to False.

  • train_transform – The transformation to apply to the training data, e.g. a random crop, a normalization or a concatenation of different transformations (see torchvision.transform documentation for a comprehensive list of possible transformations). Defaults to None.

  • train_target_transform – The transformation to apply to training patterns targets. Defaults to None.

  • eval_transform – The transformation to apply to the test data, e.g. a random crop, a normalization or a concatenation of different transformations (see torchvision.transform documentation for a comprehensive list of possible transformations). Defaults to None.

  • eval_target_transform – The transformation to apply to test patterns targets. Defaults to None.

  • other_streams_transforms – Transformations to apply to custom streams. If no transformations are defined for a custom stream, then “train” transformations will be used. This parameter must be a dictionary mapping stream names to transformations. The transformations must be a two elements tuple where the first element defines the X transformation while the second element is the Y transformation. Those elements can be None. If this dictionary contains the transformations for “train” or “test” streams then those transformations will override the train_transform, train_target_transform, eval_transform and eval_target_transform parameters.

  • dataset_type – The type of the dataset. Defaults to UNDEFINED.

Returns

A GenericCLScenario instance.