Skip to content

Implementation of Perceptual Losses Neural Style Transfer Model in Tensorflow / Keras

Notifications You must be signed in to change notification settings

milmor/perceptual-losses-neural-st

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

47 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Perceptual Losses Neural Style Transfer

Implementation of the Perceptual Losses Neural Style Transfer model in the paper:

Perceptual Losses for Real-Time Style Transfer and Super-Resolution (ECCV 2016).

Architecture

This repository implements Instance normalization: The missing ingredient for fast stylization.

See here for the official Torch implementation.

Examples

Content image from Instance normalization paper and style images from Arbitrary Style Transfer paper.


Different resolutions

Delaunay style from Instance normalization paper.

Dependencies

  • Python 3.8
  • Tensorfow 2.5
  • Tensorflow Addons 0.12.1

Usage

Train

  1. Download COCO dataset.
  2. Use --name=<model_name>, --style_img=<style_image_path> and --content_dir=<coco_path> to specify model name, style and content dataset path.
python train.py --name=<model_name> --style_img=<style_image_path> --content_dir=<coco_path> 

Test

Run test.py. It will save every content image to the output directory.

python test.py --name=<model_name> 

Hparams setting

Set hyperparameters in the hparams.py file. Use content_weight and style_weight to adjust the degree of stylization.

Tensorboard

Run tensorboard --logdir ./.

Implementation notes

  • Images normalized [-1, 1] and tanh activation at the network output.

  • Conv2d layers with reflect padding.

  • Example images are generated after 2,400 steps.

  • The model runs using mixed precision.

Licence

Copyright (c) 2020 Emilio Morales. Free to use, copy and modify for academic research purposes, as long as proper attribution is given and this copyright notice is retained. Contact me for any use that is not academic research (email: mil.mor.mor at gmail.com).

Citation

@software{morales2020perceptual,
  author = {Morales, Emilio},
  title = {Perceptual losses neural style transfer},
  url = {https://github.com/milmor/perceptual-losses-neural-st},
  year = {2020},
}

About

Implementation of Perceptual Losses Neural Style Transfer Model in Tensorflow / Keras

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages