Official PyTorch implementation of "ArtFlow: Unbiased Image Style Transfer via Reversible Neural Flows"

Related tags

Deep LearningArtFlow
Overview

ArtFlow

Official PyTorch implementation of the paper:

ArtFlow: Unbiased Image Style Transfer via Reversible Neural Flows
Jie An*, Siyu Huang*, Yibing Song, Dejing Dou, Wei Liu and Jiebo Luo
CVPR 2021

ArtFlow is a universal style transfer method that consists of reversible neural flows and an unbiased feature transfer module. ArtFlow adopts a projection-transfer-reversion scheme instead of the encoder-transfer-decoder to avoid the content leak issue of existing style transfer methods and consequently achieves unbiased style transfer in continuous style transfer.

Style Transfer Examples

Style Transfer Examples

Artistic Portrait Style Transfer Examples

We also train a model with the FFHQ dataset as the content and Metfaces as the style to convert a portrait photo into an artwork.

Portrait Style Transfer

Content Leak Phenomenon

When we continuously perform style transfer with a style transfer algorithm, the produced result will gradually lose the detail of the content image. The code in this repository solves this problem.

Content Leak Phenomenons

Dependencies

  • Python=3.6
  • PyTorch=1.8.1
  • CUDA=10.2
  • cuDNN=7.6
  • Scipy=1.5.2

Optionally, if you are a conda user, you can execute the following command in the directory of this repository to create a new environment with all dependencies installed.

conda env create -f environment.yaml

Pretrained Models

If you want to use pretrained models to perform style transfer, please download the pre-trained models in Google Drive and put the downloaded experiments directory under the root of this repository. Then execute the following command in the root of the repository.

Style Transfer

The command with the default settings is:

CUDA_VISIBLE_DEVICES=0 python3 -u test.py --content_dir data/content --style_dir data/style --size 256 --n_flow 8 --n_block 2 --operator adain --decoder experiments/ArtFlow-AdaIN/glow.pth --output output_ArtFlow-AdaIN
  • content_dir: path for the content images. Default is data/content.
  • style_dir: path for the style images. Default is data/style.
  • size: image size for style transfer. Default is 256.
  • n_flow: number of the flow module used per block in the backbone network. Default is 8.
  • n_block: number of the block used in the backbone network. Default is 2.
  • operator: style transfer module. Options: [adain, wct, decorator].
  • decoder: path for the pre-trained model, if you let the --operator wct, then you should load the pre-trained model with --decoder experiments/ArtFlow-WCT/glow.pth. Otherwise, if you use AdaIN, you should set --decoder experiments/ArtFlow-AdaIN/glow.pth. If you want to use this code for portrait style transfer, please set --operator adain and --decoder experiments/ArtFlow-AdaIN-Portrait/glow.pth.
  • output: path of the output directory. This code will produce a style transferred image for every content-style combination in your designated directories.

Continuous Style Transfer

We provide a script to make style transfer with a content and a series of style images to demonstrate that our code can avoid the content leak issue. The command with the default settings is:

CUDA_VISIBLE_DEVICES=0 python3 continuous_transfer.py --content_dir data/content --style_dir data/style --size 256 --n_flow 8 --n_block 2 --operator adain --decoder experiments/ArtFlow-AdaIN/glow.pth --output output_ArtFlow-AdaIN

All parameters are the same as the style transfer part above.

Testing

To test the style transfer performance of the pre-trained model with the given content and style images under data directory. Please run the following commands:

ArtFlow + AdaIN

bash test_adain.sh

The style transfer results will be saved in output_ArtFlow-AdaIN.

ArtFlow + WCT

bash test_wct.sh

The style transfer results will be saved in output_ArtFlow-WCT.

Training

To train ArtFlow by yourself. Please firstly download the Imagenet pre-trained VGG19 model from Google Drive and put the downloaded models directory under the root of the repository. Then run the following commands.

CUDA_VISIBLE_DEVICES=0,1 python3 -u train.py --content_dir $training_content_dir --style_dir $training_style_dir --n_flow 8 --n_block 2 --operator adain --save_dir $param_save_dir --batch_size 4
  • content_dir: path for the training content images.
  • style_dir: path for the training style images.
  • n_flow: number of the flow module used per block in the backbone network. Default is 8.
  • n_block: number of the block used in the backbone network. Default is 2.
  • operator: style transfer module. Options: [adain, wct, decorator].
  • save_dir: path for saving the trained model.

The datasets we used for training in our experiments are as follows:

Model Content Style
General MS_COCO WikiArt
Portrait FFHQ Metfaces

If you want to reproduce the model in our experiments. Here are two bash scripts with our settings:

bash train_adain.sh
bash train_wct.sh

Please note that you may need to change the path of the train content and style datasets in the above two bash scripts.

Citation

@inproceedings{artflow2021,
 title={ArtFlow: Unbiased image style transfer via reversible neural flows},
 author={An, Jie and Huang, Siyu and Song, Yibing and Dou, Dejing and Liu, Wei and Luo, Jiebo},
 booktitle={Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition},
 year={2021}
}

Acknowledgement

We thank the great work glow-pytorch, AdaIN and WCT as we benefit a lot from their codes and papers.

Contact

If you have any questions, please do not hesitate to contact [email protected] and [email protected].

Owner
writing toy code...
Pytorch implementation of Hinton's Dynamic Routing Between Capsules

