Giter VIP home page Giter VIP logo

progressive_growing_of_gans_tensorflow's Introduction

PGGAN-tensorflow

The tensorflow implementation of PROGRESSIVE GROWING OF GANS FOR IMPROVED QUALITY, STABILITY, AND VARIATION.

The generative process of PG-GAN

Differences with the original paper.

  • Recently, just generate 64x64 and 128x128 pixels samples.

Setup

Prerequisites

  • TensorFlow >= 1.4
  • python 2.7 or 3

Getting Started

  • Clone this repo:
git clone https://github.com/zhangqianhui/progressive_growing_of_gans_tensorflow.git
cd progressive_growing_of_gans_tensorflow
  • Download the CelebA dataset

You can download the CelebA dataset and unzip CelebA into a directory. Noted that this directory don't contain the sub-directory.

  • The method for creating CelebA-HQ can be found on Method

  • Train the model on CelebA dataset

python main.py --path=your celeba data-path --celeba=True
  • Train the model on CelebA-HQ dataset
python main.py --path=your celeba-hq data-path --celeba=False

Results on celebA dataset

Here is the generated 64x64 results(Left: generated; Right: Real):

Here is the generated 128x128 results(Left: generated; Right: Real):

Results on CelebA-HQ dataset

Here is the generated 64x64 results(Left: Real; Right: Generated):

Here is the generated 128x128 results(Left: Real; Right: Generated):

Issue

If you find some bugs, Thanks for your issue to propose it.

Reference code

PGGAN Theano

PGGAN Pytorch

progressive_growing_of_gans_tensorflow's People

Contributors

ilavva avatar zhangqianhui 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

progressive_growing_of_gans_tensorflow's Issues

tf version is 1.8, why has so many errors? Is tf version a bit higher?

E:\anacond\python.exe C:/Users/admin/Desktop/progressive_growing_of_gans_tensorflow/main.py
Traceback (most recent call last):
File "E:\anacond\lib\site-packages\absl\flags_flag.py", line 166, in _parse
return self.parser.parse(argument)
File "E:\anacond\lib\site-packages\absl\flags_argument_parser.py", line 152, in parse
val = self.convert(argument)
File "E:\anacond\lib\site-packages\absl\flags_argument_parser.py", line 268, in convert
type(argument)))
TypeError: Expect argument to be a string or int, found <class 'float'>

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:/Users/admin/Desktop/progressive_growing_of_gans_tensorflow/main.py", line 19, in
flags.DEFINE_integer("lam_eps", 0.001, "Weight for the epsilon term")
File "E:\anacond\lib\site-packages\tensorflow\python\platform\flags.py", line 58, in wrapper
return original_function(*args, **kwargs)
File "E:\anacond\lib\site-packages\absl\flags_defines.py", line 315, in DEFINE_integer
DEFINE(parser, name, default, help, flag_values, serializer, **args)
File "E:\anacond\lib\site-packages\absl\flags_defines.py", line 81, in DEFINE
DEFINE_flag(_flag.Flag(parser, serializer, name, default, help, **args),
File "E:\anacond\lib\site-packages\absl\flags_flag.py", line 107, in init
self._set_default(default)
File "E:\anacond\lib\site-packages\absl\flags_flag.py", line 196, in _set_default
self.default = self._parse(value)
File "E:\anacond\lib\site-packages\absl\flags_flag.py", line 169, in _parse
'flag --%s=%s: %s' % (self.name, argument, e))
absl.flags._exceptions.IllegalFlagValueError: flag --lam_eps=0.001: Expect argument to be a string or int, found <class 'float'>

Process finished with exit code 1

progressive growing of conditional gans

Do you have any plans for progressive growing of conditional gans, whose input will be image, and then we pass it through an encoder and we can regard it as normal gan whose input is noise.

sigmoid / WScaleLayer

Hi, I am glad to find the implementation using wgan-gp.

Can you explain the differences from the reference implementation:

  • sigmoid at the end of Discriminator
  • No use of WScaleLayer

Pre-trained weights for 64x64 and 128x128 on CelebA

