Skip to content

shelsql/CV_style_transfer

Repository files navigation

Computer Vision Final Project: Neural Style Transfer

梁世谦,裴虎镇,吴益强

This repository contains a PyTorch implementation of Gatys' neural style transfer, LapStyle, AdaIN, and AdaIN with Laplacian Loss.

Great thanks to the original authors, this tutorial and this PyTorch implementation, both from which this implementation borrows code.

Environment

conda env create --name envname --file=environment.yml

Usage

Gatys method

python gatys.py --method gatys --style path/to/style_img.jpg --content path/to/content_img.jpg

LapStyle method

python gatys.py --method lapstyle --style path/to/style_img.jpg --content path/to/content_img.jpg

AdaIN method

Adaptive instance normalization for arbitrary style transfer trains a feed-forward network instead of optimizing a noise image.

Download Models

bash get_vgg.sh

For a pre-trained decoder, we refer you to this link.

Test

python test_adain.py --style path/to/style_img.jpg --content path/to/content_img.jpg

Train

This code trains with Laplacian loss by default, you can specify loss weights by parameters.

python train_adain.py --content_dir path/to/content/imgs --style_dir path/to/style/imgs --lap_weight some_weight --content_weight some_weight --style_weight some_weight

References

  • [1]: X. Huang and S. Belongie. "Arbitrary Style Transfer in Real-time with Adaptive Instance Normalization.", in ICCV, 2017.
  • [2]: Original implementation in Torch

About

Computer Vision Final Project Codebase

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors