Re-implement CycleGAN in Tensorlayer

Overview

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:

Comments
  • Difference from original code

    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.
    opened by taki0112 7
  • Color inversion, black image and nan in loss after ~20 epochs

    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)?

    opened by victor-felicitas 0
  • How to change test output size?

    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!

    opened by victor-felicitas 0
  • About the imagepool.

    About the imagepool.

    opened by Zardinality 0
  • Error in main.py?

    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.

    opened by yongqiangzhang1 2
  • Where are datasets shown in readme?

    Where are datasets shown in readme?

    opened by Zardinality 7
Releases(0.1)
PyTorch implementation of SmoothGrad: removing noise by adding noise.

SmoothGrad implementation in PyTorch PyTorch implementation of SmoothGrad: removing noise by adding noise. Vanilla Gradients SmoothGrad Guided backpro

SSKH 143 Jan 05, 2023
The Dual Memory is build from a simple CNN for the deep memory and Linear Regression fro the fast Memory

Simple-DMA a simple Dual Memory Architecture for classifications. based on the paper Dual-Memory Deep Learning Architectures for Lifelong Learning of

1 Jan 27, 2022
Doing fast searching of nearest neighbors in high dimensional spaces is an increasingly important problem

Benchmarking nearest neighbors Doing fast searching of nearest neighbors in high dimensional spaces is an increasingly important problem, but so far t

Erik Bernhardsson 3.2k Jan 03, 2023
The Power of Scale for Parameter-Efficient Prompt Tuning

The Power of Scale for Parameter-Efficient Prompt Tuning Implementation of soft embeddings from https://arxiv.org/abs/2104.08691v1 using Pytorch and H

Kip Parker 208 Dec 30, 2022
Infrastructure as Code (IaC) for a self-hosted version of Gnosis Safe on AWS

Welcome to Yearn Gnosis Safe! Setting up your local environment Infrastructure Deploying Gnosis Safe Prerequisites 1. Create infrastructure for secret

Numan 16 Jul 18, 2022
A full-fledged version of Pix2Seq

Stable-Pix2Seq A full-fledged version of Pix2Seq What it is. This is a full-fledged version of Pix2Seq. Compared with unofficial-pix2seq, stable-pix2s

peng gao 205 Dec 27, 2022
5 Jan 05, 2023
MacroTools provides a library of tools for working with Julia code and expressions.

MacroTools.jl MacroTools provides a library of tools for working with Julia code and expressions. This includes a powerful template-matching system an

FluxML 278 Dec 11, 2022
High performance Cross-platform Inference-engine, you could run Anakin on x86-cpu,arm, nv-gpu, amd-gpu,bitmain and cambricon devices.

Anakin2.0 Welcome to the Anakin GitHub. Anakin is a cross-platform, high-performance inference engine, which is originally developed by Baidu engineer

514 Dec 28, 2022
🧑‍🔬 verify your TEAL program by experiment and observation

Graviton - Testing TEAL with Dry Runs Tutorial Local Installation The following instructions assume that you have make available in your local environ

Algorand 18 Jan 03, 2023
RNN Predict Street Commercial Vitality

RNN-for-Predicting-Street-Vitality Code and dataset for Predicting the Vitality of Stores along the Street based on Business Type Sequence via Recurre

Zidong LIU 1 Dec 15, 2021
Code associated with the paper "Deep Optics for Single-shot High-dynamic-range Imaging"

Deep Optics for Single-shot High-dynamic-range Imaging Code associated with the paper "Deep Optics for Single-shot High-dynamic-range Imaging" CVPR, 2

Stanford Computational Imaging Lab 40 Dec 12, 2022
A Shading-Guided Generative Implicit Model for Shape-Accurate 3D-Aware Image Synthesis

A Shading-Guided Generative Implicit Model for Shape-Accurate 3D-Aware Image Synthesis Figure: Shape-Accurate 3D-Aware Image Synthesis. A Shading-Guid

Xingang Pan 115 Dec 18, 2022
A Human-in-the-Loop workflow for creating HD images from text

A Human-in-the-Loop? workflow for creating HD images from text DALL·E Flow is an interactive workflow for generating high-definition images from text

Jina AI 2.5k Jan 02, 2023
Adaptive, interpretable wavelets across domains (NeurIPS 2021)

Adaptive wavelets Wavelets which adapt given data (and optionally a pre-trained model). This yields models which are faster, more compressible, and mo

Yu Group 50 Dec 16, 2022
R interface to fast.ai

R interface to fastai The fastai package provides R wrappers to fastai. The fastai library simplifies training fast and accurate neural nets using mod

113 Dec 20, 2022
ECCV2020 paper: Fashion Captioning: Towards Generating Accurate Descriptions with Semantic Rewards. Code and Data.

This repo contains some of the codes for the following paper Fashion Captioning: Towards Generating Accurate Descriptions with Semantic Rewards. Code

Xuewen Yang 56 Dec 08, 2022
PyTorch Implementation of AnimeGANv2

PyTorch implementation of AnimeGANv2

4k Jan 07, 2023
Gin provides a lightweight configuration framework for Python

Gin Config Authors: Dan Holtmann-Rice, Sergio Guadarrama, Nathan Silberman Contributors: Oscar Ramirez, Marek Fiser Gin provides a lightweight configu

Google 1.7k Jan 03, 2023