carpedm20 / DCGAN-tensorflow

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

visualize() not able to save the image #119

Closed asispatra closed 7 years ago

asispatra commented 7 years ago

Getting the following error during run:

Traceback (most recent call last):
  File "main.py", line 96, in <module>
    tf.app.run()
  File "....../tensorflow/python/platform/app.py", line 44, in run
    _sys.exit(main(_sys.argv[:1] + flags_passthrough))
  File "main.py", line 93, in main
    visualize(sess, dcgan, FLAGS, OPTION)
  File "...../DCGAN-tensorflow/utils.py", line 174, in visualize
    save_images(samples, [8, 8], './samples/test_arange_%s.png' % (idx))
  File "....../DCGAN-tensorflow/utils.py", line 26, in save_images
    return imsave(inverse_transform(images), size, image_path)
  File "....../DCGAN-tensorflow/utils.py", line 47, in imsave
    return scipy.misc.imsave(path, merge(images, size))
  File "....../DCGAN-tensorflow/utils.py", line 43, in merge
    img[j*h:j*h+h, i*w:i*w+w, :] = image
ValueError: could not broadcast input array from shape (64,64,3) into shape (0,64,3)
asispatra commented 7 years ago

visualize() is working if the batch-size <= 64. More than 64 is failing.

carpedm20 commented 7 years ago

That's why I manually set the number of images to be visualize as 8x8 as https://github.com/carpedm20/DCGAN-tensorflow/blob/master/utils.py#L156. You can change this 8, 8 or 64 values in utils.py to make it work for batch_size > 64

asispatra commented 7 years ago

Thanks @carpedm20, Yes, that's right. I have also arrived at the same place while I was debugging. I will try to find a way to set these sizes automatically based on batch-size.

asispatra commented 7 years ago

The following changes resolve my issue:

image_frame_dim = int(math.ceil(config.batch_size**.5))
save_images(samples, [image_frame_dim, image_frame_dim], './samples/test_arange_%s.png' % (idx))
asispatra commented 7 years ago

Fixed by #122

rp2017 commented 7 years ago

@asispatra can you generate more than 100 images?? Help needed

asispatra commented 7 years ago

@rp2017, I have made one PR #216 , I have tested only for "OPTION = 1" as specified in main.py. Please verify for other possible value of OPTION.