Image-to-Image Translation in PyTorch

Overview




CycleGAN and pix2pix in PyTorch

New: Please check out contrastive-unpaired-translation (CUT), our new unpaired image-to-image translation model that enables fast and memory-efficient training.

We provide PyTorch implementations for both unpaired and paired image-to-image translation.

The code was written by Jun-Yan Zhu and Taesung Park, and supported by Tongzhou Wang.

This PyTorch implementation produces results comparable to or better than our original Torch software. If you would like to reproduce the same results as in the papers, check out the original CycleGAN Torch and pix2pix Torch code in Lua/Torch.

Note: The current software works well with PyTorch 1.4. Check out the older branch that supports PyTorch 0.1-0.3.

You may find useful information in training/test tips and frequently asked questions. To implement custom models and datasets, check out our templates. To help users better understand and adapt our codebase, we provide an overview of the code structure of this repository.

CycleGAN: Project | Paper | Torch | Tensorflow Core Tutorial | PyTorch Colab

Pix2pix: Project | Paper | Torch | Tensorflow Core Tutorial | PyTorch Colab

EdgesCats Demo | pix2pix-tensorflow | by Christopher Hesse

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

Unpaired Image-to-Image Translation using Cycle-Consistent Adversarial Networks.
Jun-Yan Zhu*, Taesung Park*, Phillip Isola, Alexei A. Efros. In ICCV 2017. (* equal contributions) [Bibtex]

Image-to-Image Translation with Conditional Adversarial Networks.
Phillip Isola, Jun-Yan Zhu, Tinghui Zhou, Alexei A. Efros. In CVPR 2017. [Bibtex]

Talks and Course

pix2pix slides: keynote | pdf, CycleGAN slides: pptx | pdf

CycleGAN course assignment code and handout designed by Prof. Roger Grosse for CSC321 "Intro to Neural Networks and Machine Learning" at University of Toronto. Please contact the instructor if you would like to adopt it in your course.

Colab Notebook

TensorFlow Core CycleGAN Tutorial: Google Colab | Code

TensorFlow Core pix2pix Tutorial: Google Colab | Code

PyTorch Colab notebook: CycleGAN and pix2pix

ZeroCostDL4Mic Colab notebook: CycleGAN and pix2pix

Other implementations

CycleGAN

[Tensorflow] (by Harry Yang), [Tensorflow] (by Archit Rathore), [Tensorflow] (by Van Huy), [Tensorflow] (by Xiaowei Hu), [Tensorflow2] (by Zhenliang He), [TensorLayer1.0] (by luoxier), [TensorLayer2.0] (by zsdonghao), [Chainer] (by Yanghua Jin), [Minimal PyTorch] (by yunjey), [Mxnet] (by Ldpe2G), [lasagne/Keras] (by tjwei), [Keras] (by Simon Karlsson), [OneFlow] (by Ldpe2G)

pix2pix

[Tensorflow] (by Christopher Hesse), [Tensorflow] (by Eyyüb Sariu), [Tensorflow (face2face)] (by Dat Tran), [Tensorflow (film)] (by Arthur Juliani), [Tensorflow (zi2zi)] (by Yuchen Tian), [Chainer] (by mattya), [tf/torch/keras/lasagne] (by tjwei), [Pytorch] (by taey16)

Prerequisites

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

Getting Started

Installation

  • Clone this repo:
git clone https://github.com/junyanz/pytorch-CycleGAN-and-pix2pix
cd pytorch-CycleGAN-and-pix2pix
  • Install PyTorch and 0.4+ and other dependencies (e.g., torchvision, visdom and dominate).
    • For pip users, please type the command pip install -r requirements.txt.
    • For Conda users, you can create a new Conda environment using conda env create -f environment.yml.
    • For Docker users, we provide the pre-built Docker image and Dockerfile. Please refer to our Docker page.
    • For Repl users, please click Run on Repl.it.

CycleGAN train/test

  • Download a CycleGAN dataset (e.g. maps):
bash ./datasets/download_cyclegan_dataset.sh maps
  • To view training results and loss plots, run python -m visdom.server and click the URL http://localhost:8097.
  • Train a model:
#!./scripts/train_cyclegan.sh
python train.py --dataroot ./datasets/maps --name maps_cyclegan --model cycle_gan

To see more intermediate results, check out ./checkpoints/maps_cyclegan/web/index.html.

  • Test the model:
#!./scripts/test_cyclegan.sh
python test.py --dataroot ./datasets/maps --name maps_cyclegan --model cycle_gan
  • The test results will be saved to a html file here: ./results/maps_cyclegan/latest_test/index.html.

pix2pix train/test

  • Download a pix2pix dataset (e.g.facades):
bash ./datasets/download_pix2pix_dataset.sh facades
  • To view training results and loss plots, run python -m visdom.server and click the URL http://localhost:8097.
  • Train a model:
#!./scripts/train_pix2pix.sh
python train.py --dataroot ./datasets/facades --name facades_pix2pix --model pix2pix --direction BtoA

To see more intermediate results, check out ./checkpoints/facades_pix2pix/web/index.html.

  • Test the model (bash ./scripts/test_pix2pix.sh):
#!./scripts/test_pix2pix.sh
python test.py --dataroot ./datasets/facades --name facades_pix2pix --model pix2pix --direction BtoA
  • The test results will be saved to a html file here: ./results/facades_pix2pix/test_latest/index.html. You can find more scripts at scripts directory.
  • To train and test pix2pix-based colorization models, please add --model colorization and --dataset_mode colorization. See our training tips for more details.

Apply a pre-trained model (CycleGAN)

  • You can download a pretrained model (e.g. horse2zebra) with the following script:
bash ./scripts/download_cyclegan_model.sh horse2zebra
  • The pretrained model is saved at ./checkpoints/{name}_pretrained/latest_net_G.pth. Check here for all the available CycleGAN models.
  • To test the model, you also need to download the horse2zebra dataset:
bash ./datasets/download_cyclegan_dataset.sh horse2zebra
  • Then generate the results using
python test.py --dataroot datasets/horse2zebra/testA --name horse2zebra_pretrained --model test --no_dropout
  • The option --model test is used for generating results of CycleGAN only for one side. This option will automatically set --dataset_mode single, which only loads the images from one set. On the contrary, using --model cycle_gan requires loading and generating results in both directions, which is sometimes unnecessary. The results will be saved at ./results/. Use --results_dir {directory_path_to_save_result} to specify the results directory.

  • For pix2pix and your own models, you need to explicitly specify --netG, --norm, --no_dropout to match the generator architecture of the trained model. See this FAQ for more details.

Apply a pre-trained model (pix2pix)

Download a pre-trained model with ./scripts/download_pix2pix_model.sh.

  • Check here for all the available pix2pix models. For example, if you would like to download label2photo model on the Facades dataset,
bash ./scripts/download_pix2pix_model.sh facades_label2photo
  • Download the pix2pix facades datasets:
bash ./datasets/download_pix2pix_dataset.sh facades
  • Then generate the results using
python test.py --dataroot ./datasets/facades/ --direction BtoA --model pix2pix --name facades_label2photo_pretrained
  • Note that we specified --direction BtoA as Facades dataset's A to B direction is photos to labels.

  • If you would like to apply a pre-trained model to a collection of input images (rather than image pairs), please use --model test option. See ./scripts/test_single.sh for how to apply a model to Facade label maps (stored in the directory facades/testB).

  • See a list of currently available models at ./scripts/download_pix2pix_model.sh

Docker

We provide the pre-built Docker image and Dockerfile that can run this code repo. See docker.

Datasets

Download pix2pix/CycleGAN datasets and create your own datasets.

Training/Test Tips

Best practice for training and testing your models.

Frequently Asked Questions

Before you post a new question, please first look at the above Q & A and existing GitHub issues.

Custom Model and Dataset

If you plan to implement custom models and dataset for your new applications, we provide a dataset template and a model template as a starting point.

Code structure

To help users better understand and use our code, we briefly overview the functionality and implementation of each package and each module.

Pull Request

