This repository contains code for style transfer. Baseline trains a network which is fixed for a style image. The improved code trains a network which can take arbitrary content and style image as input.
-
baseline_DATA: Folder contains a small subset of data used for training the baseline model.
- content : Folder contains the content images used.
- train : Folder contains the training content images
- validation : Folder contains the validation content images
- test : Folder contains the test content images
- mosaic.jpg: The style image for which the network is trained.
- content : Folder contains the content images used.
-
baseline_CODE: Folder contains the code for running the training for the baseline model.
- LOGS : Folder stores the logs and models saved while training
- tensorboard : Folder contains the tensorboard files generated while training
- model : Folder contains the model checkpoints generated while training
- test_image : Saves the output style image for the test images while training
- LOGS : Folder stores the logs and models saved while training
-
DATA : Folder contains a small subset of data used.
- content : Folder contains the content images used.
- train : Folder contains the training content images
- validation : Folder contains the validation content images
- style : Folder contains the style images used.
- train : Folder contains the style train images
- validation : Folder contains the style validation images
- content : Folder contains the content images used.
-
CODE : Folder contains the code for running the training, inference as well as GUI.
- LOGS : Folder stores the logs and models saved while training
- tensorboard : Folder contains the tensorboard files generated while training
- model : Folder contains the model checkpoints generated while training
- models : Folder contains trained decoder model. The encoder model must be downloaded from the drive link provided.
- RESULTS_gui : Folder stores the images which are saved through the gui
- RESULTS_inference : Folder stores the images which are saved through inference script
- SAMPLE_TEST_IMAGES : Folder contains sample content and style images to run the gui and inference
- content : Folder contains sample content images
- style : Folder contains sample style images
- LOGS : Folder stores the logs and models saved while training
- train.py
This file uses the following python scripts as dependencies:
- net : contains the class for style network
- vgg : contains the class for vgg network used while evaluating loss
- loss_network : contains the class for the loss network
- helper_functions : contains helper function required by the network
- train.py - file which performs the training
- inference - file which performs the inference
- gui - file which runs the gui
The above three files use the following python scipts as dependencies:
- dataloader : defines the class for loading dataset
- network : contains the classes for networks required for training and inference
- encoder : contains the class defining the encoder
- decoder : contains the class defining the decoder
- helper_function : contains helper function required by the network
My code runs on the following versions
- Pytorch 1.0.1
- TensorboardX 1.6
- tqdm 4.28.1
- PIL 5.3.0
- torchvision 0.2.2
- tkinter
Download the vgg model file from my drive https://drive.google.com/file/d/1YiqXQpfAc_FATeJe2_n_jC_6HsineYVr/view?usp=sharing and place it in the baseline_code folder. Now, you are ready to run the network for training.
- TRAINING: All the required paths have been set.
python train.py
or
python train.py --content_dir ** --style_image_path ** --val_dir ** --lr **
Sample Images for gui and inference can be taken from the SAMPLE_TEST_IMAGES folder. They are test images.
Download the encoder model file from my drive https://drive.google.com/open?id=1HTBmh4YQa-b-z4Zljra8mJWtJrdItct- and place it in the models folder. Now, you are ready to run the network for training, inference as well as gui.
- TRAINING: All the required paths have been set.
python train.py
or
python train.py --content_dir ** --style_dir ** --val_content_dir ** --val_style_dir ** --lr ** - INFERENCE: The sample images have been set up in th file.
python inference.py
or
python inference.py --content_path ** --style_path ** - GUI : python gui.py
Sample Images for gui and inference can be taken from the SAMPLE_TEST_IMAGES folder. They are test images.
- J. Johnson, A. Alahi, and L. Fei-Fei. Perceptual losses for real-time style transfer and super-resolution. 2016. 2, 3
- Huang, X., Belongie, S.: Arbitrary style transfer in real-time with adaptive instance normalization. In: ICCV. (2017)
- K. Simonyan and A. Zisserman. Very deep convolutional networks for large-scale image recognition. In ICLR, 2015. 4, 5
- https://github.com/naoto0804/pytorch-AdaIN
- https://github.com/pytorch/examples/tree/master/fast_neural_style