Giter Club home page Giter Club logo

cyclegan_tensorlayer's Introduction

CycleGAN_Tensorlayer

Re-implement CycleGAN in TensorLayer

  • Original CycleGAN
  • Improved CycleGAN with resize-convolution

Prerequisites:

  • TensorLayer
  • TensorFlow
  • Python

Run:

CUDA_VISIBLE_DEVICES=0 python main.py 

(if datasets are collected by yourself, you can use dataset_clean.py or dataset_crop.py to pre-process images)

Theory:

The generator process:

Image text

The discriminator process:

Image text

Result Improvement

  • Data augmentation
  • Resize convolution[4]
  • Instance normalization[5]

data augmentation:

Image text

Instance normalization(comparision by original paper https://arxiv.org/abs/1607.08022):

Image text

Resize convolution (Remove Checkerboard Artifacts):

Image text

Image text

Final Results:

Image text

Image text

Reference:

cyclegan_tensorlayer's People

Contributors

luoxier avatar zsdonghao 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

cyclegan_tensorlayer's Issues

How to change test output size?

Hi!
It is a great implementation of Cyclegan, providing excellent results on Hiptensorflow and ROCm.
However, I could not use it to generate test images of different from 256x256 sizes.
How can I change that?

For now, I have trained the model on 256x256 images and try to test it on bigger ones.
I tried adding two more flags to main.py:
flags.DEFINE_integer("image_width", 420, "The size of image to use (will be center cropped) [256]")
flags.DEFINE_integer("image_height", 420, "The size of image to use (will be center cropped) [256]")

Which I use later in Test section:
test_A = tf.placeholder(tf.float32, [FLAGS.batch_size, FLAGS.image_height, FLAGS.image_width, FLAGS.c_dim],
name='test_x')
test_B = tf.placeholder(tf.float32, [FLAGS.batch_size, FLAGS.image_height, FLAGS.image_width, FLAGS.c_dim],
name='test_y')

However, I always get error:
Invalid argument: Conv2DSlowBackpropInput: Size of out_backprop doesn't match computed: actual = 105, computed = 64
Traceback (most recent call last):
File "main.py", line 285, in
tf.app.run()
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/platform/app.py", line 44, in run
_sys.exit(main(_sys.argv[:1] + flags_passthrough))
File "main.py", line 281, in main
test_cyclegan()
File "main.py", line 262, in test_cyclegan
fake_img = sess.run(net_g_logits, feed_dict={in_var: sample_image})
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py", line 767, in run
run_metadata_ptr)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py", line 965, in _run
feed_dict_string, options, run_metadata)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py", line 1015, in _do_run
target_list, options, run_metadata)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py", line 1035, in _do_call
raise type(e)(node_def, op, message)
tensorflow.python.framework.errors_impl.InvalidArgumentError: Conv2DSlowBackpropInput: Size of out_backprop doesn't match computed: actual = 105, computed = 64
[[Node: gen_A2B/u64/conv2d_transpose = Conv2DBackpropInput[T=DT_FLOAT, data_format="NHWC", padding="SAME", strides=[1, 2, 2, 1], use_cudnn_on_gpu=true, _device="/job:localhost/replica:0/task:0/gpu:0"](gen_A2B/u64/conv2d_transpose/output_shape, gen_A2B/u64/W_deconv2d/read, gen_A2B/b_residual_add/8)]]

Is there any way to choose output image size?
Original Cyclegan has special option to choose it - how can i implement it?
resize_or_crop = 'resize_and_crop', -- resizing/cropping strategy: resize_and_crop | crop | scale_width | scale_height

Any help would be appreciated!

Error in main.py?

Hi @zsdonghao @luoxier ,
Is there an error in your main.py:
_, errGB2A = sess.run([g_b2a_optim, g_b2a_loss], feed_dict={real_A: batch_imgB, real_B: batch_imgB})
Does it should be:
_, errGB2A = sess.run([g_b2a_optim, g_b2a_loss], feed_dict={real_A: batch_imgA, real_B: batch_imgB})
Could you please check it and let me know, thanks.

Color inversion, black image and nan in loss after ~20 epochs

I've tried to train the model on original summer2winter_yosemite dataset.
After ~20 epochs all sample images turned completely black, and all all loss parameters turned to nan.
However, the model continued to run for 30 more epochs regularly saving checkpoints until I stopped it.

I've also used another, my own dataset, and it ran correctly for 70 epochs at least, unfortunately the only result I had was color inversion of images.
Any advice on changing training parameters (I used default)?

Difference from original code

HI
very nice implemented cyclegan
I have a few questions...

  1. What does "Resize Convolution" mean?
  2. I wonder what is different from the original code of the author.

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.