You are always welcome to contribute to this repository by sending a pull request. Please run flake8 --ignore E501 . and python ./scripts/test_before_push.py before you commit the code. Please also update the code structure overview accordingly if you add or remove files.

Citation

If you use this code for your research, please cite our papers.

@inproceedings{CycleGAN2017,
  title={Unpaired Image-to-Image Translation using Cycle-Consistent Adversarial Networks},
  author={Zhu, Jun-Yan and Park, Taesung and Isola, Phillip and Efros, Alexei A},
  booktitle={Computer Vision (ICCV), 2017 IEEE International Conference on},
  year={2017}
}


@inproceedings{isola2017image,
  title={Image-to-Image Translation with Conditional Adversarial Networks},
  author={Isola, Phillip and Zhu, Jun-Yan and Zhou, Tinghui and Efros, Alexei A},
  booktitle={Computer Vision and Pattern Recognition (CVPR), 2017 IEEE Conference on},
  year={2017}
}

Other Languages

Spanish

Related Projects

contrastive-unpaired-translation (CUT)
CycleGAN-Torch | pix2pix-Torch | pix2pixHD| BicycleGAN | vid2vid | SPADE/GauGAN
iGAN | GAN Dissection | GAN Paint

Cat Paper Collection

If you love cats, and love reading cool graphics, vision, and learning papers, please check out the Cat Paper Collection.

Acknowledgments

Our code is inspired by pytorch-DCGAN.

