Skip to content

Instantly share code, notes, and snippets.

@dat-boris
Last active September 17, 2017 13:08
Show Gist options
  • Select an option

  • Save dat-boris/11a07f29486f584afdecf3423fe509e5 to your computer and use it in GitHub Desktop.

Select an option

Save dat-boris/11a07f29486f584afdecf3423fe509e5 to your computer and use it in GitHub Desktop.
Getting started with Neural Style learning

Running Nerual style on Cloud

Getting started with applying Artistic Style on images / videos

Paper:

1. Get started with Paperspace

Signup at https://www.paperspace.com and obtain an ubuntu machine with GPU

sudo apt update && sudo apt -y install python3-pip nvidia-cuda-dev

Follow setup on https://gist.github.com/sketchytechky/f05e443ea74abd86c08c64c715ca839f

2. Get neural-style setup

See https://github.com/anishathalye/neural-style

git clone https://github.com/anishathalye/neural-style.git
cd neural-style

# obtain pre-trained network
wget http://www.vlfeat.org/matconvnet/models/beta16/imagenet-vgg-verydeep-19.mat

pip3 install -r requirements.txt

# (Optional - running in screen for long task)
# https://stackoverflow.com/questions/44135177/tensorflow-import-error-only-when-being-in-a-linux-screen-sessionlibcublas-so-8
#export LD_LIBRARY_PATH=/usr/local/cuda-8.0/lib64
screen -S longtask

# Run example tests
python3 neural_style.py --content examples/1-content.jpg \
		 --styles examples/1-style.jpg \
		 --output test-1-output.jpg

Running video

See https://github.com/lengstrom/fast-style-transfer

sudo apt -y install ffmpeg
git clone https://github.com/lengstrom/fast-style-transfer.git
cd fast-style-transfer

mkdir checkpoint_folder
mkdir test_dir
mkdir data
pushd data; wget http://www.vlfeat.org/matconvnet/models/beta16/imagenet-vgg-verydeep-19.mat; popd

./setup.py

# see https://github.com/lengstrom/fast-style-transfer#stylizing-video
python3 style.py --style examples/style/la_muse.jpg \
  --checkpoint-dir checkpoint_folder \
  --train-path data/train2014 \
  --test examples/content/chicago.jpg \
  --test-dir `pwd`/test_dir \
  --content-weight 1.5e1 \
  --checkpoint-iterations 1000 \
  --batch-size 20

# transfering style
python3 transform_video.py --in-path `pwd`/examples/content/fox.mp4 \
  --checkpoint checkpoint_folder \
  --out-path fox-processed.mp4 \
  --batch-size 4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment