Coder Social home page Coder Social logo

beholdergan / beholder-gan Goto Github PK

View Code? Open in Web Editor NEW

This project forked from deanzadok/beholder-gan

81.0 0.0 22.0 10.23 MB

Generation and Beautification of Facial Images with Conditioning on Their Beauty Level

Home Page: https://arxiv.org/abs/1902.02593

Python 100.00%

beholder-gan's Introduction

Beholder-GAN: Generation and Beautification of Facial Images with Conditioning on Their Beauty Level

This is the code repository for our paper: https://arxiv.org/abs/1902.02593

Faces Generation Conditioned On Beauty

samples
Generated faces. left to right - least attractive to most attractive.

Beautification Of Real Faces

beautification_samples
Beautification of real faces. Left column are the input real faces. To the right are the beautified images with an increasing beauty level.

Our generating procedure is heavily based on the implementation of progressive growing of GANs. For more information, please refer to the original implementation:
https://github.com/tkarras/progressive_growing_of_gans

Installation

We recommend using Anaconda for python and creating a virtual environment the same way we did.
Anaconda can be downloaded from here: https://www.anaconda.com/distribution/

Create environment for Python 3.6:

conda create -n beholder python=3.6 anaconda

Enter the environment and install python requirements:

conda activate beholder
pip install -r requirements-pip.txt

Datasets

The datasets we worked on can be found in these links:

Usage

Creation of Beauty Scores

To reinforce additional datasets with beauty scores the same way SCUT-FBP-5500 has, we conducted a procedure to train a beauty prediction model and predict their beauty scores.

An example command to train a beauty prediction model:

python train_beauty_prediction.py --dataset ../datasets/scutfbp5500 --experiment trained_model

This script will initiate a VGG16 network pretrained on imagenet, train it on SCUT-FBP-5500 and save the output model in the experiment folder.
It is required that the dataset we are training on will be stored in the following structure:

root folder
-- All_Ratings.csv
-- img

All_Ratings.csv is the beauty scores of our data in the same format used in SCUT-FBP-5500 and img is the folder containing the images.

An example command to label an external dataset using our trained model:

python execute_beauty_prediction.py --model trained_model/VGG16_beauty_rates.pt --dataset ../datasets/CelebA-HQ

This script will reload our trained VGG16 network and predict beauty scores for all images that in ../datasets/CelebA-HQ/img in order to store a predicted All_Ratings.csv in ../datasets/CelebA-HQ.

An example command to predict beauty scores for a single image:

python execute_beauty_prediction_single.py --model trained_model/VGG16_beauty_rates.pt --image sample.png

This script will reload our trained VGG16 network and present beauty scores for the given image sample.png.

We provide a pretrained model to execute beauty prediction: models.

Data Reconstruction and Training

To use Progressive Growing of GANs the same we did, We added functions to allow reconstruction for datasets in dataset_tool.py:

usage: dataset_tool.py [-h] <command> ...

    create_celebahq_cond                  Create dataset for CelebA conditioned with a class label vector.
    create_celebahq_cond_continuous       Create dataset for CelebA conditioned with 60 beauty rates vector.
    create_from_images_cond               Create dataset for CelebA conditioned with a class label vector.
    create_from_images_cond_continuous    Create dataset for CelebA conditioned with 60 beauty rates vector.

Type "dataset_tool.py <command> -h" for more information.

These functions require the dataset folders to have the same structure mentioned before. The output will be tfrecord files ready for training. The functions of CelebA-HQ allow saving the reconstructed images using the save_images flag.
Be advised that we offer two possible ways to prepare beauty labels - the first one is a one hot vector that represnts the class of the beauty levels mean for each image, and continuous is raw input without any computation on it.
In case of failure related to the version of pillow or libjpeg during reconstruction of CelebA-HQ dataset, please create the same virtual environment we suggest with Python 3.5 instead of 3.6.

For more details on how to reconstruct the data and execute the training procedure, please refer to the original version of Progressive Growing of GANs:
https://github.com/tkarras/progressive_growing_of_gans

Generation of Synthetic Images

To create sequences of varying images from the least attractive person, we supplied inference_cond.py. Here is an example of how to use it on a trained model:

python inference_cond.py --results_dir experiment_folder --outputs 10

This will reload the last saved model from experiment_folder and generate 10 sequences in different beauty rates.

Beautification of Real Images

To create sequences of beautificated version from a given image, we supplied beautify_image.py. Here is an example of how to use it on a trained model:

python beautify_image.py --results_dir experiment_folder --image_path samples/jenny.png

This will train an algorithm to restore the given image, and beautify it.

We provide a pretrained model to compute the loss from VGG's extracted features: models.

Acknowledgments

The research was funded by ERC StG RAPID.

Citation

If our work helped you in your research, please consider cite us.

@Article{beholdergan,
  title={Beholder-GAN: Generation and Beautification of Facial Images with Conditioning on Their Beauty Level},
  author={Nir Diamant, Dean Zadok, Chaim Baskin, Eli Schwartz, Alex M. Bronstein},
  journal={arXiv preprint arXiv:1902.02593},
  year={2019}
}

This work is licensed under the Creative Commons Attribution-NonCommercial
4.0 International License. To view a copy of this license, visit
http://creativecommons.org/licenses/by-nc/4.0/ or send a letter to
Creative Commons, PO Box 1866, Mountain View, CA 94042, USA.

beholder-gan's People

Contributors

beholdergan avatar deanzadok avatar nirdiamant avatar tomhirsh avatar

Stargazers

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

beholder-gan's Issues

How to include network_pkl

Hey thanks for this amazing work.

I am struggling a little bit to use your beautify_image file.
As far as I can see it, I need a pkl file for this, but the model you published is a pb file. So how can I convert this or rewrite the script?

Requesting for pretrained model

I'm very interesting with your research "Beholder-GAN". This research can make people more beautiful. I want to test on my own datasets, and could you please provide the pretrained model? Thanks very much.

Could not find a version that satisfies the requirement torch==0.4.1

Torch 0.4.1 can not be downloaded from PyPi by default anymore.

ERROR: Could not find a version that satisfies the requirement torch==0.4.1 (from -r requirements-pip.txt (line 11)) (from versions: 1.7.0, 1.7.1, 1.8.0, 1.8.1, 1.9.0, 1.9.1, 1.10.0, 1.10.1, 1.10.2)
ERROR: No matching distribution found for torch==0.4.1 (from -r requirements-pip.txt (line 11))

Fix:

Install torch 0.4.1 manually by
pip install torch==0.4.1 -f https://download.pytorch.org/whl/torch_stable.html

Then again
pip install -r requirements-pip.txt

Good luck!

OSError: [Errno Cannot locate result subdir for run] experiment_folder

Hi,

I am trying to run your project and getting from running "python inference_cond.py --results_dir experiment_folder --outputs 10":

Saving results to results/000-inference_test

Initializing TensorFlow...
2019-05-13 22:39:02.677863: E tensorflow/stream_executor/cuda/cuda_driver.cc:300] failed call to cuInit: CUDA_ERROR_NO_DEVICE: no CUDA-capable device is detected
Traceback (most recent call last):
  File "inference_cond.py", line 34, in <module>
    network_pkl = misc.locate_network_pkl(args.results_dir)
  File "/content/Beholder-GAN/misc.py", line 626, in locate_network_pkl
    pkls = list_network_pkls(run_id_or_result_subdir_or_network_pkl)
  File "/content/Beholder-GAN/misc.py", line 614, in list_network_pkls
    result_subdir = locate_result_subdir(run_id_or_result_subdir)
  File "/content/Beholder-GAN/misc.py", line 611, in locate_result_subdir
    raise IOError('Cannot locate result subdir for run', run_id_or_result_subdir)
OSError: [Errno Cannot locate result subdir for run] experiment_folder

this is from a run on colab, notebook: https://colab.research.google.com/drive/1-ImMSom-1uX7JTsmB5d2KPrjZuDG0lAg (I have removed the tensorflow install as it is actually pre installed)

I suspect it is looking for the bueatification scores (I have no idea why it can't locate the cuda device). Can you also provide pre-calculated beatification scores?

Best regards,
Moshe

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.