Git Product home page Git Product logo

spectrum-workshop's Introduction

Lightricks Neural Style workshop

Examples: Style Transfer

Catriona Gray and Woman I by Willem de Kooning

Catriona

Janelle Monae and Starry Night by Vincent van Gogh

Janelle Monae

Andrew Y. Ng and Oil Painting of a Girl in Rain

AndrewYNg

Style Transfers of Golden Bridge

dubnation

Rodrigo Duterte + Increasing Style Weights of Starry Night

Rodrigo Duterte

Examples: Style Transfer while Preserving the original color

Janelle Monae and Starry Night by Vincent van Gogh + Preserve Original Color

Janelle Monae Preserve

Requirements

IMPORTANT NOTE: On Google-Colab All data files and dependencies can be installed by running the uppermost cell of the notebook! See Usage!

Data Files

Dependecies

Usage

You will be running the notebook in Google Colab! Colab is a cloud service with an interface similar to Jupyter notebook. It allows you to get an accelerator, such as a GPU, for Free!

Uncomment and run the first cell to download the demo pictures, and VGG19 weights. It will also install the dependencies (i.e. PyTorch and torchvision).

# Download VGG19 Model
!wget -c https://s3-us-west-2.amazonaws.com/jcjohns-models/vgg19-d01eb7cb.pth
!mkdir models
!cp vgg19-d01eb7cb.pth models/

# Download Images
!wget -c https://github.com/ofirbb/spectrum-workshop/archive/master.zip
!unzip -q master.zip
!mkdir images
!cp neural-style-pytorch-master/images/1-content.png images
!cp neural-style-pytorch-master/images/1-style.jpg images

Options

Image

  • MAX_IMAGE_SIZE: sets the max dimension of height or weight. Bigger GPU memory is needed to run larger images. Default is 512px.
  • INIT_IMAGE: sets the initial image file to either 'random' or 'content'. Default is random which initializes a noise image. Content copies a resized content image, giving free optimization of content loss!
  • CONTENT_PATH: path of the content image
  • STYLE_PATH: path of the style image
  • PRESERVE_COLOR: determines whether to preserve the color of the content image. True preserves the color of the content image. Default value is False
  • PIXEL_CLIP: determines whether to clip the resulting image. True clips the pixel values to [0, 255]. Default value is True

Optimizer

  • OPTIMIZER: sets the optimizer to either 'adam' or 'lbfgs'. Default optimizer is Adam with learning rate of 10. L-BFGS was used in the original (matlab) implementation of the reference paper.
  • ADAM_LR: learning rate of the adam optimizer. Default is 1e1
  • CONTENT_WEIGHT: Multiplier weight of the loss between content representations and the generated image. Default is 5e0
  • STYLE_WEIGHT: Multiplier weight of the loss between style representations and the generated image. Default is 1e2
  • TV_WEIGHT: Multiplier weight of the Total Variation Denoising. Default is 1e-3
  • NUM_ITER: Iterations of the style transfer. Default is 500
  • SHOW_ITER: Number of iterations before showing and saving the generated image. Default is 100

Model

  • VGG19_PATH = path of VGG19 Pretrained weights. Default is 'models/vgg19-d01eb7cb.pth'
  • POOL: Defines which pooling layer to use. The reference paper suggests using average pooling! Default is 'max'

Credits!!!

An implementation of the neural style in PyTorch! This notebook implements Image Style Transfer Using Convolutional Neural Networks by Leon Gatys, Alexander Ecker, and Matthias Bethge. Color preservation/Color transfer is based on the 2nd approach of discussed in Preserving Color in Neural Artistic Style Transfer by Leon Gatys, Matthias Betge, Aaron Hertzmann, and Eli Schetman.

This implementation is a slight adaptation of the code by Rusty.

The original caffe pretrained weights of VGG19 were used for this implementation, instead of the pretrained VGG19's in PyTorch's model zoo.

spectrum-workshop's People

Contributors

galpatel1 avatar ofirbb avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.