数据集FFHQ和LSUN介绍

数据集FFHQ和LSUN介绍

  • 一、FFHQ
    • 1、介绍
    • 2、获取方法
  • 二、LSUN
    • 1、介绍
    • 2、获取方法
  • Reference:

一、FFHQ

1、介绍

FFHQ全称Flickr-Faces-High-Quality(Flickr-Faces-HQ),最初是作为生成式对抗网络(GAN)的基准创建的,也用于StyleGAN的训练数据集中,并由英伟达于2019年开源。
数据集FFHQ和LSUN介绍_第1张图片

文章来自:A Style-Based Generator Architecture for Generative Adversarial NetworksCVPR_2019
title={A style-based generator architecture for generative adversarial networks},
author={Karras, Tero and Laine, Samuli and Aila, Timo},
booktitle={Proceedings of the IEEE/CVF conference on computer vision and pattern recognition},
pages={4401–4410},
year={2019}
项目链接:https://github.com/NVlabs/ffhq-dataset

Flickr-Faces-HQ (FFHQ)其由 70,000 张分辨率为 1024×1024 的高质量 PNG 图像组成,在年龄、种族和图像背景方面包含相当大的差异。它对眼镜、太阳镜、帽子等配饰也有很好的覆盖。图像是从 Flickr 上爬取的,因此继承了该网站的所有偏见,并使用 dlib 自动对齐和裁剪。仅收集许可许可下的图像。使用各种自动过滤器来修剪集合,最后使用 Amazon Mechanical Turk 去除偶尔出现的雕像、绘画或照片。(即移除了一些非真实人脸)

因此该数据集也是可以用于开发一些人脸属性分类或者人脸语义分割模型的。

FFHQ高清人脸数据集主要存储于Google Drive云盘,官方给出的存储结构如下图所示:
数据集FFHQ和LSUN介绍_第2张图片
总大小2.56TB,也着实吓人,但如果不需要原始图像仅需要已对齐裁剪的高清人脸,那么images1024x1024文件夹下的数据就是我们关注的对象,其大小为89.1GB还是可以接受的。另外,官方还细心的为我们准备了StyleGAN和StyleGAN2不同分辨率下的tfrecords训练数据集。

整个数据集的统计分析情况如下图所示:
数据集FFHQ和LSUN介绍_第3张图片
该饼图包含了数据划分比例、所有图像遵循的协议比例以及人脸所属的国家分布情况。官方解释说,70000张人脸图像,在StyleGAN论文里,有划分60000张用于训练,剩余的10000张用于验证,但在实际应用时,他们却是使用了所有的数据集用于训练的。在制作的数据集里是没有重复的人脸图像的,但在in-the-wild目录下可能存在从同一张图像里获取不同人脸的情况出现。

发现一个链接包含很多机器学习的数据集有需要的可以收藏一下:https://datasets.activeloop.ai/docs/ml/datasets/ffhq-dataset/

2、获取方法

您可以直接从 Google Drive 获取数据或使用提供的下载脚本。该脚本通过自动下载所有请求的文件、验证它们的校验和、在出错时重试每个文件数次以及使用多个并发连接来最大化带宽,使事情变得相当容易。该脚本易用、自纠错、多线程、可利用最大带宽,方便用户自己进行原始图像下载,脚本工具解释如下:

> python download_ffhq.py -h
usage: download_ffhq.py [-h] [-j] [-s] [-i] [-t] [-w] [-r] [-a]
                        [--num_threads NUM] [--status_delay SEC]
                        [--timing_window LEN] [--chunk_size KB]
                        [--num_attempts NUM]

Download Flickr-Face-HQ (FFHQ) dataset to current working directory.

optional arguments:
  -h, --help            show this help message and exit
  -j, --json            download metadata as JSON (254 MB)
  -s, --stats           print statistics about the dataset
  -i, --images          download 1024x1024 images as PNG (89.1 GB)
  -t, --thumbs          download 128x128 thumbnails as PNG (1.95 GB)
  -w, --wilds           download in-the-wild images as PNG (955 GB)
  -r, --tfrecords       download multi-resolution TFRecords (273 GB)
  -a, --align           recreate 1024x1024 images from in-the-wild images
  --num_threads NUM     number of concurrent download threads (default: 32)
  --status_delay SEC    time between download status prints (default: 0.2)
  --timing_window LEN   samples for estimating download eta (default: 50)
  --chunk_size KB       chunk size for each download thread (default: 128)
  --num_attempts NUM    number of download attempts per file (default: 10)
  --random-shift SHIFT  standard deviation of random crop rectangle jitter
  --retry-crops         retry random shift if crop rectangle falls outside image (up to 1000
                        times)
  --no-rotation         keep the original orientation of images
  --no-padding          do not apply blur-padding outside and near the image borders
  --source-dir DIR      where to find already downloaded FFHQ source data

