fl4health.datasets.skin_cancer.load_data module

construct_skin_cancer_tensor_dataset(data, transform=None, num_workers=8)[source]

Construct a TensorDataset for skin cancer data.

Parameters:
  • data (list[dict[str, Any]]) – List of dictionaries containing image paths and labels.

  • transform (Callable | None) – Transformation function to apply to the images. Defaults to None.

  • num_workers (int) – Number of workers for parallel processing. Defaults to 8.

Returns:

A TensorDataset containing the processed images and labels.

Return type:

TensorDataset

load_image(item, transform)[source]

Load and transform an image from a given item dictionary.

Parameters:
  • item (dict[str, Any]) – A dictionary containing image path and labels.

  • transform (Callable | None) – Transformation function to apply to the images.

Returns:

A tuple containing the transformed image tensor and the target label.

Return type:

tuple[torch.Tensor, int]

load_skin_cancer_data(data_dir, dataset_name, batch_size, split_percents=(0.7, 0.15, 0.15), sampler=None, train_transform=None, val_transform=None, test_transform=None, dataset_converter=None, seed=None)[source]

Load skin cancer dataset (training, validation, and test set).

Parameters:
  • data_dir (Path) – Directory containing the dataset files.

  • dataset_name (str) – Name of the dataset to load.

  • batch_size (int) – Batch size for the DataLoader.

  • split_percents (tuple[float, float, float]) – Percentages for splitting the data into train, val, and test sets.

  • sampler (LabelBasedSampler | None) – Sampler for the dataset. Defaults to None.

  • train_transform (Callable | None) – Transformations to apply to the training data. Defaults to None.

  • val_transform (Callable | None) – Transformations to apply to the validation data. Defaults to None.

  • test_transform (Callable | None) – Transformations to apply to the test data. Defaults to None.

  • dataset_converter (DatasetConverter | None) – Converter to apply to the dataset. Defaults to None.

  • seed (int | None) – Random seed for shuffling data. Defaults to None.

Returns:

DataLoaders for the training, validation, and test sets, and a dictionary with the number of examples in each set.

Return type:

tuple[DataLoader, DataLoader, DataLoader, dict[str, int]]