Ganilla - Official Pytorch implementation of GANILLA

Overview

GANILLA

We provide PyTorch implementation for:

GANILLA: Generative Adversarial Networks for Image to Illustration Translation.

Paper Arxiv

Updates

Dataset Stats:

Ill stats

Sample Images:

Ill images

GANILLA:

GANILLA results on the illustration dataset:

GANILLA results

Comparison with other methods:

comparison

Style transfer using Miyazaki's anime images:

GANILLA miyazaki

Ablation Experiments:

GANILLA ablation

Prerequisites

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

Getting Started

Downloading Datasets

Please refer to datasets.md for details.

Installation

  • Clone this repo:
git clone https://github.com/giddyyupp/ganilla.git
cd ganilla
pip install -r requirements.txt
  • For Conda users, we include a script ./scripts/conda_deps.sh to install PyTorch and other libraries.

GANILLA train/test

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

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

You can find more scripts at scripts directory.

Apply a pre-trained model (GANILLA)

  • You can download pretrained models using following link

Put a pretrained model under ./checkpoints/{name}_pretrained/100_net_G.pth.

  • To test the model, you also need to download the monet2photo dataset and use trainB images as source:
bash ./datasets/download_cyclegan_dataset.sh monet2photo
  • Then generate the results using
python test.py --dataroot datasets/monet2photo/testB --name {name}_pretrained --model test

The option --model test is used for generating results of GANILLA only for one side. python test.py --model cycle_gan will require 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.

  • If you would like to apply a pre-trained model to a collection of input images (rather than image pairs), please use --dataset_mode single and --model test options. Here is a script to apply a model to Facade label maps (stored in the directory facades/testB).
#!./scripts/test_single.sh
python test.py --dataroot ./datasets/monet2photo/testB/ --name {your_trained_model_name} --model test

You might want to specify --netG to match the generator architecture of the trained model.

Style & Content CNN

We shared style & content CNNs in this repo. It contains train/test procedure as well as pretrained weights for both cnns.

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.

Citation

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

@article{hicsonmez2020ganilla,
  title={GANILLA: Generative adversarial networks for image to illustration translation},
  author={Hicsonmez, Samet and Samet, Nermin and Akbas, Emre and Duygulu, Pinar},
  journal={Image and Vision Computing},
  pages={103886},
  year={2020},
  publisher={Elsevier}
}

@inproceedings{Hicsonmez:2017:DDN:3078971.3078982,
 author = {Hicsonmez, Samet and Samet, Nermin and Sener, Fadime and Duygulu, Pinar},
 title = {DRAW: Deep Networks for Recognizing Styles of Artists Who Illustrate Children's Books},
 booktitle = {Proceedings of the 2017 ACM on International Conference on Multimedia Retrieval},
 year = {2017}
}

Acknowledgments

Our code is heavily inspired by CycleGAN.

The numerical calculations reported in this work were fully performed at TUBITAK ULAKBIM, High Performance and Grid Computing Center (TRUBA resources).

Comments
  • CUDA out of memory

    CUDA out of memory

    Thank you very much @kevroy314 for the instructions for Windows 10. I substituted the pip calls with conda as pip does not target the newly created environment in my case. Executing the command python .\test.py --dataroot .\datasets\monet2photo\testB --name AS_pretrained --model test --checkpoints_dir .\checkpoints\ --loadSize 512 --fineSize=512 I get the following error RuntimeError: CUDA out of memory. Tried to allocate 64.00 MiB (GPU 0; 2.00 GiB total capacity; 94.70 MiB already allocated; 16.35 MiB free; 112.00 MiB reserved in total by PyTorch)

    Which does not seem like a ganilla issue at all. After some googling I think this is due to a memory leak, a batch size, training not wrapped in a function call or ...

    So this is more like a question: Have you ever encountered this? Is there some way for me to investigate further?

    opened by simpsus 6
  • Where is GANILLA located..?

    Where is GANILLA located..?

    Hi!

    I was wondering where the implementation of your model is. Since in your code I only see the implementation of pix2pix or cyclegan. Do I miss something..? Or have you done something special in your implementation?

    opened by zwep 3
  • About the performance of using the usnet_128 or usnet_256 to the cyclegan backbone

    About the performance of using the usnet_128 or usnet_256 to the cyclegan backbone

    Hi, I have try the results that using the usnet as the backbone of the cyclegan for training our dataset. And I find the results are better than the res_net18 or 34. When I use the resnet ,the results include many artifacts. So I‘m curious that how the results the unet as the backbone for your dataset and why you last choose the resnet. Thank you, I'm sorry my English is not good.

    opened by Flyooofly 2
  • Illustration dataset can't download

    Illustration dataset can't download

    I can't download your Illustration dataset from your code with this problem:

    Traceback (most recent call last):
      File "/usr/local/lib/python3.7/dist-packages/selenium/webdriver/common/service.py", line 76, in start
        stdin=PIPE)
      File "/usr/lib/python3.7/subprocess.py", line 800, in __init__
        restore_signals, start_new_session)
      File "/usr/lib/python3.7/subprocess.py", line 1551, in _execute_child
        raise child_exception_type(errno_num, err_msg, err_filename)
    FileNotFoundError: [Errno 2] No such file or directory: 'geckodriver': 'geckodriver'
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "openlibraryImageDownloaderMain.py", line 48, in <module>
        main(opts)
      File "openlibraryImageDownloaderMain.py", line 17, in main
        olh = s.OpenLibHelper(opts.openlib_username, opts.openlib_password)
      File "/content/ganilla/datasets/ganilla/datasets/scraper_openlibrary.py", line 31, in __init__
        self.browser = webdriver.Firefox(firefox_profile=profile)
      File "/usr/local/lib/python3.7/dist-packages/selenium/webdriver/firefox/webdriver.py", line 164, in __init__
        self.service.start()
      File "/usr/local/lib/python3.7/dist-packages/selenium/webdriver/common/service.py", line 83, in start
        os.path.basename(self.path), self.start_error_message)
    selenium.common.exceptions.WebDriverException: Message: 'geckodriver' executable needs to be in PATH. 
    
    opened by vanduong0504 1
  • --epoch default set to '100' instead of 'latest'

    --epoch default set to '100' instead of 'latest'

    Hey,

    I was trying to continue training from epoch 40 with options --continue_train --epoch_count 40 and it was a bit weird as it tried to load epoch 100 which did't exist atm :D. After a bit of investigation found that --epoch option is '100' on default although in CycleGAN project it is set to 'latest'. This is unclear as this also not mentioned in FAQ

    opened by Robotuks 1
  • Non-relative file paths in options

    Non-relative file paths in options

    All of the options files are written with non-relative file paths which makes the recommended run commands in the README fail.

    e.g. --checkpoints_dir

    default value is: "/media/test/Samhi/GANILLA/fpn-gan/checkpoints/GANILLA"

    Also this project works perfectly fine on Windows with no adjustments at all, the only issue was the data fetching .sh scripts, but manually downloading the monet2photo data set is very easy.

    opened by Fraser-Paine 1
  • Bad results using the pre-trained

    Bad results using the pre-trained "Miyazaki"

    Hello, i have tried the pre-trained "Miyazaki" model on colab without good result (using 1 pic, the result is a looks just a little filtered)

    !python /content/drive/My\ Drive/ganilla/test.py --dataset_mode single --resize_or_crop none --dataroot /content/in1 --name /content/drive/My\ Drive/Miyazaki/ --model test --results_dir /content/

    output:

    `----------------- Options --------------- aspect_ratio: 1.0
    batch_size: 1
    checkpoints_dir: /media/test/Samhi/GANILLA/fpn-gan/checkpoints/GANILLA cityscape_fnames: /media/test/Samhi/GANILLA/fpn-gan/dataset/cityscape_evaluate/f_names.txt cityscapes: False
    dataroot: /content/in1 [default: /media/test/Samhi/GANILLA/fpn-gan/dataset/photo2axel/] dataset_mode: single
    direction: AtoB
    display_winsize: 256
    epoch: 100
    eval: False
    fineSize: 256
    fpn_weights: [1.0, 1.0, 1.0, 1.0]
    gpu_ids: 0
    init_gain: 0.02
    init_type: normal
    input_nc: 3
    isTrain: False [default: None] loadSize: 256
    max_dataset_size: inf
    model: test
    model_suffix:
    n_layers_D: 3
    name: /content/drive/My Drive/Miyazaki/ [default: photo2korky_ganilla_dropout] ndf: 64
    netD: basic
    netG: resnet_fpn
    ngf: 64
    no_dropout: True
    no_flip: False
    norm: instance
    ntest: inf
    num_test: 751
    num_threads: 8
    output_nc: 3
    phase: test
    resize_or_crop: none [default: resize_and_crop] results_dir: /content/ [default: ./results/] serial_batches: False
    suffix:
    verbose: False
    ----------------- End ------------------- dataset [SingleImageDataset] was created initialize network with normal model [TestModel] was created loading the model from /content/drive/My Drive/Miyazaki/100_net_G.pth ---------- Networks initialized ------------- [Network G] Total number of parameters : 7.228 M

    creating web directory /content/drive/My Drive/Miyazaki/test_100 processing (0000)-th image... ['/content/in1/vlcsnap.png']`

    opened by lorrp1 1
  • Serap Deliorman

    Serap Deliorman

    All Serap Deliorman's books appears to be missing on Open Library site. I there any other way to download the Serap Deliorman dataset? Thanks, Noa Barzilay

    opened by NoaBrazilay 0
  • Got it Working on Windows 10

    Got it Working on Windows 10

    This isn't an issue for the developer, but if future folks want to run this on Windows 10, I was able to do it fair easily with the following steps:

    • Download the repo into a folder and create a conda environment with python==3.7
    • pip install -r requirements.txt
    • pip install pillow==6.1 dominate scipy==1.1.0
    • conda install pytorch=1.3.1 torchvision=0.4.2 -c pytorch
    • Download the model you want (I wanted Miyazaki; https://drive.google.com/drive/folders/1g_YT3q5fY2hEBUu587v784e2UkGbOCfq ) via the documentation in this package into ./checkpoints/{model_name}_pretrained (per the instructions)
    • Download monet2photo from https://people.eecs.berkeley.edu/~taesung_park/CycleGAN/datasets/monet2photo (you can download other models by swapping the last element of the url with the name per the bash script)
    • If you want to run on your own images, create a directory in datasets (for me it was called kevintest) and place your images in there. you'll get the best results with square images
    • Run a command a la (note that I manually specify the dataroot, checkpoint_dir, name, and sizes)

    python test.py --dataroot ./datasets/kevintest --name Miyazaki_pretrained --model test --checkpoints_dir ./checkpoints/ --loadSize 1024 --fineSize=1024

    It seems to work really well on scenery, but it fails on people and human-made objects in my opinion.

    opened by kevroy314 0
  • Change the output channel

    Change the output channel

    Hello. Thank you for the contribution! I have a novice question about the output channel. I changed the output channel in the base_option.py to 1 as I input gray images. But there is one error thrown out: RuntimeError: The size of tensor a (32) must match the size of tensor b (31) at non-singleton dimension 3 I can't figure out why this would happen. Could you please tell me what could be the reason and where should I change in the network.py file?

    Thank you very much!

    opened by Wangmmstar 1
  • Illustration dataset could not be downloaded /  Crawler raises an exception

    Illustration dataset could not be downloaded / Crawler raises an exception

    I have tried to download the illustration dataset according to instruction and make the crawler work. However, it appears that it does not download any file at all. Maybe because of some change in openlibrary.org. Also, the script does not seem to run till the end and it raises below exception. I am also attaching the correspondent browser state. Traceback (most recent call last): File "openlibraryImageDownloaderMain.py", line 48, in <module> main(opts) File "openlibraryImageDownloaderMain.py", line 26, in main olh.search_author(illustrator, dir_name, lower_case_list) File "~/ganilla/datasets/scraper_openlibrary.py", line 52, in search_author search_res = self.browser.find_element_by_id("searchResults") File "~/selenium/webdriver/remote/webdriver.py", line 360, in find_element_by_id return self.find_element(by=By.ID, value=id_) File "~/selenium/webdriver/remote/webdriver.py", line 978, in find_element 'value': value})['value'] File "~/selenium/webdriver/remote/webdriver.py", line 321, in execute self.error_handler.check_response(response) File "~/selenium/webdriver/remote/errorhandler.py", line 242, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.NoSuchElementException: Message: Unable to locate element: [id="searchResults"] image

    opened by gsoykan 1
Owner
Samet Hi
Hacettepe University
Samet Hi
StyleGAN2-ADA - Official PyTorch implementation

Abstract: Training generative adversarial networks (GAN) using too little data typically leads to discriminator overfitting, causing training to diverge. We propose an adaptive discriminator augmentation mechanism that significantly stabilizes training in limited data regimes.

NVIDIA Research Projects 3.2k Dec 30, 2022
Official PyTorch implementation of Joint Object Detection and Multi-Object Tracking with Graph Neural Networks

This is the official PyTorch implementation of our paper: "Joint Object Detection and Multi-Object Tracking with Graph Neural Networks". Our project website and video demos are here.

Richard Wang 443 Dec 6, 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
Official pytorch implementation of paper "Inception Convolution with Efficient Dilation Search" (CVPR 2021 Oral).

IC-Conv This repository is an official implementation of the paper Inception Convolution with Efficient Dilation Search. Getting Started Download Imag

Jie Liu 111 Dec 31, 2022
Official PyTorch Implementation of Unsupervised Learning of Scene Flow Estimation Fusing with Local Rigidity

UnRigidFlow This is the official PyTorch implementation of UnRigidFlow (IJCAI2019). Here are two sample results (~10MB gif for each) of our unsupervis

Liang Liu 28 Nov 16, 2022
Official implementation of our paper "LLA: Loss-aware Label Assignment for Dense Pedestrian Detection" in Pytorch.