脚本工具可下载图像链接后再下载图像,然后自动对齐裁剪人脸,也可以选择获取统计分析报表、已对齐裁剪了的1024x1024高清人脸图像、相应的128x128预览图像、原始图像、已封装了包含不同分辨率的tfrecords文件等内容,也可以设置下载线程数、人脸对齐等操作。

如果想获取图像链接后再进行数据下载,那么脚本运行命令也非常简洁:

> python ..\download_ffhq.py --json --images
Downloading JSON metadata...
\ 100.00% done  2/2 files  0.25/0.25 GB   43.21 MB/s  ETA: done
Parsing JSON metadata...
Downloading 70000 files...
| 100.00% done  70001/70001 files  89.19 GB/89.19 GB  59.87 MB/s  ETA: done

该脚本还用作我们用于对齐和裁剪图像的自动化方案的参考实现。使用 python download_ffhq.py --wilds 下载野外图像后,您可以运行 python download_ffhq.py --align 以使用元数据中包含的面部标志位置重现对齐的 1024×1024 图像的精确副本.

除了下载脚本外,官方还提供了一个包含详细元素的json文件ffhq-dataset-v2.json,该文件内容示例如下所示:

{
  "0": {                                                 # Image index
    "category": "training",                              # Training or validation
    "metadata": {                                        # Info about the original Flickr photo:
      "photo_url": "https://www.flickr.com/photos/...",  # - Flickr URL
      "photo_title": "DSCF0899.JPG",                     # - File name
      "author": "Jeremy Frumkin",                        # - Author
      "country": "",                                     # - Country where the photo was taken
      "license": "Attribution-NonCommercial License",    # - License name
      "license_url": "https://creativecommons.org/...",  # - License detail URL
      "date_uploaded": "2007-08-16",                     # - Date when the photo was uploaded to Flickr
      "date_crawled": "2018-10-10"                       # - Date when the photo was crawled from Flickr
    },
    "image": {                                           # Info about the aligned 1024x1024 image:
      "file_url": "https://drive.google.com/...",        # - Google Drive URL
      "file_path": "images1024x1024/00000/00000.png",    # - Google Drive path
      "file_size": 1488194,                              # - Size of the PNG file in bytes
      "file_md5": "ddeaeea6ce59569643715759d537fd1b",    # - MD5 checksum of the PNG file
      "pixel_size": [1024, 1024],                        # - Image dimensions
      "pixel_md5": "47238b44dfb87644460cbdcc4607e289",   # - MD5 checksum of the raw pixel data
      "face_landmarks": [...]                            # - 68 face landmarks reported by dlib
    },
    "thumbnail": {                                       # Info about the 128x128 thumbnail:
      "file_url": "https://drive.google.com/...",        # - Google Drive URL
      "file_path": "thumbnails128x128/00000/00000.png",  # - Google Drive path
      "file_size": 29050,                                # - Size of the PNG file in bytes
      "file_md5": "bd3e40b2ba20f76b55dc282907b89cd1",    # - MD5 checksum of the PNG file
      "pixel_size": [128, 128],                          # - Image dimensions
      "pixel_md5": "38d7e93eb9a796d0e65f8c64de8ba161"    # - MD5 checksum of the raw pixel data
    },
    "in_the_wild": {                                     # Info about the in-the-wild image:
      "file_url": "https://drive.google.com/...",        # - Google Drive URL
      "file_path": "in-the-wild-images/00000/00000.png", # - Google Drive path
      "file_size": 3991569,                              # - Size of the PNG file in bytes
      "file_md5": "1dc0287e73e485efb0516a80ce9d42b4",    # - MD5 checksum of the PNG file
      "pixel_size": [2016, 1512],                        # - Image dimensions
      "pixel_md5": "86b3470c42e33235d76b979161fb2327",   # - MD5 checksum of the raw pixel data
      "face_rect": [667, 410, 1438, 1181],               # - Axis-aligned rectangle of the face region
      "face_landmarks": [...],                           # - 68 face landmarks reported by dlib
      "face_quad": [...]                                 # - Aligned quad of the face region
    }
  },
  ...
}

二、LSUN

1、介绍

文章地址:LSUN: Construction of a Large-Scale Image Dataset
using Deep Learning with Humans in the Loop
项目地址:https://github.com/fyu/lsun

title={Lsun: Construction of a large-scale image dataset using deep learning with humans in the loop},
author={Yu, Fisher and Seff, Ari and Zhang, Yinda and Song, Shuran and Funkhouser, Thomas and Xiao, Jianxiong},
journal={arXiv preprint arXiv:1506.03365},
year={2015}

