Giter Club home page Giter Club logo

mgan's Introduction

Masking GAN - Generating image attribute mask (pytorch)

!Disclaimer

This project is pretty much abandoned. I have achieved following results after spending a lot of time tuning the model. Unfortunatelly I was not able to reproduce results, which means I was lucky to get a good random seed once. Also, I am not interested in research in this direction right now, so the problem won't be fixed any time soon. C'est la vie.

Motivation

When I first approached semantic manipulation problem there was no solution like CycleGAN, or later findings. And even now all of them produce artifacts.

Approach

diagram

  1. Use generator architecture with built-in segmentation.
  2. Mix original image with new patches through the segmentation mask.
  3. Train the whole network end-to-end.
  4. Use L1 identity loss to constrain Generator and reduce changes.

Instructions

I am using CelebA dataset to train the model. There are two files you would need to reproduce results: img_align_celeba.zip and list_attr_celeba.txt

You can download them from here http://mmlab.ie.cuhk.edu.hk/projects/CelebA.html and put into {PROJECT_DIR}/data
After that initialize data and train the model by running

sh init_data.sh
python train.py

Results

picked sample

  1. In case a person is already smiling it doesn’t do any changes at all.
  2. It handles poorly some extreme head angles.
  3. There are still artifacts.

Advices

Consider following advices if you want to build this kind of a model:

  1. Make sure your GAN model converges without appling mask and L1 loss.

Acknowledgments

The code is inspired by pytorch-CycleGAN-and-pix2pix . This paper GANimation: Anatomically-aware Facial Animation from a Single Image arXiv:1807.09251 describes similar training scheme.

mgan's People

Contributors

tgeorgy 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mgan's Issues

RuntimeError: input and target shapes do not match: input [1 x 1 x 1 x 1], target [1 x 1]

Hi, tgeorgy.

I'v just started learning GAN and used your code for my first try. Unluckily I met a problem which I can't solve. At line 113 an error existed, where the code is:

loss_P2N_gan = criterion_gan(fake_neg_lbl, Variable(real_lbl)).

And the traceback is :

RuntimeError: input and target shapes do not match: input [1 x 1 x 1 x 1], target [1 x 1]

It seems that the dimensions of the scalars differ from each other. Could you tell me how to solve the problem? Or what should I learn to handle this? I ran the code using python 3.6, so I changed the 'itertools.izip' to 'zip', does this affect the programme?

Best regards,
Hondahmd

hi

How long have you train your model?

suggest

can u provide a test.py.
thanks

Paper about this project

Hi, tgeorgy.

I really appreciate your work.
And i wonder whether u wrote any paper about this project?

Valentina

Data error!

Hi, thank you for sharing this code, but when I executing 'sh init_data.sh', I got following error, may you provide a solution for me?

extracting: img_align_celeba/202594.jpg
extracting: img_align_celeba/202595.jpg
extracting: img_align_celeba/202596.jpg
extracting: img_align_celeba/202597.jpg
extracting: img_align_celeba/202598.jpg
extracting: img_align_celeba/202599.jpg
Traceback (most recent call last):
File "crop_images.py", line 29, in
os.rename(ipath+fname, 'data/celeba/pos/'+fname)
OSError: [Errno 2] No such file or directory

question about mask

Hi~ Seeing from the graph you provided , the generated image containing mask will go through discriminator , but in your code it seems you didn't do that?

Multiple faces?

Hi, great work!

How to apply this multiple faces? i mean the images which includes more than 1 person

regards

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.