Dear Authors,
Thanks for releasing the codes. Will it be possible to release the pre-trained weights for CelebA at 64x64 and 128x128 resolution. It will be really helpful for me to get started off with.

Thanks,
Avisek Lahiri
Indian Institute of Technology Kharagpur

TypeError: 'float' object cannot be interpreted as an integer

Hi, I clone your code and has many prombles while running
The error info is:

Traceback (most recent call last):
File "main.py", line 58, in
pggan.train()
File "D:\code_hj\progressive_growing_of_gans_tensorflow-master\progressive_gro
wing_of_gans_tensorflow-master\PGGAN.py", line 194, in train
'{}/{:02d}_real.jpg'.format(self.sample_path, step))
File "D:\code_hj\progressive_growing_of_gans_tensorflow-master\progressive_gro
wing_of_gans_tensorflow-master\utils.py", line 115, in save_images
return imsave(inverse_transform(images), size, image_path)
File "D:\code_hj\progressive_growing_of_gans_tensorflow-master\progressive_gro
wing_of_gans_tensorflow-master\utils.py", line 128, in imsave
return scipy.misc.imsave(path, merge(images, size))
File "D:\code_hj\progressive_growing_of_gans_tensorflow-master\progressive_gro
wing_of_gans_tensorflow-master\utils.py", line 132, in merge
img = np.zeros((h * size[0], w * size[1], 3),dtype=int)
TypeError: 'float' object cannot be interpreted as an integer

So, please help me solve the problem
Thanksssss!

Why are there coding errors

Traceback (most recent call last):
File "main.py", line 34, in
File "E:\pythonproject\lib\site-packages\h5py_hl\files.py", line 142, in make_fid
fid = h5f.open(name, flags, fapl=fapl )
File "h5py_objects.pyx", line 54, in h5py._objects.with_phil.wrapper
File "h5py_objects.pyx", line 55, in h5py._objects.with_phil.wrapper
File "h5py\h5f.pyx", line 78, in h5py.h5f.open
File "h5py\defs.pyx", line 621, in h5py.defs.H5Fopen
File "h5py_errors.pyx", line 123, in h5py._errors.set_exception
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb1 in position 32: invalid start byte

Hi, I have some questions

阅读了下你的代码,终于把nvidia这篇文章中的一些小点搞明白了。还有几个问题想咨询一下。

  1. low_realbatch_array这个是什么作用,没看明白,alpha功能不是已经通过alpha_trans在G和D中实现了么
  2. 请问最大迭代数max_iters是怎么决定为32000的
  3. 载入真实图片的时候center_crop,会随机把图片的左右调换,这是为了增加样本多样性吗?
  4. 论文中44,88,1616,3232层都还是512,你的从16开始就递减为256,128,64了,这是因为内存不足吗,不知道是否会对结果产生较大的影响
  5. 我用的GTX 1080,到pg=6 t=true这一步就提示我CUDA_ERROR_OUT_OF_MEMORY....

可能是我tensorflow版本是最新的,所以有两个地方有问题,我修改了下

  1. ops.py 153行 input.shape[0]改为了tf.shape(input)[0],否则会报错
  2. main.py 模型的保存路径,最新版tf是保存为4个文件,没有model.ckpt这个文件了,模型路径需要更改下,否则会生成一个叫model.ckpt的文件夹

问题好像有点多。。非常希望能够解答,或者可以的话加我的QQ46923591

How could we get high-quality images in 1024*1024 format?

I have tried code in tkarra's implementation, however, when I use h5tool.py to generate images, it seems there are some errors in the code.

Worker thread caught an exception:

Traceback (most recent call last):

  File "h5tool.py", line 97, in run

    result = func(*args)

  File "h5tool.py", line 146, in task_func

    return process_func(prepared)

  File "h5tool.py", line 569, in process_func

    img = np.pad(np.float32(img), ((pad[1], pad[3]), (pad[0], pad[2]), (0, 0)), 'reflect')

TypeError: float() argument must be a string or a number

Have you successfully use high-quality images?

我有一个疑问