Comments
  • Question: PatchGAN Discriminator

    Question: PatchGAN Discriminator

    Hi there. I was investigating your CycleGAN paper and code. And looks like discriminator you've implemented is just a conv net, not a patchgan that was mentioned in the paper. Maybe I've missed something. Could you point me where the processing of 70x70 patches is going on. Thanks in advance!

    opened by johnkorn 32
  • weird results

    weird results

    Hello,

    I am training the CycleGAN on driving scenes, in the beginning the results were a little bit nicer but then there were a little bit weird

    This is after epoch 18 image

    This is after epoch 92 image image

    During the training, the results generated and saved in the checkpoints are much better and well translated. However, when i load the latest checkpoint on test images, these results up there I have @junyanz

    any idea why this is happening ?

    opened by mhusseinsh 27
  • White spots artifacts on the picture

    White spots artifacts on the picture

    Hi,I tried to train my own collected dataset on the source code you provided, but the generated image always produced a white spots artifact ,Do you know why? Any suggestions?

    opened by yinqk 22
  • Error(s) in loading state_dict for ResnetGenerator

    Error(s) in loading state_dict for ResnetGenerator

    Today, I want to test my trained model. There are some errors not occur before.

    Traceback (most recent call last): File "test.py", line 19, in model.setup(opt) File "/home/t-fayan/vision/pytorch-CycleGAN-and-pix2pix/models/base_model.py", line 43, in setup self.load_networks(opt.which_epoch) File "/home/t-fayan/vision/pytorch-CycleGAN-and-pix2pix/models/base_model.py", line 130, in load_networks net.load_state_dict(state_dict) File "/home/t-fayan/anaconda2/envs/py27/lib/python2.7/site-packages/torch/nn/modules/module.py", line 721, in load_state_dict self.class.name, "\n\t".join(error_msgs))) RuntimeError: Error(s) in loading state_dict for ResnetGenerator: Missing key(s) in state_dict: "model.10.conv_block.6.bias", "model.10.conv_block.6.weight", "model.10.conv_block.7.running_var", "model.10.conv_block.7.running_mean", "model.11.conv_block.6.bias", "model.11.conv_block.6.weight", "model.11.conv_block.7.running_var", "model.11.conv_block.7.running_mean", "model.12.conv_block.6.bias", "model.12.conv_block.6.weight", "model.12.conv_block.7.running_var", "model.12.conv_block.7.running_mean", "model.13.conv_block.6.bias", "model.13.conv_block.6.weight", "model.13.conv_block.7.running_var", "model.13.conv_block.7.running_mean", "model.14.conv_block.6.bias", "model.14.conv_block.6.weight", "model.14.conv_block.7.running_var", "model.14.conv_block.7.running_mean", "model.15.conv_block.6.bias", "model.15.conv_block.6.weight", "model.15.conv_block.7.running_var", "model.15.conv_block.7.running_mean", "model.16.conv_block.6.bias", "model.16.conv_block.6.weight", "model.16.conv_block.7.running_var", "model.16.conv_block.7.running_mean", "model.17.conv_block.6.bias", "model.17.conv_block.6.weight", "model.17.conv_block.7.running_var", "model.17.conv_block.7.running_mean", "model.18.conv_block.6.bias", "model.18.conv_block.6.weight", "model.18.conv_block.7.running_var", "model.18.conv_block.7.running_mean". Unexpected key(s) in state_dict: "model.10.conv_block.5.weight", "model.10.conv_block.5.bias", "model.10.conv_block.6.running_mean", "model.10.conv_block.6.running_var", "model.11.conv_block.5.weight", "model.11.conv_block.5.bias", "model.11.conv_block.6.running_mean", "model.11.conv_block.6.running_var", "model.12.conv_block.5.weight", "model.12.conv_block.5.bias", "model.12.conv_block.6.running_mean", "model.12.conv_block.6.running_var", "model.13.conv_block.5.weight", "model.13.conv_block.5.bias", "model.13.conv_block.6.running_mean", "model.13.conv_block.6.running_var", "model.14.conv_block.5.weight", "model.14.conv_block.5.bias", "model.14.conv_block.6.running_mean", "model.14.conv_block.6.running_var", "model.15.conv_block.5.weight", "model.15.conv_block.5.bias", "model.15.conv_block.6.running_mean", "model.15.conv_block.6.running_var", "model.16.conv_block.5.weight", "model.16.conv_block.5.bias", "model.16.conv_block.6.running_mean", "model.16.conv_block.6.running_var", "model.17.conv_block.5.weight", "model.17.conv_block.5.bias", "model.17.conv_block.6.running_mean", "model.17.conv_block.6.running_var", "model.18.conv_block.5.weight", "model.18.conv_block.5.bias", "model.18.conv_block.6.running_mean", "model.18.conv_block.6.running_var".

    What does it mean? Also, if I test pretrained model like horse2zebra, these errors occur too. But I didn't encounter these errors before.

    opened by yfnn 22
  • Connection Error:HTTPConnectionPool

    Connection Error:HTTPConnectionPool

    When I try to python the train.py, such error will show up: Traceback (most recent call last): File "/home/yushengzhang/.conda/envs/my_root/lib/python3.5/site-packages/visdom/init.py", line 261, in _send data=json.dumps(msg), File "/home/yushengzhang/.conda/envs/my_root/lib/python3.5/site-packages/requests/api.py", line 112, in post return request('post', url, data=data, json=json, **kwargs) File "/home/yushengzhang/.conda/envs/my_root/lib/python3.5/site-packages/requests/api.py", line 58, in request return session.request(method=method, url=url, **kwargs) File "/home/yushengzhang/.conda/envs/my_root/lib/python3.5/site-packages/requests/sessions.py", line 508, in request resp = self.send(prep, **send_kwargs) File "/home/yushengzhang/.conda/envs/my_root/lib/python3.5/site-packages/requests/sessions.py", line 618, in send r = adapter.send(request, **kwargs) File "/home/yushengzhang/.conda/envs/my_root/lib/python3.5/site-packages/requests/adapters.py", line 508, in send raise ConnectionError(e, request=request) requests.exceptions.ConnectionError: HTTPConnectionPool(host='localhost', port=8097): Max retries exceeded with url: /events (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f5cc198ca90>: Failed to establish a new connection: [Errno 111] Connection refused',))

    I have tried to modify the requests.adapters.DEFAULT_RETRIES from 0 to 5, but also set requests.session().keep_alive to False.However it doesn't work.How can I successfully run the train.py?

    opened by YushengZhang 21
  • Problem with visdom.server

    Problem with visdom.server

    When I run "python -m visdom.server", there happens: "OSError: [Errno 98] Address already in use" How can I solve this problem? The port stays unchanged as 8097 and I don't have any other sessions occupying this port...

    opened by beardoll 20
  • CUDA Error: Out of Memory

    CUDA Error: Out of Memory

    Hi Team,

    I'm in the process of trying to train a pix2pix model on an AtoB set (edges) where I've already structured these in a montage (A on one side, B on the other side, collated into one image). I have roughly 12,000 images in my training set that I'd like to use. Batch_size is already 1, so I can't reduce that further. I've turned off the visualizer but still have the error.

    From nvidia-smi, I find that GPU utilization spikes just after the Network was initialized (54.414M and 2.769M parameters for Network G and Network D respectively).

    This is the error:

    File "C:\Users\acn.kiosk\Anaconda3\envs\pix2pix-pytorch\lib\site-packages\torch\nn\modules\conv.py", line 301, in forward
        self.padding, self.dilation, self.groups)
    RuntimeError: CUDA error: out of memory
    

    `

    I'm running Windows 10, a Quadro M6000 with 24GB of RAM. Python 3.5.5, CUDA 9.2, Pytorch 0.4.1 (for Cuda92).

    Any ideas? I'm at a loss...

    Brian

    opened by brian1986 20
  • Training on rectangle images

    Training on rectangle images

    Hello, I am starting using the code to train on my own dataset. I have images of size (800x600), any tips what to do I need to edit inside the code/options, to fit my dataset ?

    opened by mhusseinsh 20
  • Any idea about dealing with large image size ?

    Any idea about dealing with large image size ?

    First of all, thanks for the wonderful work!! It's really awesome that can transfer cross domain without paired training examples!!

    I'm wondering that what is the biggest image size you've tried? Since the application of GAN nowadays could only perform on small image size like 256x256 or 512x512 (correct me if I'm wrong).

    But I want to apply this cross domain transfer on high resolution images like 4096x4096 with one GPU (I use TitanX), if I just divide it into several small patches, though it performs well on each patch but they don't show consistent while combine them into the whole image.

    I will appreciate if you can give me some advices.

    Thanks!!

    opened by u10116032 20
  • Testing pre-trained edges2handbags model for single image inputs

    Testing pre-trained edges2handbags model for single image inputs

    I'm trying to test single input images (e.g., handbag sketches) for edges2handbags dataset rather than paired images. I'm using the command provided here pytorch-CycleGAN-and-pix2pix/scripts/test_single.sh. But I'm getting the following error: dataset [SingleImageDataset] was created initialize network with normal model [TestModel] was created loading the model from ./checkpoints/edges2handbags/latest_net_G.pth Traceback (most recent call last): File "test.py", line 20, in model.setup(opt) File "/home/ay/Documents/workspaces/py_ws/.virtualenvs/pytorch/pytorch-CycleGAN-and-pix2pix/models/base_model.py", line 43, in setup self.load_networks(opt.epoch) File "/home/ay/Documents/workspaces/py_ws/.virtualenvs/pytorch/pytorch-CycleGAN-and-pix2pix/models/base_model.py", line 135, in load_networks self.__patch_instance_norm_state_dict(state_dict, net, key.split('.')) File "/home/ay/Documents/workspaces/py_ws/.virtualenvs/pytorch/pytorch-CycleGAN-and-pix2pix/models/base_model.py", line 115, in __patch_instance_norm_state_dict self.__patch_instance_norm_state_dict(state_dict, getattr(module, key), keys, i + 1) File "/home/ay/Documents/workspaces/py_ws/.virtualenvs/pytorch/pytorch-CycleGAN-and-pix2pix/models/base_model.py", line 115, in __patch_instance_norm_state_dict self.__patch_instance_norm_state_dict(state_dict, getattr(module, key), keys, i + 1) File "/home/ay/Documents/workspaces/py_ws/.virtualenvs/pytorch/lib/python3.5/site-packages/torch/nn/modules/module.py", line 518, in getattr type(self).name, name)) AttributeError: 'Sequential' object has no attribute 'model'

    I tried to come up with a workaround for this by concatenating a white image next to my sketches but it seems that output depends on the provided real image. or am I missing something?

    Some of the my tests:

    testalan testalan_fake_b testalan testalan_fake_b

    opened by azadyasar 18
  • Reproducing problem on cityscapes

    Reproducing problem on cityscapes

    Hello! I have read your paper very carefully and tried to reproduce your experiments on cityscapes dataset (photo to label). I changed the input size from 256 to 128 and use resnet_6blocks for G as stated in the appendix, and trained a model, and evaluated the performance of photo to label generator. You got (0.58, 0.22, 0.16) results for pixel acc, cls acc, and iou. But my best results are (0.51, 0.16, 0.10), which have quiet a large margin. I wondered if there are any other details that I should change. What is your configs for cityscapes? And can the size of batch_size produce an influence on the final results? Also, how did you evaluate the segmentation results of 128x128 generated images? Did you resize the original label image to 128x128 and do the evaluation? Thanks a lot. This work is amazing.

    opened by FishYuLi 18
  • The size on disk of ouput is bigger than input

    The size on disk of ouput is bigger than input

    When i put arg --preprocess none on test . The resolution of output image is same as input but the size on disk of ouput is 18 times bigger than input, why is that

    opened by NQHuy1905 0
  • Visdom style.css error

    Visdom style.css error

    Hey Junyanz, thanks for your great work. I have the following issue:

    python -m visdom.server Checking for scripts. It's Alive! ERROR:root:initializing INFO:root:Application Started INFO:root:Working directory: C:\Users\olive.visdom You can navigate to http://localhost:8097 INFO:tornado.access:304 GET / (::1) 30.08ms INFO:tornado.access:304 GET /user/style.css?v=311c1a25a99ac897d22df72ea024df452eee92fdc1453817050a243b62106e375c791d4f9b831ec371f6f342f84fd41d05bcc29d7835ec2bb78a150ba90282d1 (::1) 1.00ms INFO:tornado.access:304 GET /static/fonts/glyphicons-halflings-regular.woff2 (::1) 284.73ms INFO:tornado.access:304 GET / (::1) 72.16ms INFO:tornado.access:304 GET /user/style.css?v=311c1a25a99ac897d22df72ea024df452eee92fdc1453817050a243b62106e375c791d4f9b831ec371f6f342f84fd41d05bcc29d7835ec2bb78a150ba90282d1 (::1) 1.02ms INFO:tornado.access:101 GET /socket (::1) 0.00ms INFO:root:Opened new socket from ip: ::1 INFO:tornado.access:200 POST /env/main (::1) 1.00ms INFO:tornado.access:200 POST /env/main (::1) 0.00ms INFO:tornado.access:304 GET /favicon.png (::1) 14.04ms


    I have gone to the file directory where visdom is saved in the environment and manually created a user\style.css file. I am not sure what code to include in the style.css. I couldn't fix the problem (I have also deleted and reinstalled visdom. It doesn't give me the user\style.css files.

    opened by MayuO2 0
  • DiffAugment in an image translation task while maintaining explainability

    DiffAugment in an image translation task while maintaining explainability

    Hi, I am wondering how to use DiffAugment in an image translation task while maintaining explainability of the feature maps in the generator?

    I am trying to apply DiffAugment with the policy of 'color, translation, cutout' with CUT and CycleGAN models in my research project. I am still exploring CycleGAN, but, with CUT, I observe the augmentation can delay domination of the discriminator while obtaining lower FID when other hyperparameters are left unchanged. However, the feature maps in the generator get "augmented". They become superimposed of multiple shifted maps, which might reduce the potential of other downstream tasks of interest that require explainability. I wonder if there's any suggestion that you can provide.

    Thank you for creating these methods : D

    opened by aarontyliu 0
  • How to eliminate strange border effect in the CycleGAN output image

    How to eliminate strange border effect in the CycleGAN output image

    Need tips/advice on how best to reduce the unwanted border effects from CycleGAN. See output image examples: epoch200_fake_B epoch197_fake_B

    Training command: python train.py --dataroot /cyclegan-catdog_imp2_512-data/catdog_imp2_512 --name catdog_imp2_512 --model cycle_gan --netG resnet_9blocks --display_id -1 --batch_size 16 --gpu_ids 0,1,2,3 --load_size 512 --crop_size 512 --n_epochs 150 --n_epochs_decay 150 --init_type xavier --norm instance

    opened by spinoza1791 5
  • test came out cropped

    test came out cropped

    Hello. I am a student who has just started studying deeplearning and there are many things I don't know.

    I trained the pix2pix model with options —model pix2pix --direction AtoB --save_epoch_freq 100 --n_epochs 400 --n_epochs_decay 400 --preprocess scale_width_and_crop --load_size 768 --crop_size 768

    and tried to test with options —model pix2pix --direction AtoB --preprocess scale_width_and_crop --load_size 1024 --crop_size 512

    but the result came out cropped. (image size of test is 1488*837)

    I want to know why this happens even if test and train have the same options.

    and I also tried with scale_witdth option but I got this error:

    RuntimeError: Sizes of tensors must match except in dimension 1. Expected size 13 but got size 12 for tensor number 1 in the list.

    I want to know why these errors occur and how to solve! Thanks.

    opened by GyuRiiii 1
  • Training pix2pix with High resolution images

    Training pix2pix with High resolution images

    Greetings Thanks for your amazing work! I have one issue and one problem I fixed to report ,and a question to ask. I'm using google collab to train pix2pix model, I need high resolution output so I tested the recommended settings --preprocess scale_width_and_crop --load_size 1024 --crop_size 360 and it worked for training cyclegan but when training pix2pix network I got the following error: RuntimeError: Sizes of tensors must match except in dimension 1. Expected size 5 but got size 4 for tensor number 1 in the list. This is my full training command: !python train.py --dataroot /content/gdrive/MyDrive/pix2pix_official/dataset/dataset --name watermark_remover_pix2pix_1024 --model pix2pix --preprocess scale_width_and_crop --load_size 1024 --crop_size 360 --display_id -1 I also want to report that I had to edit the script unalligned_dataset.py since the Added letter prevented the script from finding the data

    # self.dir_A = os.path.join(opt.dataroot, opt.phase + 'A')  
    self.dir_A = os.path.join(opt.dataroot, opt.phase) 
    
    # self.dir_B = os.path.join(opt.dataroot, opt.phase + 'B')  
    self.dir_B = os.path.join(opt.dataroot, opt.phase)  
    

    finally my question is that my dataset is formed of complex objects I applied a set of masks and I need the model to remove those masks, for example I added a the some star object to the src image, my end goal is to use the network to remove that star from a new image that contains a different object but the same mask(in this example star). what is the recommended training epochs to achieve that goal?

    opened by maryam95hallal 0
Owner
Jun-Yan Zhu
Understanding and creating pixels.
Jun-Yan Zhu
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
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
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
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
Code for Dual Contrastive Learning for Unsupervised Image-to-Image Translation, NTIRE, CVPRW 2021.

arXiv Dual Contrastive Learning Adversarial Generative Networks (DCLGAN) We provide our PyTorch implementation of DCLGAN, which is a simple yet powerf

null 119 Dec 4, 2022
Unsupervised Image-to-Image Translation

UNIT: UNsupervised Image-to-image Translation Networks Imaginaire Repository We have a reimplementation of the UNIT method that is more performant. It

Ming-Yu Liu 劉洺堉 1.9k Dec 26, 2022
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
Pytorch implementation of our method for high-resolution (e.g. 2048x1024) photorealistic video-to-video translation.

vid2vid Project | YouTube(short) | YouTube(full) | arXiv | Paper(full) Pytorch implementation for high-resolution (e.g., 2048x1024) photorealistic vid

NVIDIA Corporation 8.1k Jan 1, 2023
PyTorch Implementation of "Non-Autoregressive Neural Machine Translation"

Non-Autoregressive Transformer Code release for Non-Autoregressive Neural Machine Translation by Jiatao Gu, James Bradbury, Caiming Xiong, Victor O.K.

Salesforce 261 Nov 12, 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
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