peal.data.custom_datasets.CelebADataset

class peal.data.custom_datasets.CelebADataset[source]

Bases: Image2MixedDataset

CelebA with its 40 binary face attributes.

The dataset is downloaded when config.dataset_path does not exist. After loading, the attribute names are read from the label csv - whose first line is a bare sample count and whose second line is the header ImgName, the 40 attributes and split - so evaluations report real attribute names instead of label_0 ... label_39. If $PEAL_RUNS/celeba/latent_oracle/model.cpl exists it is loaded as the attribute oracle behind sample_to_2d_latent; otherwise a warning is printed and that method has no oracle to call.

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

  • **kwargs – Forwarded to Image2MixedDataset.

Variables:
  • attributes (list of str) – The 40 CelebA attribute names.

  • oracle (torch.nn.Module) – Attribute predictor in eval mode, when the checkpoint was found.

Methods

sample_to_2d_latent

Oracle attribute readout, reduced to the confounding factors.

Attributes

__init__(config, **kwargs)[source]

Download CelebA if missing, read the attribute names and load the oracle.

sample_to_2d_latent(sample, mask=None)[source]

Oracle attribute readout, reduced to the confounding factors.

Works both with the loaded PEAL oracle and with the ACE OracleMetrics wrapper kept in oracle_metric.

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 40 outputs if that is unset.

Return type:

torch.Tensor