peal.data.custom_datasets.CelebADataset¶
- class peal.data.custom_datasets.CelebADataset[source]¶
Bases:
Image2MixedDatasetCelebA with its 40 binary face attributes.
The dataset is downloaded when
config.dataset_pathdoes 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 headerImgName, the 40 attributes andsplit- so evaluations report real attribute names instead oflabel_0 ... label_39. If$PEAL_RUNS/celeba/latent_oracle/model.cplexists it is loaded as the attribute oracle behindsample_to_2d_latent; otherwise a warning is printed and that method has no oracle to call.- Parameters:
config (
DataConfig) – Usesdataset_path,label_rel_path,delimiterandconfounding_factors.**kwargs – Forwarded to
Image2MixedDataset.
- Variables:
oracle (
torch.nn.Module) – Attribute predictor in eval mode, when the checkpoint was found.
Methods
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
OracleMetricswrapper kept inoracle_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: