carpedm20 / DCGAN-tensorflow

A tensorflow implementation of "Deep Convolutional Generative Adversarial Networks"
http://carpedm20.github.io/faces/
MIT License
7.15k stars 2.62k forks source link

How to perform Vector Arithmetic of face images #147

Open mhasnat opened 7 years ago

mhasnat commented 7 years ago

Hi,

I would like to perform vector arithmetic of face images. Have you written tensorflow version of the arithmetic.lua file? Or is there any other way with the existing code?

Thanks.

johnhany commented 7 years ago

When I was reproducing results from the paper, I wrote a piece of python codes to help with. It worked out fine for me:)

TigistAbebaw commented 7 years ago

Can u give me some directions on how to generate the examplar_vector.txt.

johnhany commented 7 years ago

@TigistAbebaw sorry I didn't explain that I also altered part of visualize() codes in utils.py such that the generated txt file would be used for visualization. Please take following steps:

  1. Run generate_samples(), which will create a sample_file.txt.
  2. Run DCGAN.main() in test mode and make sure option=0 for visualize().
  3. Select images by hand from generated png file that you need for arithmetic calculation (take smiling woman for example), and copy corresponding sample vector (examplar vector) in sample_file.txt to a new txt file.
  4. Repeat 1-3 until you have 3 different examplar vectors (smiling woman, normal woman and normal man). Name this new txt file as exemplar_vector.txt.
  5. Run alrithmetic_sample() which performs arithmetic calculation between 3 examplar vectors and generates a new sample_file.txt.
  6. Run DCGAN.main() in test mode and set option=0 in visualize(). Now arithmetic result image will be generated. Pardon me if the procedures are far more complicated than a single script file. But I believe it introduces more freedom in the process.
TigistAbebaw commented 7 years ago

Thank you for the clear explanation.

TigistAbebaw commented 7 years ago

After doing the arithmetic, it has given me some result. But it is not as interesting as the "smiling man". Mine is not much different from the inputs.

I want to generate more samples by using the interpolation. I didn't understand the difference with the generate_samples using uniform distribution. How can we get more images generated from interpolation. thanks.

And If you have any suggestions to make arithmetic result significant.

JeawooNam commented 6 years ago

Can you tell me more details on how to do this?

How can I make a vector with the desired pictures? (Example: sample_file.txt of man wearing glasses)

johnhany commented 6 years ago

I just did it in a very straightforward fashion, which is handpicking the desired vectors based on their result images. For example, generate a sample_file.txt filled with entirely random vectors and look for a man wearing glasses. If the kth (row first) image is what I need, I will say that the kth vector in the sample_file.txt is the examplar vector.

I'm sure the author has far more experience in identifying the generated samples' relation to their vectors. My method to reproduce results in the paper is naive and unpolished, but the results are similar.

Here are some results: 1.vector arithmetic vector arithmetic

2.[-0.5, +0.5] noise added to the arithmetic result arithmetic noise

3.vector interpolation arithmetic noise

JeawooNam commented 6 years ago

Thank you for your kind reply.

I have one more question.

After creating sample_file.txt, I set visualize to 0 using test mode, but a dimension error occurs.

The executable code python main.py --is_crop False --is_train False --visualize 0

below picture is command and error

image

image

akshseh commented 6 years ago

Try using is_crop as true. (Since the specified shape and found shape is different) Or use some other way to make the size consistent.