PyTorch implementation for ComboGAN

Overview

ComboGAN

This is our ongoing PyTorch implementation for ComboGAN. Code was written by Asha Anoosheh (built upon CycleGAN)

[ComboGAN Paper]

If you use this code for your research, please cite:

ComboGAN: Unrestrained Scalability for Image Domain Translation Asha Anoosheh, Eirikur Augustsson, Radu Timofte, Luc van Gool In Arxiv, 2017.





Prerequisites

  • Linux or macOS
  • Python 3
  • CPU or NVIDIA GPU + CUDA CuDNN

Getting Started

Installation

  • Install PyTorch and dependencies from http://pytorch.org
  • Install Torch vision from the source.
git clone https://github.com/pytorch/vision
cd vision
python setup.py install
pip install visdom
pip install dominate
  • Clone this repo:
git clone https://github.com/AAnoosheh/ComboGAN.git
cd ComboGAN

ComboGAN training

Our ready datasets can be downloaded using ./datasets/download_dataset.sh .

A pretrained model for the 14-painters dataset can be found HERE. Place under ./checkpoints/ and test using the instructions below, with args --name paint14_pretrained --dataroot ./datasets/painters_14 --n_domains 14 --which_epoch 1150.

Example running scripts can be found in the scripts directory.

  • Train a model:
python train.py --name 
   
     --dataroot ./datasets/
    
      --n_domains 
     
       --niter 
      
        --niter_decay 
        
       
      
     
    
   

Checkpoints will be saved by default to ./checkpoints/ /

  • Fine-tuning/Resume training:
python train.py --continue_train --which_epoch 
   
     --name 
    
      --dataroot ./datasets/
     
       --n_domains 
      
        --niter 
       
         --niter_decay 
         
        
       
      
     
    
   
  • Test the model:
python test.py --phase test --name 
   
     --dataroot ./datasets/
    
      --n_domains 
     
       --which_epoch 
      
        --serial_test

      
     
    
   

The test results will be saved to a html file here: ./results/ / /index.html .

Training/Testing Details

  • Flags: see options/train_options.py for training-specific flags; see options/test_options.py for test-specific flags; and see options/base_options.py for all common flags.
  • Dataset format: The desired data directory (provided by --dataroot) should contain subfolders of the form train*/ and test*/, and they are loaded in alphabetical order. (Note that a folder named train10 would be loaded before train2, and thus all checkpoints and results would be ordered accordingly.)
  • CPU/GPU (default --gpu_ids 0): set--gpu_ids -1 to use CPU mode; set --gpu_ids 0,1,2 for multi-GPU mode. You need a large batch size (e.g. --batchSize 32) to benefit from multiple GPUs.
  • Visualization: during training, the current results and loss plots can be viewed using two methods. First, if you set --display_id > 0, the results and loss plot will appear on a local graphics web server launched by visdom. To do this, you should have visdom installed and a server running by the command python -m visdom.server. The default server URL is http://localhost:8097. display_id corresponds to the window ID that is displayed on the visdom server. The visdom display functionality is turned on by default. To avoid the extra overhead of communicating with visdom set --display_id 0. Secondly, the intermediate results are also saved to ./checkpoints/ /web/index.html . To avoid this, set the --no_html flag.
  • Preprocessing: images can be resized and cropped in different ways using --resize_or_crop option. The default option 'resize_and_crop' resizes the image to be of size (opt.loadSize, opt.loadSize) and does a random crop of size (opt.fineSize, opt.fineSize). 'crop' skips the resizing step and only performs random cropping. 'scale_width' resizes the image to have width opt.fineSize while keeping the aspect ratio. 'scale_width_and_crop' first resizes the image to have width opt.loadSize and then does random cropping of size (opt.fineSize, opt.fineSize).

NOTE: one should not expect ComboGAN to work on just any combination of input and output datasets (e.g. dogs<->houses). We find it works better if two datasets share similar visual content. For example, landscape painting<->landscape photographs works much better than portrait painting <-> landscape photographs.

Comments
  • Test problem

    Test problem

    There is something wrong when I try to test my own dataset, I've already trained my models and now I want to generate a new dataset so I write this command in my terminal :python test.py --phase test --name dimmer --dataroot ./datasets/stanfordcars/test0_day --n_domains 2 --which_epoch 195 --serial_test

    opened by WeeshawChen 5
  • Testing all Images from Test Folder

    Testing all Images from Test Folder

    Hi,

    I have 1000 images in each test folders. I need to generate images from all the test images. I have 3 domains. So, I need to generate 1000 * 3 = 3000 images from one test folders. Please let me know how can I do that?

    opened by redhat12345 4
  • Dataset Error 404: not found

    Dataset Error 404: not found

    Hi, thanks for your work! I have tried to download datasets by download_dataset.sh scripts and wget but failed. I have noticed issue3 and 2. But it still doesn't work. 微信截图_20190326075338

    opened by bdseal 2
  • The number of testing images?

    The number of testing images?

    Thanks for you sharing your excellent codes. But a problem confused me. The Alps Seasons dataset has 400 testing images, however, after doing testing, I obtained 1240 images in folder "image", why is not 400*5=2000 images generated rather 1240 images?

    opened by happsky 2
  • --netG_n_shared flag

    --netG_n_shared flag

    Hi, I was wondering what exactly this --netG_n_shared flag is for ? What I understood is that these are the Resblocks shared by all encoders (they help bring the different images into the same shared latent space) right?

    The problem is that when I change the default value (zero) of the flag I get a Cuda issue:

    RuntimeError: chunk expects at least a 1-dimensional tensor (chunk at /pytorch/aten/src/ATen/native/TensorShape.cpp:186) frame #0: std::function<std::string ()>::operator()() const + 0x11 (0x7f44f02bb441 in /usr/lib/python3.7/site-packages/torch/lib/libc10.so) frame #1: c10::Error::Error(c10::SourceLocation, std::string const&) + 0x2a (0x7f44f02bad7a in /usr/lib/python3.7/site-packages/torch/lib/libc10.so) frame #2: at::native::chunk(at::Tensor const&, long, long) + 0x1f3 (0x7f449c7dbf93 in /usr/lib/python3.7/site-packages/torch/lib/libcaffe2.so) frame #3: at::TypeDefault::chunk(at::Tensor const&, long, long) const + 0x12 (0x7f449ca3a442 in /usr/lib/python3.7/site-packages/torch/lib/libcaffe2.so) frame #4: torch::autograd::VariableType::chunk(at::Tensor const&, long, long) const + 0x282 (0x7f449ae270c2 in /usr/lib/python3.7/site-packages/torch/lib/libtorch.so.1) frame #5: torch::cuda::scatter(at::Tensor const&, c10::ArrayRef, c10::optional<std::vector<long, std::allocator > > const&, long, c10::optional<std::vector<c10::optionalc10::cuda::CUDAStream, std::allocator<c10::optionalc10::cuda::CUDAStream > > > const&) + 0x5ad (0x7f449b38a1fd in /usr/lib/python3.7/site-packages/torch/lib/libtorch.so.1) frame #6: + 0x5a41cf (0x7f44f0a781cf in /usr/lib/python3.7/site-packages/torch/lib/libtorch_python.so) frame #7: + 0x130fac (0x7f44f0604fac in /usr/lib/python3.7/site-packages/torch/lib/libtorch_python.so) frame #15: THPFunction_apply(_object*, _object*) + 0x6b1 (0x7f44f0888301 in /usr/lib/python3.7/site-packages/torch/lib/libtorch_python.so)

    opened by Ibrahim-Halfaoui 1
  • training hours

    training hours

    Hi, in your paper, you mentioned that "The fourteen painters dataset, for example, ran 1400 epochs in 220 hours on our nVidia Titan X GPU. Note that pairwise CycleGAN instead would have taken about 2860 hours, or four months."

    How you calculated the training hours, i.e. 2860 hours for CycleGAN?

    opened by Zeros12 1
  • Objective function for four domains

    Objective function for four domains

    Hi, thanks for such a nice work.

    In your paper, you have mentioned the objective of CycleGAN which is: screenshot from 2018-12-12 16-43-09

    This is the objective for two domains only. As your work in ComboGAN can translate images from multiple domains, then if you have four domains, what will be the objective function for four domains?

    opened by Zeros12 1
  • Explanation for forward loss

    Explanation for forward loss

    Thanks for such a nice and clean code. Can you please explain what lambda_fwd is intended to do?

    https://github.com/AAnoosheh/ComboGAN/blob/master/models/combogan_model.py#L155

    Thanks.

    opened by RagMeh11 1
Owner
Asha Anoosheh
Asha Anoosheh
RealFormer-Pytorch Implementation of RealFormer using pytorch

RealFormer-Pytorch Implementation of RealFormer using pytorch. Includes comparison with classical Transformer on image classification task (ViT) wrt C

Simo Ryu 90 Dec 8, 2022
A PyTorch implementation of the paper Mixup: Beyond Empirical Risk Minimization in PyTorch

Mixup: Beyond Empirical Risk Minimization in PyTorch This is an unofficial PyTorch implementation of mixup: Beyond Empirical Risk Minimization. The co

Harry Yang 121 Dec 17, 2022
A pytorch implementation of Pytorch-Sketch-RNN