大规模场景理解The Large-scale Scene Understanding (LSUN) 挑战旨在为大规模场景分类和理解提供不同的基准。 LSUN分类数据集包含餐厅、卧室、鸡、户外教堂等10个场景类别。对于训练数据,每个类别都包含大量图像,从大约 120,000 到 3,000,000 不等。验证数据包括 300 张图像,测试数据每个类别有 1000 张图像。

LSun场景分类的10个场景类别。LSUN 是一个场景理解图像数据集,主要包含了卧室、固房、客厅、教室等场景图像。
20对象类别:链接列表。每个类别的图像以LMDB格式存储,然后数据库被压缩。下载和解压缩ZIP文件后,请参考LSun实用代码来可视化和导出图像。还提供了每个zip文件的MD5和,以便您可以验证下载。

其中物体标注及数量如下:

数据集FFHQ和LSUN介绍_第4张图片
其中场景标注是现在深度学习中常用的benchmark数据集.

常用场景包括:cat,horse,以及卧室(bedroom)

2、获取方法

首先请确保您已安装 cURL(在项目地址里面)

# Download the whole latest data set
python3 download.py
# Download the whole latest data set to 
python3 download.py -o <data_dir>
# Download data for bedroom
python3 download.py -c bedroom
# Download testing set
python3 download.py -c test

不过这个问题就bug比较多了,具体可以看看github项目issues中的
“export lmdb to jpg has error #11”

即修改data.py中的45,49,50行为:

LINE 45 : image_out_dir = join(out_dir, '/'.join(key[:6].decode()))

LINE 50 : with open(image_out_path, 'wb') as fp:

Line 49 :image_out_path = join(image_out_dir, key.decode() + '.jpg')

其中前两个是转码问题:
image_out_dir = join(out_dir, ‘/’.join(key[:6]))
TypeError: sequence item 0: expected str instance, int found

后一个是转换图片格式默认是.webp,可以改为jpg(也可以改为png)

  • 保存文件
    默认保存文件是分为无数个子文件夹,如果想全部图片保存为一个文件夹,可以加上–flatten参数,容易:
python data.py export ./bedroom_val_lmdb --out_dir ./bedroom_val --flat

最后就是图片文件名在unbuntu上是乱码,这个自己转码或者重写命名规则即可。

Abstract
虽然视觉识别算法的性能取得了显着进步,但最先进的模型往往非常需要数据。需要大量标记的训练数据集,生成起来既昂贵又乏味,需要优化深度网络模型中的数百万个参数。落后于模型容量的增长,可用数据集在大小和密度方面迅速变得过时。为了规避这一瓶颈,我们建议通过部分自动化的标记方案来扩大人类的努力,利用循环中的人类深度学习。从每个类别的大量候选图像开始,我们迭代地采样一个子集,要求人们给它们贴上标签,用训练好的模型对其他图像进行分类,根据分类置信度将集合分为正、负和未标记,然后迭代未标记的集合。为了评估这种级联过程的有效性并使视觉识别研究取得进一步进展,我们构建了一个新的图像数据集 LSUN。它为 10 个场景类别和 20 个对象类别中的每一个包含大约一百万个标记图像。我们尝试训练流行的卷积网络,发现它们在该数据集上训练时获得了可观的性能提升。
While there has been remarkable progress in the performance of visual recognition algorithms, the state-of-the-art models tend to be exceptionally data-hungry. Large labeled training datasets, expensive and tedious to produce, are required to optimize millions of parameters in deep network models. Lagging behind the growth in model capacity, the available datasets are quickly becoming outdated in terms of size and density. To circumvent this bottleneck, we propose to amplify human effort through a partially automated labeling scheme, leveraging deep learning with humans in the loop. Starting from a large set of candidate images for each category, we iteratively sample a subset, ask people to label them, classify the others with a trained model, split the set into positives, negatives, and unlabeled based on the classification confidence, and then iterate with the unlabeled set. To assess the effectiveness of this cascading procedure and enable further progress in visual recognition research, we construct a new image dataset, LSUN. It contains around one million labeled images for each of 10 scene categories and 20 object categories. We experiment with training popular convolutional networks and find that they achieve substantial performance gains when trained on this dataset.

至此结束,感谢阅读^ - ^!
如果觉得有帮助的话,希望点赞收藏评论加关注支持一下吧。
你的支持是我创作的最大动力!!!

Reference:

https://blog.csdn.net/disanda/article/details/105787112

你可能感兴趣的:(CV,人工智能,计算机视觉,FFHQ,LSUN,深度学习)