This model generates photo-realistic images by learning image dataset.
The codes are based on eriklindernoren's repository.
You can run this model with celebA dataset.
- main.py : contains model and running part
- utils.py : contains preprocessing function for CelebA dataset & data loader
- haarcascade_frontalface_default.xml : for face recognition (preprocessing)
Before you run the model, make directories below.
datasets: put your dataset in this folderlogs: checkpoints are going to be saved heremodels: model architecture and weights are going to be saved here
You need to edit some hyper parameters in line 23-29 of main.py.
When you put your own data to datasets folder, clarify the resolution of image data by making another folder *by*.
ex) datasets/CelebA/128by128/*.jpg
If you don't want to use 128x128 resolution but other, you'd better change the model a bit. If you have any problem to adjust the model to your own data, don't hesitate to open issue.
You can crop faces from CelebA dataset with util.py. (the image file in CelebA should be jpg)
Import this file to console and call crop_face function.
The function has 4 parameters.
dataPath: path of face imagessavePath: path to save the cropped imagetarget_size: need to be tuple ex) (128, 128)cascPath: haar-cascade xml file path
The base code of class DataLoader is from (eriklindernoren/Keras-GAN)[https://github.com/eriklindernoren/Keras-GAN].
I recommend to visit his repo, because there are so many good example code for GAN. :)
Anyway, there are two ways to load data with DataLoader.
- Load all the data into RAM. : this would be way faster when you have enough RAM.
- Randomly picked image data from the designated directory. : though it's slower, this way doesn't need much RAM space.
