peal.data.custom_datasets.Camelyon17AugmentedDataset

class peal.data.custom_datasets.Camelyon17AugmentedDataset[source]

Bases: Image2MixedDataset

Camelyon17 exported into PEAL’s imgs/ plus data.csv layout.

On first use every WILDS sample is written to <dataset_path>/imgs/<7 digit index>.png and a data.csv with the columns img, tumor, hospital is created, the hospital id acting as the confounder of the tumour label. A latent oracle is loaded from $PEAL_RUNS/camelyon17/latent_oracle/model.cpl, falling back to the latent_oracle_old_20250417_150756 run, and backs sample_to_2d_latent.

Parameters:
  • config (DataConfig) – Uses dataset_path and confounding_factors.

  • **kwargs – Forwarded to Image2MixedDataset.

Variables:

oracle (torch.nn.Module) – Attribute predictor in eval mode.

Methods

sample_to_2d_latent

Oracle attribute readout, reduced to the confounding factors.

Attributes

__init__(config, **kwargs)[source]

Export the WILDS images if missing and load the latent oracle.

Raises:

ImportError – If the images still have to be exported and the optional wilds dependency is not installed.

sample_to_2d_latent(sample, mask=None)[source]

Oracle attribute readout, reduced to the confounding factors.

Parameters:
  • sample (torch.Tensor) – Image [C, H, W] or batch [N, C, H, W]; a single image is unsqueezed for the oracle and squeezed again afterwards.

  • mask (torch.Tensor, optional) – Ignored; kept for interface compatibility.

Returns:

Oracle outputs for the attributes named in config.confounding_factors, or all outputs if that is unset.

Return type:

torch.Tensor