In this paper we address the problem of artist style transfer where the painting style of a given artist is applied on a real world photograph. We train our neural networks in adversarial setting via recently introduced quadratic potential divergence for stable learning process. To further improve the quality of generated artist stylized images we also integrate some of the recently introduced deep learning techniques in our method. To our best knowledge this is the first attempt towards artist style transfer via quadratic potential divergence. We provide some stylized image samples in the supplementary material. The source code for experimentation was written in PyTorch and is available online in my GitHub repository.
If you find our work, or this repository helpful, please consider citing our work with the following BibTex:
@article{bhalley2019artist,
title={Artist Style Transfer Via Quadratic Potential},
author={Bhalley, Rahul and Su, Jianlin},
journal={arXiv preprint arXiv:1902.11108},
year={2019}
}
NOTE: Pre-trained models are available in Google Drive
. Please download it in the root directory of this repository.
This code was tested in following environment setting:
- Python (version >= 3.6.0)
- PyTorch (version >= 1.0.0)
- Torchvision (version = 0.2.1)
First clone this repository:
git clone https://github.com/rahulbhalley/cyclegan-qp.git
Enter into the cyclegan-qp
directory via terminal.
cd cyclegan-qp
To download the datasets (for instance, ukiyoe2photo
) run:
bash download_dataset.sh ukiyoe2photo
Now ukiyoe2photo
dataset will be downloaded and unzipped in cyclegan-qp/datasets/ukiyoe2photo
directory.
To train the network set TRAIN = True
in config.py and for inference set it to False
. Then one may only need to execute the following command in terminal.
python main.py
Following is a list of configurable variables (in config.py) to perform experiments with different settings.
DATASET_DIR
- name of directory containing dataset. Default:"datasets"
.DATASET_NAME
- name of dataset to use. Default:"vangogh2photo"
.LOAD_DIM
- sets the size of images to load. Default:286
.CROP_DIM
- square crops the images from center. Default:256
.CKPT_DIR
- name of directory to save checkpoints in. Default:"checkpoints"
.SAMPLE_DIR
- directory name where inferred samples will be saved. Default:"samples"
.
LAMBDA
- see equation (1) in paper. Default:10.0
.NORM
- see equation (2) in paper. Possible values:"l1"
,"l2"
. Default:"l1"
.
CYC_WEIGHT
- cycle consistency weight. Default:10.0
.ID_WEIGHT
- identity weight. Default:0.5
.
N_CHANNELS
- number of channels of images in dataset. Set to3
for RGB and1
for grayscale. Default:3
.UPSAMPLE
- setTrue
to use (Odena et al., 2016) technique butFalse
to use vanilla transpose convolution layers in generator networks. Default:True
.
RANDOM_SEED
- random seed to reproduce the experiments. Default:12345
.BATCH_SIZE
- batch size for training. Default:4
.LR
- learning rate. Default:2e-4
.BETA1
- hyper-parameter of Adam optimizer. Default:0.5
.BETA2
- hyper-parameter of Adam optimizer. Default:0.999
.BEGIN_ITER
- if0
the train begins from start but when set to> 0
then training continues fromBEGIN_ITER
th checkpoint. Default:0
.END_ITER
- number of iteration for training. Default:15000
.TRAIN
- setTrue
for training CycleGAN-QP butFalse
to perform inference (for more inference configurations see next subsection). Default:True
.
INFER_ITER
- performs inference by loading parameters from this checkpoint. Default:15000
.INFER_STYLE
- style to be transferred on images. Possible values:"ce"
,"mo"
,"uk"
,"vg"
. Default:"vg"
.IMG_NAME
- name of image to be performed inference on. Default:"image.jpg"
.IN_IMG_DIR
- name of directory containingIMG_NAME
. Default:"images"
.OUT_STY_DIR
- name of directory to save inferredIMG_NAME
. Default:"sty"
.OUT_REC_DIR
- name of directory to save recovered (original)IMG_NAME
. Default:"rec"
.IMG_SIZE
- setNone
to infer with the original sizedIMG_NAME
or set some integral value to infer withIMG_SIZE
. Default:None
.
ITERS_PER_LOG
- iterations duration at which screen logs should be made. Default:100
ITERS_PER_CKPT
- iterations duration at which checkpoints should be saved. Default:1000
The images in each column (from left to right) corresponds to:
- Original image
- Paul Cézanne
- Claude Monet
- Ukiyo-e
- Vincent Van Gogh.
And each row contains a different image.