Unsupervised Image-to-Image Translation

Overview

License CC BY-NC-SA 4.0 Python 2.7

UNIT: UNsupervised Image-to-image Translation Networks

Imaginaire Repository

We have a reimplementation of the UNIT method that is more performant. It is avaiable at Imaginaire

License

Copyright (C) 2018 NVIDIA Corporation. All rights reserved. Licensed under the CC BY-NC-SA 4.0 license (https://creativecommons.org/licenses/by-nc-sa/4.0/legalcode).

Code usage

  • Please check out our tutorial.

  • For multimodal (or many-to-many) image translation, please check out our new work on MUNIT.

What's new.

  • 05-02-2018: We now adapt MUNIT code structure. For reproducing experiment results in the NIPS paper, please check out version_02 branch.

  • 12-21-2017: Release pre-trained synthia-to-cityscape image translation model. See USAGE.md for usage examples.

  • 12-14-2017: Added multi-scale discriminators described in the pix2pixHD paper. To use it simply make the name of the discriminator COCOMsDis.

Paper

Ming-Yu Liu, Thomas Breuel, Jan Kautz, "Unsupervised Image-to-Image Translation Networks" NIPS 2017 Spotlight, arXiv:1703.00848 2017

Two Minute Paper Summary

(We thank the Two Minute Papers channel for summarizing our work.)

The Shared Latent Space Assumption

Result Videos

More image results are available in the Google Photo Album.

Left: input. Right: neural network generated. Resolution: 640x480

Left: input. Right: neural network generated. Resolution: 640x480

Street Scene Image Translation

From the first row to the fourth row, we show example results on day to night, sunny to rainy, summery to snowy, and real to synthetic image translation (two directions).

For each image pair, left is the input image; right is the machine generated image.

Dog Breed Image Translation

Cat Species Image Translation

Attribute-based Face Image Translation

Comments
  • Details about IR/RGB conversion

    Details about IR/RGB conversion

    Hi, Mingyu. I'm studying your amazing work about UNIT, and I'm very interested in UNIT's attractive poteintial of IR/RGB conversion. So I tried to repeat the experiment. Since the detailed parameters of training are not provided, I just tried borrowing settings in synthia2cityscape.yaml for the training. But the results were not satisfying. So I'm wondering is it right for me to do so? If it's not right to borrow settings in synthia2cityscape.yaml, is there any possibility that settings for IR/RGB conversion may be released? Thanks for your attention and amazing work:)

    opened by xelmirage 17
  • a question about vgg16.t7

    a question about vgg16.t7

    Hello, I downloaded the vgg16.t7 manually, when I ran"load_lua(r"D:\Progarm Files\eclipse\preferences\UNIT\vgg16.t7")", I got this error message:"unknown type id 1056626884. The file may be corrupted." Why is this problem? I had downloaded it several times.

    Thank you for your answer.

    opened by Linlin0611 16
  • Tensorboard summary writer error

    Tensorboard summary writer error

    I am running version_01, and I am facing problems with the summary writer.

    1. this line throws the following error:

    AttributeError: 'module' object has no attribute 'FileWriter'

    So, I replaced it with the following line:

    train_writer = tf.summary.FileWriter("%s/%s" % (opts.log,os.path.splitext(os.path.basename(opts.config))[0]))
    

    Upon doing so the program runs fine, until this line.

    The error it throws is:

    in add_summary for value in summary.value: AttributeError: 'Tensor' object has no attribute 'value'

    Can anybody please point out the change I need to make.

    opened by groot-1313 16
  • Hyperparameter information

    Hyperparameter information

    Hi ! I am reproducing your code with tensorflow. But I do not know the current hyperparameter information. (batch size, input size, dropout rate, etc.) Could you tell me which code I can check?

    opened by taki0112 15
  • 3 Questions

    3 Questions

    Hi ! *** Q1 *** When using Image translation, did you not use augmentation? I want to know about this, but I can not find it in your code

    *** Q2 *** For example, suppose I want to convert from domain_A (dog) to domain_B (cat). (domainA -> domain_B)

    Assume that the number of dog images in domain_A is 1000, and the number of cat images in domain_B is 1500. (That means # domainA < # domainB)

    If so, how do I train? I think the learning imbalance will happen because the number of data in two domains is different. Did you make the number of images in both domains the same?

    *** Q3 *** Generator_loss = G_A_loss + G_B_loss Discriminator_loss = D_A_loss + D_B_loss

    When you train Generator A and B, why did you train with sum of two loss(Generator_loss), instead of training about G_A_loss and G_B_loss, respectively? Likewise, why did the Discriminator do so?

    opened by taki0112 10
  • RuntimeError in python3

    RuntimeError in python3

    Hi! Thank you very much for sharing your code. I encountered some error when training from scratch with celeba blond hair translation using python 3 according to the usage. The itertool.izip in python2 is changed to the built-in zip in python3:

    Traceback (most recent call last): File "cocogan_train.py", line 88, in <module> main(sys.argv) File "cocogan_train.py", line 56, in main for it, (images_a, images_b) in enumerate(zip(train_loader_a,train_loader_b)): File "/home/fox/anaconda3/lib/python3.5/site-packages/torch/utils/data/dataloader.py", line 301, in __iter__ return DataLoaderIter(self) File "/home/fox/anaconda3/lib/python3.5/site-packages/torch/utils/data/dataloader.py", line 171, in __init__ self._put_indices() File "/home/fox/anaconda3/lib/python3.5/site-packages/torch/utils/data/dataloader.py", line 210, in _put_indices indices = next(self.sample_iter, None) File "/home/fox/anaconda3/lib/python3.5/site-packages/torch/utils/data/sampler.py", line 115, in __iter__ for idx in self.sampler: File "/home/fox/anaconda3/lib/python3.5/site-packages/torch/utils/data/sampler.py", line 50, in __iter__ return iter(torch.randperm(len(self.data_source)).long()) RuntimeError: invalid argument 1: must be strictly positive at /opt/conda/conda-bld/pytorch_1503968623488/work/torch/lib/TH/generic/THTensorMath.c:2033 How can I fix this problem?

    opened by CherylZR 8
  • Config Day2Night | Split Datasets

    Config Day2Night | Split Datasets

    Hi, there, i'm trying to train dataset and stucked with some learning problems

    Example of 10000 iterations day 2 night (train) image Example of 10000 iterations night 2 day (train) image

    I think that it's unit_day2night.yaml configuration problem. Can you share yours config file?


    Another option, that it's dataset's split issue. I used 50/50 for train and test. And both divided into two equal domains A and B.

    opened by solesensei 7
  • Test time z vector representation

    Test time z vector representation

    Hi I couldnt find in the paper or understand from the code what you are doing during test time in the next manner:

    On train time you insert noise and you compute the mu and sd and represent z as a random vector.

    What happens during test time, cause i dont see you do the same, do you use the average mu and sd or something else? i would love to know.

    thanks, Gal.

    opened by galsk87 7
  • No module named 'net_config'

    No module named 'net_config'

    Hi, I tried to run the training with CelebA dataset, and got the following error when I started train :

    Traceback (most recent call last): File "cocogan_train.py", line 6, in from tools import * File "/home/paperspace/Downloads/UNIT/src/tools/init.py", line 6, in from net_config import * ModuleNotFoundError: No module named 'net_config'

    Do you have any hints I could solve it? thanks!

    opened by chikiuso 5
  • Discriminator update rule in domain adaptation and domain translation

    Discriminator update rule in domain adaptation and domain translation

    Dear M. Liu,

    I am studying your paper that I found very interesting, thank you for sharing your research ! I read the other issues/questions asked, where you pointed that some explanations were not given in the paper, about that I would like to ask you more details about the domain adaptation experiment.

    Could you explain the discriminator update rule and more precisely when you compute that please ? feature_loss_a = self._compute_ll_loss(fake_feat_ab - fake_feat_aa, dummy_variable) feature_loss_b = self._compute_ll_loss(fake_feat_ba - fake_feat_bb, dummy_variable) (cocogan_trainer_da.py lines 102-103)

    Also, my experiments focus more on domain translation than domain adaptation. For that purpose, is this update rule still relevant ?

    Thank you for your answer. Adrien

    opened by adrienchaton 4
  • Accuracy

    Accuracy

    I am getting low accuracy. May I know why ?

    $python cocogan_train_domain_adaptation.py --config ../exps/unit/svhn2mnist.yaml --log ../logs

    Iteration: 00000010/00200000 Iteration: 00000020/00200000 Iteration: 00000030/00200000 Iteration: 00000040/00200000 Iteration: 00000050/00200000 Iteration: 00000060/00200000 Iteration: 00000070/00200000 Iteration: 00000080/00200000 Iteration: 00000090/00200000 Iteration: 00000100/00200000 Classification accuracy for Test_B dataset: 0.1296 Iteration: 00000110/00200000 Iteration: 00000120/00200000 Iteration: 00000130/00200000 Iteration: 00000140/00200000 Iteration: 00000150/00200000 Iteration: 00000160/00200000 Iteration: 00000170/00200000 Iteration: 00000180/00200000 Iteration: 00000190/00200000 Iteration: 00000200/00200000 Classification accuracy for Test_B dataset: 0.1032 Iteration: 00000210/00200000 Iteration: 00000220/00200000 Iteration: 00000230/00200000 Iteration: 00000240/00200000 Iteration: 00000250/00200000 Iteration: 00000260/00200000 Iteration: 00000270/00200000 Iteration: 00000280/00200000 Iteration: 00000290/00200000 Iteration: 00000300/00200000 Classification accuracy for Test_B dataset: 0.1084 Iteration: 00000310/00200000 Iteration: 00000320/00200000 Iteration: 00000330/00200000 Iteration: 00000340/00200000 Iteration: 00000350/00200000 Iteration: 00000360/00200000 Iteration: 00000370/00200000 Iteration: 00000380/00200000 Iteration: 00000390/00200000 Iteration: 00000400/00200000 Classification accuracy for Test_B dataset: 0.0826 Iteration: 00000410/00200000 Iteration: 00000420/00200000 Iteration: 00000430/00200000 Iteration: 00000440/00200000 Iteration: 00000450/00200000 Iteration: 00000460/00200000 Iteration: 00000470/00200000 Iteration: 00000480/00200000 Iteration: 00000490/00200000 Iteration: 00000500/00200000 Classification accuracy for Test_B dataset: 0.0984 Iteration: 00000510/00200000 Iteration: 00000520/00200000 Iteration: 00000530/00200000 Iteration: 00000540/00200000 Iteration: 00000550/00200000 Iteration: 00000560/00200000 Iteration: 00000570/00200000 Iteration: 00000580/00200000 Iteration: 00000590/00200000 Iteration: 00000600/00200000 Classification accuracy for Test_B dataset: 0.0912 Iteration: 00000610/00200000 Iteration: 00000620/00200000 Iteration: 00000630/00200000 Iteration: 00000640/00200000 Iteration: 00000650/00200000 Iteration: 00000660/00200000 Iteration: 00000670/00200000 Iteration: 00000680/00200000 Iteration: 00000690/00200000 Iteration: 00000700/00200000 Classification accuracy for Test_B dataset: 0.0819

    opened by redhat12345 4
Owner
Ming-Yu Liu 劉洺堉
Ming-Yu Liu 劉洺堉
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
This repository contains several image-to-image translation models, whcih were tested for RGB to NIR image generation. The models are Pix2Pix, Pix2PixHD, CycleGAN and PointWise.

RGB2NIR_Experimental This repository contains several image-to-image translation models, whcih were tested for RGB to NIR image generation. The models

null 5 Jan 4, 2023
Code of U2Fusion: a unified unsupervised image fusion network for multiple image fusion tasks, including multi-modal, multi-exposure and multi-focus image fusion.

U2Fusion Code of U2Fusion: a unified unsupervised image fusion network for multiple image fusion tasks, including multi-modal (VIS-IR, medical), multi

Han Xu 129 Dec 11, 2022
Image-to-Image Translation with Conditional Adversarial Networks (Pix2pix) implementation in keras

pix2pix-keras Pix2pix implementation in keras. Original paper: Image-to-Image Translation with Conditional Adversarial Networks (pix2pix) Paper Author

William Falcon 141 Dec 30, 2022
Official pytorch implementation of paper "Image-to-image Translation via Hierarchical Style Disentanglement".

HiSD: Image-to-image Translation via Hierarchical Style Disentanglement Official pytorch implementation of paper "Image-to-image Translation

null 364 Dec 14, 2022
This is the PyTorch implementation of GANs N’ Roses: Stable, Controllable, Diverse Image to Image Translation

Official PyTorch repo for GAN's N' Roses. Diverse im2im and vid2vid selfie to anime translation.

null 1.1k Jan 1, 2023
PyTorch implementation of "Image-to-Image Translation Using Conditional Adversarial Networks".

pix2pix-pytorch PyTorch implementation of Image-to-Image Translation Using Conditional Adversarial Networks. Based on pix2pix by Phillip Isola et al.

mrzhu 383 Dec 17, 2022
Image-to-Image Translation in PyTorch

CycleGAN and pix2pix in PyTorch New: Please check out contrastive-unpaired-translation (CUT), our new unpaired image-to-image translation model that e

Jun-Yan Zhu 19k Jan 7, 2023
Breaking the Dilemma of Medical Image-to-image Translation

Breaking the Dilemma of Medical Image-to-image Translation Supervised Pix2Pix and unsupervised Cycle-consistency are two modes that dominate the field

Kid Liet 86 Dec 21, 2022
Maximum Spatial Perturbation for Image-to-Image Translation (Official Implementation)

MSPC for I2I This repository is by Yanwu Xu and contains the PyTorch source code to reproduce the experiments in our CVPR2022 paper Maximum Spatial Pe

null 51 Dec 14, 2022
A series of convenience functions to make basic image processing operations such as translation, rotation, resizing, skeletonization, and displaying Matplotlib images easier with OpenCV and Python.

imutils A series of convenience functions to make basic image processing functions such as translation, rotation, resizing, skeletonization, and displ

Adrian Rosebrock 4.3k Jan 8, 2023
a morph transfer UGATIT for image translation.

Morph-UGATIT a morph transfer UGATIT for image translation. Introduction 中文技术文档 This is Pytorch implementation of UGATIT, paper "U-GAT-IT: Unsupervise

null 55 Nov 14, 2022
CVPR 2021: "The Spatially-Correlative Loss for Various Image Translation Tasks"

Spatially-Correlative Loss arXiv | website We provide the Pytorch implementation of "The Spatially-Correlative Loss for Various Image Translation Task

Chuanxia Zheng 89 Jan 4, 2023
Framework for joint representation learning, evaluation through multimodal registration and comparison with image translation based approaches

CoMIR: Contrastive Multimodal Image Representation for Registration Framework ?? Registration of images in different modalities with Deep Learning ??

Methods for Image Data Analysis - MIDA 55 Dec 9, 2022
CoCosNet v2: Full-Resolution Correspondence Learning for Image Translation

CoCosNet v2: Full-Resolution Correspondence Learning for Image Translation (CVPR 2021, oral presentation) CoCosNet v2: Full-Resolution Correspondence

Microsoft 308 Dec 7, 2022
Unbalanced Feature Transport for Exemplar-based Image Translation (CVPR 2021)

UNITE and UNITE+ Unbalanced Feature Transport for Exemplar-based Image Translation (CVPR 2021) Unbalanced Intrinsic Feature Transport for Exemplar-bas

Fangneng Zhan 183 Nov 9, 2022
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
Official pytorch implementation of "Scaling-up Disentanglement for Image Translation", ICCV 2021.

Official pytorch implementation of "Scaling-up Disentanglement for Image Translation", ICCV 2021.

Aviv Gabbay 41 Nov 29, 2022
Code of Adverse Weather Image Translation with Asymmetric and Uncertainty aware GAN

Adverse Weather Image Translation with Asymmetric and Uncertainty-aware GAN (AU-GAN) Official Tensorflow implementation of Adverse Weather Image Trans

Jeong-gi Kwak 36 Dec 26, 2022