Git Product home page Git Product logo

ganilla's Introduction

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.

Best practice for training and testing your models.

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).

ganilla's People

Contributors

dependabot[bot] avatar giddyyupp avatar nerminsamet avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ganilla's Issues

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

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. 

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!

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']`

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?

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

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.

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?

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.

--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

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.