pytorch-capsule A Pytorch implementation of Hinton's "Dynamic Routing Between Capsules". https://arxiv.org/pdf/1710.09829.pdf Thanks to @naturomics fo

Tim Omernick 625 Oct 27, 2022
Implementation of algorithms for continuous control (DDPG and NAF).

DEPRECATION This repository is deprecated and is no longer maintaned. Please see a more recent implementation of RL for continuous control at jax-sac.

Ilya Kostrikov 288 Dec 31, 2022
Quick program made to generate alpha and delta tables for Hidden Markov Models

HMM_Calc Functions for generating Alpha and Delta tables from a Hidden Markov Model. Parameters: a: Matrix of transition probabilities. a[i][j] = a_{i

Adem Odza 1 Dec 04, 2021
The codes and models in 'Gaze Estimation using Transformer'.

GazeTR We provide the code of GazeTR-Hybrid in "Gaze Estimation using Transformer". We recommend you to use data processing codes provided in GazeHub.

65 Dec 27, 2022
Assessing the Influence of Models on the Performance of Reinforcement Learning Algorithms applied on Continuous Control Tasks

Assessing the Influence of Models on the Performance of Reinforcement Learning Algorithms applied on Continuous Control Tasks This is the master thesi

Giacomo Arcieri 1 Mar 21, 2022
Code for paper "Extract, Denoise and Enforce: Evaluating and Improving Concept Preservation for Text-to-Text Generation" EMNLP 2021

The repo provides the code for paper "Extract, Denoise and Enforce: Evaluating and Improving Concept Preservation for Text-to-Text Generation" EMNLP 2

Yuning Mao 18 May 24, 2022
Code for HLA-Face: Joint High-Low Adaptation for Low Light Face Detection (CVPR21)

HLA-Face: Joint High-Low Adaptation for Low Light Face Detection The official PyTorch implementation for HLA-Face: Joint High-Low Adaptation for Low L

Wenjing Wang 77 Dec 08, 2022
Predictive Modeling on Electronic Health Records(EHR) using Pytorch

Predictive Modeling on Electronic Health Records(EHR) using Pytorch Overview Although there are plenty of repos on vision and NLP models, there are ve

81 Jan 01, 2023
Pyramid addon for OpenAPI3 validation of requests and responses.

Validate Pyramid views against an OpenAPI 3.0 document Peace of Mind The reason this package exists is to give you peace of mind when providing a REST

Pylons Project 79 Dec 30, 2022
Linear image-to-image translation

Linear (Un)supervised Image-to-Image Translation Examples for linear orthogonal transformations in PCA domain, learned without pairing supervision. Tr

Eitan Richardson 40 Aug 31, 2022
[ICCV2021] Safety-aware Motion Prediction with Unseen Vehicles for Autonomous Driving

Safety-aware Motion Prediction with Unseen Vehicles for Autonomous Driving Safety-aware Motion Prediction with Unseen Vehicles for Autonomous Driving

Xuanchi Ren 44 Dec 03, 2022
[ECCV 2020] XingGAN for Person Image Generation

Contents XingGAN or CrossingGAN Installation Dataset Preparation Generating Images Using Pretrained Model Train and Test New Models Evaluation Acknowl

Hao Tang 218 Oct 29, 2022
Code for our TKDE paper "Understanding WeChat User Preferences and “Wow” Diffusion"

wechat-wow-analysis Understanding WeChat User Preferences and “Wow” Diffusion. Fanjin Zhang, Jie Tang, Xueyi Liu, Zhenyu Hou, Yuxiao Dong, Jing Zhang,

18 Sep 16, 2022
Delta Conformity Sociopatterns Analysis - Delta Conformity Sociopatterns Analysis

Delta_Conformity_Sociopatterns_Analysis ∆-Conformity is a local homophily measur

2 Jan 09, 2022
GPT-Code-Clippy (GPT-CC) is an open source version of GitHub Copilot

GPT-Code-Clippy (GPT-CC) is an open source version of GitHub Copilot, a language model -- based on GPT-3, called GPT-Codex -- that is fine-tuned on publicly available code from GitHub.

2.3k Jan 09, 2023
Program your own vulkan.gpuinfo.org query in Python. Used to determine baseline hardware for WebGPU.

query-gpuinfo-data License This software is not presently released under a license. The data in data/ is obtained under CC BY 4.0 as specified there.

Kai Ninomiya 5 Jul 18, 2022
Implement object segmentation on images using HOG algorithm proposed in CVPR 2005

HOG Algorithm Implementation Description HOG (Histograms of Oriented Gradients) Algorithm is an algorithm aiming to realize object segmentation (edge

Leo Hsieh 2 Mar 12, 2022
Image Segmentation using U-Net, U-Net with skip connections and M-Net architectures

Brain-Image-Segmentation Segmentation of brain tissues in MRI image has a number of applications in diagnosis, surgical planning, and treatment of bra

Angad Bajwa 8 Oct 27, 2022
Collection of generative models, e.g. GAN, VAE in Pytorch and Tensorflow.

Generative Models Collection of generative models, e.g. GAN, VAE in Pytorch and Tensorflow. Also present here are RBM and Helmholtz Machine. Note: Gen

Agustinus Kristiadi 7k Jan 02, 2023
Dataset and codebase for NeurIPS 2021 paper: Exploring Forensic Dental Identification with Deep Learning

Repository under construction. Example dataset, checkpoints, and training/testing scripts will be avaible soon! 💡 Collated best practices from most p

4 Jun 26, 2022