Skip to content
Gary Boodhoo edited this page Apr 21, 2018 · 92 revisions

Welcome to Visual Strategies for Neural Artistic Style Transfer

Requirements:

  • Laptop running Windows or MacOS
  • A camera (phone or laptop camera ok)
  • A way to transfer image files from your camera to your laptop
  • Image editing software (any suitable application you are comfortable with, mobile apps are also fine)
  • 5-6 personal images to get started with

Background

Neural artistic style transfer is a method for repainting images in the style of other images using a neural network. The algorithm is computationally intensive because it must be run about a thousand times to produce a decent picture. The bigger the picture, the longer this takes. In order to create rapidly, we'll run these computations on a remote server.

The neural-style code was written by Justin Johnson, a PhD student in the Stanford Vision Lab. His work implements ideas described in the foundational paper, A Neural Algorithm of Artistic Style (Gatys, Ecker, Bethge, 1993). The "AI" for this workshop runs on an Amazon EC2 P3 server. This configuration is specific to this workshop and will only work for the time you're here. Ask me how to replicate this process at home if you're interested.

Getting Started

The server needs three inputs before it can synthesize an output:

A content image

This is the image to be styled

A style image

The neural net takes its stylistic cues from this image

A render scripr

This is a batch file which runs the neural-style algorithm upon the specified style and content images using specified parameters

#!/bin/bash


# 1. replace this with the filename of your content image
CONTENT_IMAGE=radiometer.jpg

# 2. replace this with the filename of your style image
STYLE_IMAGE=starry-2.jpg


# housekeeping
SCRIPT_NAME=`basename "$0"`
IMAGE_PATH=./
OUTPUT_IMAGE=${IMAGE_PATH}output/${SCRIPT_NAME%.*}.png


STYLE_WEIGHT=5e3 # default is 5e2
CONTENT_WEIGHT=5e0 # default is 5e0
STYLE_SCALE=1.1

th neural_style.lua \
  -content_image $IMAGE_PATH$CONTENT_IMAGE \
  -style_image $IMAGE_PATH$STYLE_IMAGE \
  -output_image $IMAGE_PATH$OUTPUT_IMAGE \
  -style_scale $STYLE_SCALE \
  -print_iter 100 \
  -content_weight $CONTENT_WEIGHT \
  -style_weight $STYLE_WEIGHT \
  -image_size 512 \
  -tv_weight 0 \
  -backend cudnn -cudnn_autotune \
  -gpu 0 \

Let's configure a workspace on our laptops to connect with the server. We'll need a way to transfer files, and we also need a way to run scripts. By the way, no programming experience is required. I've already written the render scripts, but you will need to edit them to use filenames of your own pictures.

Setup

Setup for macOS
Setup for Windows