Pytorch-Sketch-RNN A pytorch implementation of https://arxiv.org/abs/1704.03477 In order to draw other things than cats, you will find more drawing da

Alexis David Jacq 172 Dec 12, 2022
PyTorch implementation of Advantage async actor-critic Algorithms (A3C) in PyTorch

Advantage async actor-critic Algorithms (A3C) in PyTorch @inproceedings{mnih2016asynchronous, title={Asynchronous methods for deep reinforcement lea

LEI TAI 111 Dec 8, 2022
Pytorch-diffusion - A basic PyTorch implementation of 'Denoising Diffusion Probabilistic Models'

PyTorch implementation of 'Denoising Diffusion Probabilistic Models' This reposi

Arthur Juliani 76 Jan 7, 2023
Fang Zhonghao 13 Nov 19, 2022
RETRO-pytorch - Implementation of RETRO, Deepmind's Retrieval based Attention net, in Pytorch

RETRO - Pytorch (wip) Implementation of RETRO, Deepmind's Retrieval based Attent

Phil Wang 556 Jan 4, 2023
HashNeRF-pytorch - Pure PyTorch Implementation of NVIDIA paper on Instant Training of Neural Graphics primitives

HashNeRF-pytorch Instant-NGP recently introduced a Multi-resolution Hash Encodin

Yash Sanjay Bhalgat 616 Jan 6, 2023
Generic template to bootstrap your PyTorch project with PyTorch Lightning, Hydra, W&B, and DVC.

NN Template Generic template to bootstrap your PyTorch project. Click on Use this Template and avoid writing boilerplate code for: PyTorch Lightning,

Luca Moschella 520 Dec 30, 2022
A PyTorch Extension: Tools for easy mixed precision and distributed training in Pytorch

This repository holds NVIDIA-maintained utilities to streamline mixed precision and distributed training in Pytorch. Some of the code here will be included in upstream Pytorch eventually. The intention of Apex is to make up-to-date utilities available to users as quickly as possible.

NVIDIA Corporation 6.9k Jan 3, 2023
Objective of the repository is to learn and build machine learning models using Pytorch. 30DaysofML Using Pytorch

30 Days Of Machine Learning Using Pytorch Objective of the repository is to learn and build machine learning models using Pytorch. List of Algorithms

Mayur 119 Nov 24, 2022
Pretrained SOTA Deep Learning models, callbacks and more for research and production with PyTorch Lightning and PyTorch

Pretrained SOTA Deep Learning models, callbacks and more for research and production with PyTorch Lightning and PyTorch

Pytorch Lightning 1.4k Jan 1, 2023
Amazon Forest Computer Vision: Satellite Image tagging code using PyTorch / Keras with lots of PyTorch tricks

Amazon Forest Computer Vision Satellite Image tagging code using PyTorch / Keras Here is a sample of images we had to work with Source: https://www.ka

Mamy Ratsimbazafy 360 Dec 10, 2022
The Incredible PyTorch: a curated list of tutorials, papers, projects, communities and more relating to PyTorch.

This is a curated list of tutorials, projects, libraries, videos, papers, books and anything related to the incredible PyTorch. Feel free to make a pu

Ritchie Ng 9.2k Jan 2, 2023
Amazon Forest Computer Vision: Satellite Image tagging code using PyTorch / Keras with lots of PyTorch tricks

Amazon Forest Computer Vision Satellite Image tagging code using PyTorch / Keras Here is a sample of images we had to work with Source: https://www.ka

Mamy Ratsimbazafy 359 Jan 5, 2023
A bunch of random PyTorch models using PyTorch's C++ frontend

PyTorch Deep Learning Models using the C++ frontend Gettting started Clone the repo 1. https://github.com/mrdvince/pytorchcpp 2. cd fashionmnist or

Vince 0 Jul 13, 2021
PyTorch Autoencoders - Implementing a Variational Autoencoder (VAE) Series in Pytorch.

PyTorch Autoencoders Implementing a Variational Autoencoder (VAE) Series in Pytorch. Inspired by this repository Model List check model paper conferen

Subin An 8 Nov 21, 2022
PyTorch-LIT is the Lite Inference Toolkit (LIT) for PyTorch which focuses on easy and fast inference of large models on end-devices.

PyTorch-LIT PyTorch-LIT is the Lite Inference Toolkit (LIT) for PyTorch which focuses on easy and fast inference of large models on end-devices. With

Amin Rezaei 157 Dec 11, 2022
A general framework for deep learning experiments under PyTorch based on pytorch-lightning

torchx Torchx is a general framework for deep learning experiments under PyTorch based on pytorch-lightning. TODO list gan-like training wrapper text

Yingtian Liu 6 Mar 17, 2022