peal.training.trainers.distill_1ofn_dataset

peal.training.trainers.distill_1ofn_dataset(predictor_distillation, base_path, predictor, predictor_datasets)[source]

Relabel Image2ClassDataset (folder-per-class) data with a predictor.

Every sample of the first two datasets is classified and saved as <base_path>/dataset_<i>/<predicted class>/<idx>.png (skipped when the directory exists), then reloaded as a dataset without confounder information; index 0 is the train split, index 1 the validation split. Samples with more than three channels, or that fail to load or save, are skipped with a printed message.

Parameters:
  • predictor_distillation (str, dict or PredictorConfig) – Config of the student.

  • base_path (str) – Directory the relabelled image folders are written to.

  • predictor (torch.nn.Module) – Teacher that produces the labels.

  • predictor_datasets (list) – Two datasets, dataloader mixers or weighted dataloader lists.

Returns:

The two relabelled datasets.

Return type:

list