Official Tensorflow implementation of U-GAT-IT: Unsupervised Generative Attentional Networks with Adaptive Layer-Instance Normalization for Image-to-Image Translation (ICLR 2020)

Related tags

Deep Learning UGATIT
Overview

U-GAT-IT — Official TensorFlow Implementation (ICLR 2020)

: Unsupervised Generative Attentional Networks with Adaptive Layer-Instance Normalization for Image-to-Image Translation

Paper | Official Pytorch code

This repository provides the official Tensorflow implementation of the following paper:

U-GAT-IT: Unsupervised Generative Attentional Networks with Adaptive Layer-Instance Normalization for Image-to-Image Translation
Junho Kim (NCSOFT), Minjae Kim (NCSOFT), Hyeonwoo Kang (NCSOFT), Kwanghee Lee (Boeing Korea)

Abstract We propose a novel method for unsupervised image-to-image translation, which incorporates a new attention module and a new learnable normalization function in an end-to-end manner. The attention module guides our model to focus on more important regions distinguishing between source and target domains based on the attention map obtained by the auxiliary classifier. Unlike previous attention-based methods which cannot handle the geometric changes between domains, our model can translate both images requiring holistic changes and images requiring large shape changes. Moreover, our new AdaLIN (Adaptive Layer-Instance Normalization) function helps our attention-guided model to flexibly control the amount of change in shape and texture by learned parameters depending on datasets. Experimental results show the superiority of the proposed method compared to the existing state-of-the-art models with a fixed network architecture and hyper-parameters.

Requirements

  • python == 3.6
  • tensorflow == 1.14

Pretrained model

We released 50 epoch and 100 epoch checkpoints so that people could test more widely.

Dataset

Web page

Telegram Bot

Usage

