zl程序教程

您现在的位置是:首页 >  数据库

当前栏目

CelebA Datasets——Readme

2023-03-07 09:11:35 时间

今天介绍一个在GAN中经常用的人脸数据集:

CelebFaces Attributes (CelebA) Dataset

来自于kaggle上的数据集介绍:

A popular component of computer vision and deep learning revolves around identifying faces for various applications from logging into your phone with your face or searching through surveillance images for a particular suspect. This dataset is great for training and testing models for face detection, particularly for recognising facial attributes such as finding people with brown hair, are smiling, or wearing glasses. Images cover large pose variations, background clutter, diverse people, supported by a large quantity of images and rich annotations. This data was originally collected by researchers at MMLAB, The Chinese University of Hong Kong (specific reference in Acknowledgment section).

Overall
  202,599 number of face images of various celebrities
  10,177 unique identities, but names of identities are not given
  40 binary attribute annotations per image
  5 landmark locations

下载下来的数据集是这样的:

这是数据集:

下面使用代码加载数据集,并且读取25张人脸

# load and plot faces
from os import listdir
from numpy import asarray
from PIL import Image
from matplotlib import pyplot

# load an image as an rgb numpy array
def load_image(filename):
  # load image from file
  image = Image.open(filename)
  # convert to RGB, if needed
  image = image.convert('RGB')
  # convert to array
  pixels = asarray(image)
  return pixels

# load images and extract faces for all images in a directory
def load_faces(directory, n_faces):
  faces = list()
  # enumerate files
  for filename in listdir(directory):
    # load the image
    pixels = load_image(directory + filename)
    # store
    faces.append(pixels)
    # stop once we have enough
    if len(faces) >= n_faces:
      break
  return asarray(faces)

# plot a list of loaded faces
def plot_faces(faces, n):
  for i in range(n * n):
    # define subplot
    pyplot.subplot(n, n, 1 + i)
    # turn off axis
    pyplot.axis('off')
    # plot raw pixel data
    pyplot.imshow(faces[i])
  pyplot.show()

# directory that contains all images
directory = r'your path'
# load and extract all faces
faces = load_faces(directory, 25)
print('Loaded: ', faces.shape)
# plot faces
plot_faces(faces, 5)

下面是celebA数据集官网的同意协议:

Agreement
  The CelebA dataset is available for non-commercial research purposes only.
  All images of the CelebA dataset are obtained from the Internet which are not property of MMLAB, The Chinese University of Hong Kong. The MMLAB is not responsible for the content nor the meaning of these images.
  You agree not to reproduce, duplicate, copy, sell, trade, resell or exploit for any commercial purposes, any portion of the images and any portion of derived data.
  You agree not to further copy, publish or distribute any portion of the CelebA dataset. Except, for internal use at a single site within the same organization it is allowed to make copies of the dataset.
  The MMLAB reserves the right to terminate your access to the CelebA dataset at any time.
  The face identities are released upon request for research purposes only. Please contact us for details.