Giter Club home page Giter Club logo

pokemon_gan's Introduction

pokeGAN

Overview

This is the code for this video on Youtube by Siraj Raval. We'll use a WGAN to create new kinds of Pokemon.

Dependencies (pip install)

cv2
tensorflow( >=1.0)
scipy
numpy

Usage

cd pokeGAN
python resize.py
python RGBA2RGB.py
python pokeGAN.py

And open the notebook by typing in jupyter notebook in the root directory. Install it here if you haven't

example pokemon

image1

image2

Credits

The credits for this code go to moxiegushi. I've merely created a wrapper to get people started.

pokemon_gan's People

Contributors

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

pokemon_gan's Issues

Confusion in the README

Readme says that before running pokeGAN.py one should run resize.py and RGBA2RGB.py.
There are few problems here and I'll work backwards from pokeGAN.py to explain them. In pokeGAN.py the height and width of the images are hardcoded to be 128 and 128. However in resize.py resized images height and width are 256. This is the first wtf.
Second wtf is that pokeGAN.py reads the data from 'data' directory (line 29), but resize.py puts data in a directory named 'resizedData'. Third thing is that RGBA2RGB.py takes this a step further and puts files from resizedData to resized_black (which is bad naming, but let it be).

To conclude, either the pokeGAN.py reads images from wrong directories or helper scripts put processed images into wrong directories. I understand that this is not your code, but let's fix this if people of YouTube will try to use it ๐Ÿ˜‰

When using tf.layers.conv2d_transpose, what defines the output tensor shape?

When using tf.layers.conv2d_transpose what defines the output tensor shape?

In the generator code, when the input was 4x4x512, for the output to be 8x8x256 the number of filters can be given, but how are the height and width of the output defined? Or else is it always two times the input height and width?

Thanks.

Not getting the result properly

Results are getting black color. Is it need to uncomment the line before saving to get proper result

imgtest = imgtest * 255.0

imgtest.astype(np.uint8)

        save_images(imgtest, [8,8] ,newPoke_path + '/epoch' + str(i) + '.jpg')

Possible incomplete dependencies list

Possibly the dependencies list is incomplete. When I first ran the code it threw error "module 'scipy.misc' has no attribute 'imsave'"

Googling led to this being about pillow. It was suggested to uninstall scipy, install pillow, then install scipy again. I did this and the error was gone.

Perhaps pillow should be on the dependencies list?

Training time

What type of training times are you getting with 5k epochs on a GPU? Does 20 hours seem in the right ballpark?

Error when run pokeGan.py

Hi everyone,

I got some error like above when I'm trying to run pokeGAN.py. Is there anaybody know the solution?

error

Input_fn

Where is the Input_fn? it is practically impossible to read and write data to the disk, do you imagine how inefficient it makes the code? You have to make the crop and resize on the fly using the TF DATASET API.

OutOfRangeError when trying to run pokeGAN.py

When I'm trying to run pokeGAN.py, line 225 throws the following error: tensorflow.python.framework.errors_impl.OutOfRangeError: RandomShuffleQueue '_0_shuffle_batch/random_shuffle_queue' is closed and has insufficient elements (requested 64, current size 0)
[[Node: shuffle_batch = QueueDequeueManyV2[component_types=[DT_FLOAT], timeout_ms=-1, _device="/job:localhost/replica:0/task:0/cpu:0"](shuffle_batch/random_shuffle_queue, shuffle_batch/n)]]

While this error is throwing during the train_image = sess.run(image_batch) instruction, it seems to be related to line 58, where is defined a shuffle batch instruction:

    images_batch = tf.train.shuffle_batch(
                                    [image], batch_size = BATCH_SIZE,
                                    num_threads = 4, capacity = 200 + 3* BATCH_SIZE,
                                    min_after_dequeue = 200)

I couldn't find anyone else on the internet with the same mistake, but it happens when I try to run this code without any changes.

could not broadcast input array from shape (128,128,3) into shape (0,128,3)

