An approach to implement artistic stylized effects on images, loosely based on the implementation of A Neural Algorithm of Artistic Style by Gatys, Ecker, and Bethge. This implementation extracts features representing style and content from different layers in VGG-19 network, followed by manipulating both representations independently to produce stylized effects on the input image. There is a slight modification in the use of max-pooling layers as opposed to the use of average pooling in the paper.
Pre-trained VGG19's weights from PyTorch's model zoo is used in this implementation.
Implementation takes considerable amount of time to produce results without GPU, it is advisable to use a CUDA capable GPU device.
- PyTorch
- Numpy
Here's an overview of project structure,
Main : Main program to implement stylized effects on images
Utilities: Performs necessary image transformation and also extracts loss at different layers of VGG19 network
Ancillary Functions: Defines necessary loss functions
--style_image
: Path to style image
--content_image
: Path to content image
--style_weight
(Optional): Defaults to 1e6
--content_weight
(Optional): Defaults to 1
--num_iter
(Optional): Set the number of iterations (between 300-800) defaults to 300
To run,
python nst.py --style_image <path to style image> --content_image <path to content image>
This work borrows some implementation from:
- PyTorch's Neural Style Tutorial