├── dataset
   └── YOUR_DATASET_NAME
       ├── trainA
           ├── xxx.jpg (name, format doesn't matter)
           ├── yyy.png
           └── ...
       ├── trainB
           ├── zzz.jpg
           ├── www.png
           └── ...
       ├── testA
           ├── aaa.jpg 
           ├── bbb.png
           └── ...
       └── testB
           ├── ccc.jpg 
           ├── ddd.png
           └── ...

Train

> python main.py --dataset selfie2anime
  • If the memory of gpu is not sufficient, set --light to True
    • But it may not perform well
    • paper version is --light to False

Test

> python main.py --dataset selfie2anime --phase test

Architecture


Results

Ablation study

User study

Kernel Inception Distance (KID)

Citation

If you find this code useful for your research, please cite our paper:

@inproceedings{
Kim2020U-GAT-IT:,
title={U-GAT-IT: Unsupervised Generative Attentional Networks with Adaptive Layer-Instance Normalization for Image-to-Image Translation},
author={Junho Kim and Minjae Kim and Hyeonwoo Kang and Kwang Hee Lee},
booktitle={International Conference on Learning Representations},
year={2020},
url={https://openreview.net/forum?id=BJlZ5ySKPH}
}

Author

Junho Kim, Minjae Kim, Hyeonwoo Kang, Kwanghee Lee

Comments
  • The course of true love never did run smooth

    The course of true love never did run smooth

    I just want to ask, at this speed, can I see the end of training in my lifetime?

    image

    Waiting for the pretrained model is wise for me, maybe... @taki0112

    opened by opentld 17
  • Name of output_node_names for .pb

    Name of output_node_names for .pb

    I'm trying to convert the checkpoint to .pb graph of Tensorflow.

    python3 freeze_graph.py --input_meta_graph=checkpoint/UGATIT_selfie2anime_lsgan_4resblock_6dis_1_1_10_10_1000_sn_smoothing/UGATIT.model-1000000.meta --input_checkpoint=checkpoint/UGATIT_selfie2anime_lsgan_4resblock_6dis_1_1_10_10_1000_sn_smoothing --output_graph=selfie2anime.pb --input_binary=True --output_node_names="???"

    What do I have to write in output_node_names?

    Thank you!

    opened by DiMiTriFrog 7
  • CAM loss is degrading the results

    CAM loss is degrading the results

    I'm using the light version of UGATIT for a project. The introduction of CAM loss seems to be degrading the quality of results.

    I'm wondering whether the CAM loss improves the model performance only in the case of a heavy model. Is it so? Any help is appreciated. Thank you.

    opened by sudarshanregmi 6
  • TypeError: Input 'filename' of 'ReadFile' Op has type float32 that does not match expected type of string.

    TypeError: Input 'filename' of 'ReadFile' Op has type float32 that does not match expected type of string.

    i see the error when i trained trainA = trainA.apply(shuffle_and_repeat(self.dataset_num)).apply(map_and_batch(Image_Data_Class.image_processing, self.batch_size, num_parallel_batches=16, drop_remainder=True)).apply(prefetch_to_device(gpu_device, None)) File "/home/terry/.local/lib/python2.7/site-packages/tensorflow/python/data/ops/dataset_ops.py", line 1109, in apply dataset = transformation_func(self) File "/home/terry/.local/lib/python2.7/site-packages/tensorflow/contrib/data/python/ops/batching.py", line 828, in _apply_fn num_parallel_calls, drop_remainder) File "/home/terry/.local/lib/python2.7/site-packages/tensorflow/contrib/data/python/ops/batching.py", line 740, in __init__ super(_MapAndBatchDataset, self).__init__(input_dataset, map_func) File "/home/terry/.local/lib/python2.7/site-packages/tensorflow/python/data/ops/dataset_ops.py", line 2198, in __init__ map_func, "Dataset.map()", input_dataset) File "/home/terry/.local/lib/python2.7/site-packages/tensorflow/python/data/ops/dataset_ops.py", line 1454, in __init__ self._function.add_to_graph(ops.get_default_graph()) File "/home/terry/.local/lib/python2.7/site-packages/tensorflow/python/framework/function.py", line 481, in add_to_graph self._create_definition_if_needed() File "/home/terry/.local/lib/python2.7/site-packages/tensorflow/python/framework/function.py", line 337, in _create_definition_if_needed self._create_definition_if_needed_impl() File "/home/terry/.local/lib/python2.7/site-packages/tensorflow/python/framework/function.py", line 346, in _create_definition_if_needed_impl self._capture_by_value, self._caller_device) File "/home/terry/.local/lib/python2.7/site-packages/tensorflow/python/framework/function.py", line 863, in func_graph_from_py_func outputs = func(*func_graph.inputs) File "/home/terry/.local/lib/python2.7/site-packages/tensorflow/python/data/ops/dataset_ops.py", line 1392, in tf_data_structured_function_wrapper ret = func(*nested_args) File "/opt/python/UGATIT/utils.py", line 15, in image_processing x = tf.read_file(filename) File "/home/terry/.local/lib/python2.7/site-packages/tensorflow/python/ops/gen_io_ops.py", line 528, in read_file "ReadFile", filename=filename, name=name) File "/home/terry/.local/lib/python2.7/site-packages/tensorflow/python/framework/op_def_library.py", line 533, in _apply_op_helper (prefix, dtypes.as_dtype(input_arg.type).name)) TypeError: Input 'filename' of 'ReadFile' Op has type float32 that does not match expected type of string.

    the usage was the following:python main.py --dataset mydataset --light true

    opened by biubiaa 5
  • How to train on multi GPU?

    How to train on multi GPU?

    Hi , I'm new to tensorflow, and I trained the model on a multi GPU server. But it took only ONE gpu. I want to make all of my gpus useful, is there a way to do so? Thank you.

    opened by creke 4
  • Error

    Error "Failed to find a checkpoint"

    Hi, fiorst of all thank you for this awesome Net! I was aiming to try it out, but got the error in the log:

    [*] Reading checkpoints...
    [*] Failed to find a checkpoint
    [!] Load failed...
    [*] Test finished! 
    

    the usage was the following: python main.py --sample_dir customfolder --phase test --light true where I put a folder next to the source code inside the repository. Inside the folder there was only an image 02.png on which I tried to test the net on.

    I have tried absolute path as well, but with the same error. Would you kindly show an example usage for only one picture, or folder? Thank you in advance!

    opened by davids91 4
  • I tried the train , but

    I tried the train , but "Failed to find a checkpoint".

    I tried the train using the test dataset , but "Failed to find a checkpoint". (in google colaboratory , tensorflow1.14.0) How can I solve this problem?

    !python main.py --dataset train --phase train ... [*] Reading checkpoints... [*] Failed to find a checkpoint [!] Load failed... ^C result_images

    opened by click-stack 3
  • oom question

    oom question

    I've met the oom question with a TITAN xp 12GB GPU while running the original model(256px , un-light mode)

    How much memory would be enough to succefully run the code , like loading the 100-epoch pre-trained model?

    opened by xwwwwww 3
  • A problem in function fully_connected_with_w()

    A problem in function fully_connected_with_w()

    In function fully_connected_with_w(), if parameter 'sn' is False, the else branch will get a variable 'w' with code w = tf.get_variable('kernel', shape=[channels, 1]). Is the purpose of this to get the weights in above dense layer? If so, shouldn't it be coded as w = tf.get_variable('dense/kernel', shape=[channels, 1])? https://github.com/taki0112/UGATIT/blob/master/ops.py#L74

    opened by zjuzxd94 3
  • This topic is so HOT! Files cannot be downloaded~~

    This topic is so HOT! Files cannot be downloaded~~

    When I downloaded these two files that taki0112 shared, the google drive tells me this:

    Sorry, you are currently unable to view or download this file. Too many users have recently viewed or downloaded this file. Try accessing this file again later. If the file you are trying to access is extremely large or Shared by many people, it can take up to 24 hours to view or download. If you are still unable to access the file after 24 hours, contact your domain administrator.

    Could anyone share another link? Thanks a lot~~

    opened by wangshisheng 3
  • Add support for MacOS?

    Add support for MacOS?

    After installing tensorflow and running

    python3 main.py --dataset selfie2anime

    I'm getting the following error on MacOS (10.14.5)

    TypeError: Input 'filename' of 'ReadFile' Op has type float32 that does not match expected type of string.

    opened by sfoley-gpqa 3
  • In paper,

    In paper, "5.3.2 AdaLIN analysis", how to use AdaIN for comparative experiments?

    Great work! But I have a question about "5.3.2 AdaLIN analysis" in your paper. AdaIN is a model that need a style feature and a content feature, and how to get style features when you done experiments? Thanks!!

    opened by Xccdd 1
  • Testing does not work!

    Testing does not work!

    I am trying to test the trained model using the command:

    python main.py --dataset maps --light True --phase test
    

    However, the testing always seems to fail loading the model weights. It finishes with the following output and without any generated images:

    . . .
    
    ##### Weight #####
    # adv_weight :  1
    # cycle_weight :  10
    # identity_weight :  10
    # cam_weight :  1000
     [*] Load FAILURE
     [*] Test finished!
    
    opened by Lauenburg 0
  • Augmentation probability

    Augmentation probability

    https://github.com/taki0112/UGATIT/blob/d508e8f5188e47000d79d8aecada0cc9119e0d56/utils.py#L23-L24

    With this piece of code, we make sure that the augmentation is provided with a probability of 0.5. In the paper, it is written that the horizontal flip is done with a probability of 0.5 and then the random crops are taken (assuming with a probability of 1, ie all the time).

    For data augmentation, we flipped the images horizontally with a probability of 0.5, resized them to 286 x 286, and random cropped them to 256 x 256.

    With the implementation of the code, the statement in the paper becomes untrue, here the horizontal flip probability becomes 0.5*0.5=0.25 and the random crop probability becomes 0.5.

    Is this intended behaviour?

    opened by ariG23498 0
  • Pre-trained model provided on googl drive looks broken

    Pre-trained model provided on googl drive looks broken

    Hi,

    I was trying to extract zip files that uploaded on Google Drive that you provided

    They assume to be broken URLS as it says error: invalid zip file with overlapped components (possible zip bomb)

    I tried both of URLS and they do not work.

    opened by gyupro 1
Owner
Junho Kim
Research Scientist
Junho Kim
[CVPR 2021] Region-aware Adaptive Instance Normalization for Image Harmonization

RainNet — Official Pytorch Implementation Region-aware Adaptive Instance Normalization for Image Harmonization Jun Ling, Han Xue, Li Song*, Rong Xie,

null 130 Dec 11, 2022
IAST: Instance Adaptive Self-training for Unsupervised Domain Adaptation (ECCV 2020)

This repo is the official implementation of our paper "Instance Adaptive Self-training for Unsupervised Domain Adaptation". The purpose of this repo is to better communicate with you and respond to your questions. This repo is almost the same with Another-Version, and you can also refer to that version.

CVSM Group -  email: czhu@bupt.edu.cn 84 Dec 12, 2022
Pytorch implementation of the paper "Enhancing Content Preservation in Text Style Transfer Using Reverse Attention and Conditional Layer Normalization"

Pytorch implementation of the paper "Enhancing Content Preservation in Text Style Transfer Using Reverse Attention and Conditional Layer Normalization"

Dongkyu Lee 4 Sep 18, 2022
Code for "On the Effects of Batch and Weight Normalization in Generative Adversarial Networks"

Note: this repo has been discontinued, please check code for newer version of the paper here Weight Normalized GAN Code for the paper "On the Effects

