Code Monkey home page Code Monkey logo

make-celeba-hq's Introduction

make-CelebA-HQ

Python script to download and create the celebA-HQ dataset.

To get the celebA-HQ dataset, you need to

a) download the celebA dataset. Google Drive or Baidu Drive.

b) download celebA-HQ dataset. Google Drive

c) do some processing to get the HQ images make_HQ_images.py.

Usage

1.Clone the repository

git clone https://github.com/mazzzystar/make-CelebA-HQ.git
cd make-CelebA-HQ

2.Install necessary packages

conda create -n celebaHQ python=3
source activate celebaHQ
  • Install the packages
conda install jpeg tqdm requests pillow urllib3 numpy cryptography scipy
pip install opencv-python==3.4.0.12 cryptography==2.1.4
  • Install 7zip (On Ubuntu)
sudo apt-get install p7zip-full

3.Download and Unzip CelebA & CelebA-HQ

Downloading CelebA: Large-scale CelebFaces Attributes (CelebA) Dataset

Downloading CelebA-HQ. Google Drive: https://drive.google.com/drive/folders/0B4qLcYyJmiz0TXY1NG02bzZVRGs

# there are 14 file inside. (img_celeba.7z.001, ... img_celeba.7z.014)
cd CelebA/Img/img_celeba.7z  
# merge .7z files into a single file.
cat img_celeba.7z.0** > img_celeba.7z
# unzip the .7z file
7z x img_celeba.7z
# move the unzipped folder 'img_celeba' under 'Img/' path
mv img_celeba ../


cd CelebA-HQ/
# unzip the zips of deltas00000.zip, deltas00001.zip, .. into one file
unzip '*.zip' -d combined
# move the "image_list.txt" to current github repo folder.

4.Make sure your datasets/landmark/scripts under current Github repo folder.

make-CelebA-HQ---CelebA
               |    |___Anno
               |    |     |___list_landmarks_celeba.txt
               |    |     |___...
               |    |     
               |    |___Img
               |         |___ img_celeba/
               |
               |_CelebA-HQ
               |    |
               |    |_Combined/
               |  
               |-make_HQ_images.py
               |-image_list.txt  
               |_README.md 
  

5.Run the scripts

python make_HQ_images.py ./

where ./ is the directory where you wish the data to be saved. this script will take a few hours to run depending on your internet connection and your CPU power. The final HQ images will be saved as .npy files in the ./celebA-HQ/combined/ folder.

6.Sample of loading image

import numpy as np
from PIL import Image

img = np.load('imgHQ15858.npy')
img = img.reshape(3, 1024, 1024)
print(img.shape)
img = np.transpose(img, (1, 2, 0))
print(img.shape)

im = Image.fromarray(img)
im.show()

Sources

This code is inspired by these files

Note

The code above use jpeg=8d version of md5 for checking hash value, however I could get the expected value for jpeg=9b version, so I simply ignore the md5 checking. Tell me if you think somewhere wrong.

make-celeba-hq's People

Contributors

mazzzystar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.