negedng's picture
Update README.md
6a19f6d verified
metadata
task_categories:
  - image-classification
language:
  - en
pretty_name: >-
  CelebA dataset mirrored from torchvision: identity, bbox, landmarks,
  attributes (0,1)
size_categories:
  - 100K<n<1M

CelebA Dataset from Torchvision

CelebA dataset: https://mmlab.ie.cuhk.edu.hk/projects/CelebA.html

Torchvision documentation: https://docs.pytorch.org/vision/main/generated/torchvision.datasets.CelebA.html

Features

Features include identity (id of the celeb in the image), bbox, landmarks and the 40 binary attributes

Attributes are (0,1) as in the torchvision dataset, not (-1,1) as in the original format

Script generation

traindataset = torchvision.datasets.CelebA(
    root='./datasets', split='train', download=True, transform=None, target_type=['attr', 'identity','bbox','landmarks']
)
with open("celeba/list_attr_celeba.txt", 'r') as file:
    lines = file.readlines()
# Get the second line (index 1) and split by spaces
attr_names = lines[1].strip().split()

data = []
for i in range(len(traindataset)):
    img, label = traindataset[i]
    attr, identity,bbox,landmarks = label
    sample_dict = {
        "image": img,
        "identity": identity,
        "bbox":bbox,
        "landmarks":landmarks
    }
    for k,v in zip(attr_names,attr):
        sample_dict[k] = v
    data.append(sample_dict)
hf_dataset = HFDataset.from_list(data)

hf_dataset.save_to_disk(path)

Steps to make the saved arrow formats compatible with HF Hub DataViewer:

  1. Save a dataset_info.json from the generated files and place in the root folder of the repo.
  2. Remove generated files that are not the arrow format.
  3. Place all arrow files into the same folder, rename to start with the name of the split.

Citation information

@inproceedings{liu2015faceattributes,
  title = {Deep Learning Face Attributes in the Wild},
  author = {Liu, Ziwei and Luo, Ping and Wang, Xiaogang and Tang, Xiaoou},
  booktitle = {Proceedings of International Conference on Computer Vision (ICCV)},
  month = {December},
  year = {2015} 
}

License

Follow original license from https://mmlab.ie.cuhk.edu.hk/projects/CelebA.html