Hi
Does anyone have any idea why i am getting this error. Here is the error log.

2018-06-04 10:46:48 PSTTraceback (most recent call last):
2018-06-04 10:46:48 PSTFile "gan.py", line 296, in <module>
2018-06-04 10:46:48 PSTtrain_network()
2018-06-04 10:46:48 PSTFile "gan.py", line 267, in train_network
2018-06-04 10:46:48 PSTsave_images(imgtest, [8,8] ,new_image_path + '/epoch' + str(i) + '.jpg')
2018-06-04 10:46:48 PSTFile "/code/utils.py", line 34, in save_images
2018-06-04 10:46:48 PSTreturn imsave(inverse_transform(images), size, image_path)
2018-06-04 10:46:48 PSTFile "/code/utils.py", line 67, in imsave
2018-06-04 10:46:48 PSTimage = np.squeeze(merge(images, size))
2018-06-04 10:46:48 PSTFile "/code/utils.py", line 53, in merge
2018-06-04 10:46:48 PSTimg[j * h:j * h + h, i * w:i * w + w, :] = image
2018-06-04 10:46:48 PSTValueError: could not broadcast input array from shape (128,128,3) into shape (0,128,3)

As soon as finish the first epoch this occurs.

        if i%50 == 0:
            # save images
            if not os.path.exists(new_image_path):
                os.makedirs(new_image_path)
            sample_noise = np.random.uniform(-1.0, 1.0, size=[batch_size, random_dim]).astype(np.float32)
            imgtest = sess.run(fake_image, feed_dict={random_input: sample_noise, is_train: False})
            # imgtest = imgtest * 255.0
            # imgtest.astype(np.uint8)
            save_images(imgtest, [8,8] ,new_image_path + '/epoch' + str(i) + '.png')  # <<<< HERE 

Result images a washed out. Problem with channels?

I've been trying to run this code with a separate collection of images. I keep running into a problem where the images are cloudy/washed-out. I've been looking through this previous issue raised here https://github.com/llSourcell/Pokemon_GAN/issues/9?_pjax=%23js-repo-pjax-container.

It seems to be an issue with the channels, but I can't seem to figure it out. I've already made sure that the images I'm working with are all .jpegs. Thanks for taking the time.

relu vs leaky relu

I noted that for activation relu is used in the generator and leaky relu is used in the Discriminator. Is there a particular reason behind this?

Number of Channels Should be 4

Hi, I just wanted to comment that you are using transparent images with 4 channels, but when you read them, you use 3 channels only. So why not change the input and output channels to be 4?

Error in RGBA2RGB.py

Sorry to bother, but there should be a

os.mkdir(dst)

before the for loop in RGBA2RGB.py to create the folder else it may give an error .
Was facing the problem so thought might point out!

Big fan :)

Doesn't continue training from checkpoint.

Hello,

I'm having a minor issue when trying to continue an interrupted training.

It is creating these files in /tmp/ as it's supposed to:
screen shot 2018-08-05 at 7 54 12 pm
And these under model/NewPokemon in my working directory:
screen shot 2018-08-05 at 7 54 56 pm

On other code I worked on, I would import the saved weights and biases with something like;

saver = tf.train.import_meta_graph('model.meta')
saver.restore(sess, tf.train.latest_checkpoint('./'))

On this code I just couldn't make it continue from where it is left off. It starts from 0 back again when I run PokeGAN.py even though I'm running inside the directory and the folder structure seems correct.

I haven't modified the code except the fact that, mine saves the model every epoch instead of every 500 - just changed the modulo i%500 to i%1.

Any help would be much appreciated.

Thanks very much!

Code questions.. or Typos?

These two questions came up, when I went threw the code:

  • In line 127 of pokeGan.py the bn1 tensor is created. But actually it is never used.. instead the next line continues with lrelu(conv1,...). Any reason for that?

  • Why is tanh used to generate the final images (line 113). Shouldn't the images values be between 0 and 1? So would not the sigmoid activation be the better choice here?

Any answers / ideas?

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.