Sitao Xiang 182 Sep 6, 2021
pytorch implementation of "Contrastive Multiview Coding", "Momentum Contrast for Unsupervised Visual Representation Learning", and "Unsupervised Feature Learning via Non-Parametric Instance-level Discrimination"

Unofficial implementation: MoCo: Momentum Contrast for Unsupervised Visual Representation Learning (Paper) InsDis: Unsupervised Feature Learning via N

Zhiqiang Shen 16 Nov 4, 2020
HINet: Half Instance Normalization Network for Image Restoration

HINet: Half Instance Normalization Network for Image Restoration Liangyu Chen, Xin Lu, Jie Zhang, Xiaojie Chu, Chengpeng Chen Paper: https://arxiv.org

null 303 Dec 31, 2022
Half Instance Normalization Network for Image Restoration

HINet Half Instance Normalization Network for Image Restoration, based on https://github.com/megvii-model/HINet. Dependencies NumPy PyTorch, preferabl

Holy Wu 4 Jun 6, 2022
[ICLR'21] FedBN: Federated Learning on Non-IID Features via Local Batch Normalization

FedBN: Federated Learning on Non-IID Features via Local Batch Normalization This is the PyTorch implemention of our paper FedBN: Federated Learning on

Med-AIR@CUHK 156 Dec 15, 2022
Towards Ultra-Resolution Neural Style Transfer via Thumbnail Instance Normalization

Towards Ultra-Resolution Neural Style Transfer via Thumbnail Instance Normalization Official PyTorch implementation for our URST (Ultra-Resolution Sty

czczup 148 Dec 27, 2022
[ICLR 2021, Spotlight] Large Scale Image Completion via Co-Modulated Generative Adversarial Networks

Large Scale Image Completion via Co-Modulated Generative Adversarial Networks, ICLR 2021 (Spotlight) Demo | Paper [NEW!] Time to play with our interac

Shengyu Zhao 373 Jan 2, 2023
Spatially-Adaptive Pixelwise Networks for Fast Image Translation, CVPR 2021

Image Translation with ASAPNets Spatially-Adaptive Pixelwise Networks for Fast Image Translation, CVPR 2021 Webpage | Paper | Video Installation insta

Tamar Rott Shaham 100 Dec 28, 2022
PyTorch implementation of Lip to Speech Synthesis with Visual Context Attentional GAN (NeurIPS2021)

Lip to Speech Synthesis with Visual Context Attentional GAN This repository contains the PyTorch implementation of the following paper: Lip to Speech

null 6 Nov 2, 2022
CoaT: Co-Scale Conv-Attentional Image Transformers

CoaT: Co-Scale Conv-Attentional Image Transformers Introduction This repository contains the official code and pretrained models for CoaT: Co-Scale Co

mlpc-ucsd 191 Dec 3, 2022
Official implementation of "DSP: Dual Soft-Paste for Unsupervised Domain Adaptive Semantic Segmentation"

DSP Official implementation of "DSP: Dual Soft-Paste for Unsupervised Domain Adaptive Semantic Segmentation". Accepted by ACM Multimedia 2021. Authors

null 20 Oct 24, 2022
This is the official pytorch implementation for the paper: Instance Similarity Learning for Unsupervised Feature Representation.

ISL This is the official pytorch implementation for the paper: Instance Similarity Learning for Unsupervised Feature Representation, which is accepted

null 19 May 4, 2022
[ICLR'21] Counterfactual Generative Networks

This repository contains the code for the ICLR 2021 paper "Counterfactual Generative Networks" by Axel Sauer and Andreas Geiger. If you want to take the CGN for a spin and generate counterfactual images, you can try out the Colab below.

null 88 Jan 2, 2023
Understanding and Improving Encoder Layer Fusion in Sequence-to-Sequence Learning (ICLR 2021)

Understanding and Improving Encoder Layer Fusion in Sequence-to-Sequence Learning (ICLR 2021) Citation Please cite as: @inproceedings{liu2020understan

Sunbow Liu 22 Nov 25, 2022
A supplementary code for Editable Neural Networks, an ICLR 2020 submission.

Editable neural networks A supplementary code for Editable Neural Networks, an ICLR 2020 submission by Anton Sinitsin, Vsevolod Plokhotnyuk, Dmitry Py

Anton Sinitsin 32 Nov 29, 2022
Official codebase for ICLR oral paper Unsupervised Vision-Language Grammar Induction with Shared Structure Modeling

CLIORA This is the official codebase for ICLR oral paper: Unsupervised Vision-Language Grammar Induction with Shared Structure Modeling. We introduce

Bo Wan                                             32 Dec 23, 2022