LLA: Loss-aware Label Assignment for Dense Pedestrian Detection This project provides an implementation for "LLA: Loss-aware Label Assignment for Dens

null 35 Dec 6, 2022
An official implementation of "SFNet: Learning Object-aware Semantic Correspondence" (CVPR 2019, TPAMI 2020) in PyTorch.

PyTorch implementation of SFNet This is the implementation of the paper "SFNet: Learning Object-aware Semantic Correspondence". For more information,

CV Lab @ Yonsei University 87 Dec 30, 2022
Old Photo Restoration (Official PyTorch Implementation)

Bringing Old Photo Back to Life (CVPR 2020 oral)

Microsoft 11.3k Dec 30, 2022
Official PyTorch implementation of Spatial Dependency Networks.

Spatial Dependency Networks: Neural Layers for Improved Generative Image Modeling Đorđe Miladinović   Aleksandar Stanić   Stefan Bauer   Jürgen Schmid

Djordje Miladinovic 34 Jan 19, 2022
Official implementation of our CVPR2021 paper "OTA: Optimal Transport Assignment for Object Detection" in Pytorch.

OTA: Optimal Transport Assignment for Object Detection This project provides an implementation for our CVPR2021 paper "OTA: Optimal Transport Assignme

null 217 Jan 3, 2023
This is the official PyTorch implementation of the paper "TransFG: A Transformer Architecture for Fine-grained Recognition" (Ju He, Jie-Neng Chen, Shuai Liu, Adam Kortylewski, Cheng Yang, Yutong Bai, Changhu Wang, Alan Yuille).

TransFG: A Transformer Architecture for Fine-grained Recognition Official PyTorch code for the paper: TransFG: A Transformer Architecture for Fine-gra

Ju He 307 Jan 3, 2023
StyleGAN2-ADA - Official PyTorch implementation

Need Help? If you’re new to StyleGAN2-ADA and looking to get started, please check out this video series from a course Lia Coleman and I taught in Oct

Derrick Schultz 217 Jan 4, 2023
Official PyTorch implementation of "ArtFlow: Unbiased Image Style Transfer via Reversible Neural Flows"

ArtFlow Official PyTorch implementation of the paper: ArtFlow: Unbiased Image Style Transfer via Reversible Neural Flows Jie An*, Siyu Huang*, Yibing

null 123 Dec 27, 2022
Official PyTorch implementation of RobustNet (CVPR 2021 Oral)

RobustNet (CVPR 2021 Oral): Official Project Webpage Codes and pretrained models will be released soon. This repository provides the official PyTorch

Sungha Choi 173 Dec 21, 2022
Official PyTorch implementation for Generic Attention-model Explainability for Interpreting Bi-Modal and Encoder-Decoder Transformers, a novel method to visualize any Transformer-based network. Including examples for DETR, VQA.

PyTorch Implementation of Generic Attention-model Explainability for Interpreting Bi-Modal and Encoder-Decoder Transformers 1 Using Colab Please notic

Hila Chefer 489 Jan 7, 2023
[PyTorch] Official implementation of CVPR2021 paper "PointDSC: Robust Point Cloud Registration using Deep Spatial Consistency". https://arxiv.org/abs/2103.05465

PointDSC repository PyTorch implementation of PointDSC for CVPR'2021 paper "PointDSC: Robust Point Cloud Registration using Deep Spatial Consistency",

null 153 Dec 14, 2022
Official PyTorch implementation of MX-Font (Multiple Heads are Better than One: Few-shot Font Generation with Multiple Localized Experts)

Introduction Pytorch implementation of Multiple Heads are Better than One: Few-shot Font Generation with Multiple Localized Expert. | paper Song Park1

Clova AI Research 97 Dec 23, 2022
Official Pytorch implementation of 'GOCor: Bringing Globally Optimized Correspondence Volumes into Your Neural Network' (NeurIPS 2020)

Official implementation of GOCor This is the official implementation of our paper : GOCor: Bringing Globally Optimized Correspondence Volumes into You

Prune Truong 71 Nov 18, 2022
Official PyTorch Implementation of Hypercorrelation Squeeze for Few-Shot Segmentation, arXiv 2021

Hypercorrelation Squeeze for Few-Shot Segmentation This is the implementation of the paper "Hypercorrelation Squeeze for Few-Shot Segmentation" by Juh

Juhong Min 165 Dec 28, 2022