初次接触GAN,如果问的太基础请见谅 `

                realbatch_array = np.clip(realbatch_array, -1, 1)
                save_images(realbatch_array[0:self.batch_size], [2, self.batch_size/2],
                            '{}/{:02d}_real.jpg'.format(self.sample_path, step))

                if self.trans and self.pg != 0:
                    low_realbatch_array = np.clip(low_realbatch_array, -1, 1)
                    save_images(low_realbatch_array[0:self.batch_size], [2, self.batch_size / 2],
                                '{}/{:02d}_real_lower.jpg'.format(self.sample_path, step))
               
                fake_image = sess.run(self.fake_images,
                                      feed_dict={self.images: realbatch_array, self.z: sample_z})
                fake_image = np.clip(fake_image, -1, 1)
                save_images(fake_image[0:self.batch_size], [2, self.batch_size/2], '{}/{:02d}_train.jpg'.format(self.sample_path, step))`

这里面有一步 fake_image = sess.run(self.fake_images, feed_dict={self.images: realbatch_array, self.z: sample_z}) 是不是可以替换成 ```
fake_image = sess.run(self.fake_images, feed_dict={ self.z: sample_z})

然后生成的fake和real值不是一一对应的吧  比如是陈冠希  我生成的fake不是陈冠希吧

One Pix_Norm too much

but we perform pixelwise normalization of the feature vectors after each Conv 3 × 3 layer in the generator as described in Section 4.2.

They write this in A.1 in the paper.

Meaning the line 265 inPCGAN.py is not intended in the original.

train loss is negative,please explain to me ,thanks!

PG 1, step 0: D loss=0.2648493 G loss=-0.1896488, D_or loss=0.1181762, opt_alpha_tra=0.0000000
PG 1, step 400: D loss=-0.6157230 G loss=0.0674022, D_or loss=-0.8367248, opt_alpha_tra=0.0100000
PG 1, step 800: D loss=-0.1810449 G loss=0.5394976, D_or loss=-0.3036686, opt_alpha_tra=0.0200000
PG 1, step 1200: D loss=-0.0945862 G loss=-0.8442736, D_or loss=-0.2622258, opt_alpha_tra=0.0300000
PG 1, step 1600: D loss=-0.5540385 G loss=0.3731411, D_or loss=-0.6529528, opt_alpha_tra=0.0400000
PG 1, step 2000: D loss=-0.4823601 G loss=0.4856569, D_or loss=-0.5566395, opt_alpha_tra=0.0500000
PG 1, step 2400: D loss=-0.0843895 G loss=0.1010681, D_or loss=-0.1548125, opt_alpha_tra=0.0600000
PG 1, step 2800: D loss=-0.1969025 G loss=0.0634548, D_or loss=-0.2701692, opt_alpha_tra=0.0700000
PG 1, step 3200: D loss=-0.3599952 G loss=0.1829128, D_or loss=-0.3996447, opt_alpha_tra=0.0800000
PG 1, step 3600: D loss=0.1415115 G loss=-0.0370798, D_or loss=0.0640999, opt_alpha_tra=0.0900000
PG 1, step 4000: D loss=-0.0609178 G loss=0.1558231, D_or loss=-0.1338096, opt_alpha_tra=0.1000000
PG 1, step 4400: D loss=-0.4271692 G loss=0.1705226, D_or loss=-0.4995243, opt_alpha_tra=0.1100000
PG 1, step 4800: D loss=-0.1475996 G loss=0.1545829, D_or loss=-0.2413805, opt_alpha_tra=0.1200000
PG 1, step 5200: D loss=-0.0023486 G loss=0.2533301, D_or loss=-0.0623062, opt_alpha_tra=0.1300000
PG 1, step 5600: D loss=-0.3025054 G loss=0.2369120, D_or loss=-0.3451613, opt_alpha_tra=0.1400000
PG 1, step 6000: D loss=-0.0315916 G loss=0.1381170, D_or loss=-0.1310087, opt_alpha_tra=0.1500000
PG 1, step 6400: D loss=-0.0186618 G loss=0.0608674, D_or loss=-0.0837486, opt_alpha_tra=0.1600000
PG 1, step 6800: D loss=-0.1877660 G loss=0.1341513, D_or loss=-0.2104936, opt_alpha_tra=0.1700000
PG 1, step 7200: D loss=-0.0606919 G loss=0.0908021, D_or loss=-0.1625843, opt_alpha_tra=0.1800000
PG 1, step 7600: D loss=-0.0598196 G loss=0.2552856, D_or loss=-0.1427037, opt_alpha_tra=0.1900000
PG 1, step 8000: D loss=-0.1311789 G loss=0.0492419, D_or loss=-0.2045113, opt_alpha_tra=0.2000000
PG 1, step 8400: D loss=-0.1048601 G loss=0.0262296, D_or loss=-0.1693949, opt_alpha_tra=0.2100000

about test and evaluate

Hi, I have 2 questions,please explain,thank you
1、 In your article,you just tell how to train. I want to know how to test after training is completed
2、How to evaluate the trained module?

UnimplementedError

Hello,

I tried to train the GAN using the code and I get the below error,
tensorflow.python.framework.errors_impl.UnimplementedError: TileOp : Unhandled input dimensions, DT : 1, dims : 8
[[Node: gradients_1/gradients/discriminator_2/Tile_grad/Sum_grad/Tile = Tile[T=DT_FLOAT, Tmultiples=DT_INT32, _device="/job:localhost/replica:0/task:0/gpu:0"](gradients_1/gradients/discriminator_2/Tile_grad/Sum_grad/Reshape, gradients_1/gradients/discriminator_2/Tile_grad/Sum_grad/floordiv)]]
Any idea how to solve this? Thanks in advance.

Trying to understand the training of PG-GAN with class labels

Hi @zhangqianhui
Thank you for the implementation! It is very helpful.

I have a question, and I was wondering if I can get your thoughts: The paper mentions that their training is unsupervised - meaning that it was not label-conditioned. Then how come they were able to generate label-specific images for LSUN dataset? Did they train separate networks for each label or is their network a multi-class generator?

As a follow-up, does your implementation generate images of input classes (while testing) after training on multiple classes?

Thanks in advance!

Output Image size issue.

Hey, I am running this program, during the training phase, there is no issues except one that the output file consisting of real.jpg and train.jpg turned out to be very small. I'm attaching the screenshot below. Kindly assist me in this matter. TIA :)
temp1
temp2
00_real
00_train

what's your tensorflow version?

my tensorflow version is 1.3 and i clone your lastest code and has many prombles while running

however ,there is no any problems about your code before

have a question

Traceback (most recent call last):
File "main.py", line 49, in
pggan.build_model_PGGan()
File "/media/lembert/DCC2B5B2C2B5916E/Windows_Yunpan_Ubuntu/Lembert_AI/example_TF/PG_GANs/zhangqianhui/PGGAN-tensorflow/PGGAN.py", line 36, in build_model_PGGan
_, self.D_pro_logits = self.discriminate(self.images, reuse=False, pg = self.pg, t=self.trans, alpha_trans=self.alpha_tra)
File "/media/lembert/DCC2B5B2C2B5916E/Windows_Yunpan_Ubuntu/Lembert_AI/example_TF/PG_GANs/zhangqianhui/PGGAN-tensorflow/PGGAN.py", line 243, in discriminate
conv = MinibatchstateConcat(conv)
File "/media/lembert/DCC2B5B2C2B5916E/Windows_Yunpan_Ubuntu/Lembert_AI/example_TF/PG_GANs/zhangqianhui/PGGAN-tensorflow/ops.py", line 153, in MinibatchstateConcat
vals = tf.tile(vals, multiples=[input.shape[0], 4, 4, 1])
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/gen_array_ops.py", line 3797, in tile
name=name)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/op_def_library.py", line 494, in apply_op
raise err
TypeError: Expected binary or unicode string, got Dimension(16)

Visualization

1200_real
1600_real
For some reason, I am able to see only a part of the faces using your code. Any idea how I can fix this? Thanks in advance.

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.