• Home
  • Projects
  • Art
  • Blog
  • CV
Menu

Riley Wong

  • Home
  • Projects
  • Art
  • Blog
  • CV
result_74.jpg
result_18 2.jpg
result_0.jpg

Implementing Neural Style Transfer from Scratch using PyTorch

March 19, 2019

This past week, I’ve been playing around with more image processing and generation techniques. In particular, I implemented the neural style transfer algorithm by Gatys, Ecker, and Bethge in PyTorch following this tutorial. The paper and technique have been around for a few years, but it wasn’t until now that I have access to a GPU here at Recurse. This was so much fun to implement and experiment with!

My GitHub repo contains instructions on setup and usage, as well as a directory containing many results, if you would like to try it out and explore for yourself!

Model Overview

Neural style transfer takes two images as input and applies the style of one image onto the content of the other. In the example below, the first image is the style input, the second image is the content input, and the third image is the result of the style transfer. (The style image used here is one of my favorite paintings: Nocturne in Black and Gold, the Falling Rocket by James Abbott McNeill Whistler.)

View fullsize whistler_nocturne_purple.jpg
View fullsize skeleton_3.jpg
View fullsize result_0.jpg

The approach builds off of the VGG-19, a convolutional neural network pretrained on millions of images. It’s 19 layers deep and built by the Visual Geometry Group, hence VGG-19.

For neural style transfer, we modify the network architecture as such: we insert a content loss layer, using mean squared error, after the fourth convolutional layer; and insert style loss layers, using mean squared error on normalized gram matrices, after the first five convolutional layers.

Results

These are some of my favorite images that resulted from my explorations. Note that this is a curated collection of results.

View fullsize result_73.jpg
View fullsize result_76.jpg
View fullsize result_23.jpg
View fullsize result_74.jpg
View fullsize result_38.jpg
View fullsize result_29.jpg
View fullsize result_4 6.jpg
View fullsize result_16 2.jpg
View fullsize result_11 7.jpg
View fullsize result_4 2.jpg
View fullsize result_11 3.jpg
View fullsize result_18 3.jpg
View fullsize result_34.jpg
View fullsize result_40.jpg
View fullsize result_0 4.jpg
View fullsize result_3.jpg
View fullsize result_11 5.jpg
View fullsize result_5.jpg
View fullsize result_1.jpg
View fullsize result_27.jpg
View fullsize result_0.jpg
View fullsize result_4 7.jpg
View fullsize result_11 8.jpg
View fullsize result_8 3.jpg
View fullsize result_17.jpg
View fullsize result_33.jpg
View fullsize result_26.jpg
View fullsize result_28.jpg
View fullsize result_8.jpg
View fullsize result_23 2.jpg
View fullsize result_0 7.jpg
View fullsize result_3 2.jpg
View fullsize result_19.jpg
View fullsize result_6 3.jpg
View fullsize result_5 2.jpg
View fullsize result_7.jpg
Tags neural networks, neural network, neural style transfer, image processing, machine learning, pytorch, python
← AACR June L. Biedler Prize for Cancer Journalism, SABEW Best in Business Honorable MentionCircuit Cities with Pix2Pix: Using Image-to-Image Translation with Generative Adversarial Networks to Create Buildings, Maps, and Satellite Images from Circuit Boards →
  • 2024
    • Nov 18, 2024 [Talk] Applications of MP-FHE for Vulnerable Communities Nov 18, 2024
    • Jun 11, 2024 [Resource] Community Models for Music Venues and Platforms Jun 11, 2024
    • Jun 11, 2024 [Resource] Interfaces for Data Consent Jun 11, 2024
    • May 7, 2024 Cooperative Leaders and Scholars, Community Venues and Cultural Land Trusts May 7, 2024
    • Mar 27, 2024 [Talk] Governable Spaces | Collective Governance: Governance Archaeology Mar 27, 2024
    • Mar 7, 2024 [Essay] Privacy-Preserving Data Governance, Ash Center Occasional Papers Series Mar 7, 2024
    • Jan 20, 2024 [Talk] Privacy-Preserving Data Governance, Second Interdisciplinary Workshop on Reimagining Democracy, Harvard Kennedy School Ash Center Jan 20, 2024
  • 2022
    • Nov 2, 2022 decentralized networks for community care, dweb reflections, general updates Nov 2, 2022
    • Nov 2, 2022 dm-uy 1133 creative coding guest lecture: creative applications of generative machine learning Nov 2, 2022
    • Mar 10, 2022 coops and governance: mood board Mar 10, 2022
  • 2021
    • Nov 4, 2021 coops and governance Nov 4, 2021
    • Nov 1, 2021 hypnopompia -- published fiction story w/ kernel mag Nov 1, 2021
    • Jul 28, 2021 sleep, dreams, and brain waves Jul 28, 2021
  • 2019
    • Jun 3, 2019 pokemon2pokemon: Using Neural Networks to Generate Pokemon as Different Elemental Types Jun 3, 2019
    • May 16, 2019 Localhost Talk: creative applications of deep learning, aka, neural networks for fun and not profit :-) May 16, 2019
    • Apr 24, 2019 Implementing char-RNN from Scratch in PyTorch, and Generating Fake Book Titles Apr 24, 2019
    • Apr 19, 2019 samoyed2bernese: Using CycleGAN for Image-to-Image Translation between Samoyeds and Bernese Mountain Dogs Apr 19, 2019
    • Apr 12, 2019 joke2punchline, punchline2joke: Using a Seq2Seq Neural Network to "Translate" Between Jokes and Punchlines Apr 12, 2019
    • Apr 4, 2019 Implementing a Seq2Seq Neural Network with Attention for Machine Translation from Scratch using PyTorch Apr 4, 2019
    • Apr 3, 2019 AACR June L. Biedler Prize for Cancer Journalism, SABEW Best in Business Honorable Mention Apr 3, 2019
    • Mar 19, 2019 Implementing Neural Style Transfer from Scratch using PyTorch Mar 19, 2019
    • Mar 6, 2019 Circuit Cities with Pix2Pix: Using Image-to-Image Translation with Generative Adversarial Networks to Create Buildings, Maps, and Satellite Images from Circuit Boards Mar 6, 2019
    • Mar 5, 2019 Dogspotting: Using Machine Learning to Draw Bounding Boxes around Dogs in Pictures Mar 5, 2019
    • Feb 28, 2019 Text Generation with GPT-2, OpenAI's Recently Released Language Model Feb 28, 2019
    • Feb 25, 2019 Generating Jazz Music with an LSTM Recurrent Neural Network Feb 25, 2019
  • 2018
    • Sep 25, 2018 Black Patients Miss Out On Promising Cancer Drugs Sep 25, 2018
    • May 23, 2018 Predicting Readmission Risk after Orthopedic Surgery May 23, 2018
    • May 3, 2018 Machine Learning for Healthcare May 3, 2018
    • Jan 3, 2018 Music and Mood: Assessing the Predictive Value of Audio Features on Lyrical Sentiment Jan 3, 2018
  • 2016
    • Jun 8, 2016 Algorithmic Bias Jun 8, 2016
    • May 26, 2016 Computational Creativity May 26, 2016
  • 2015
    • Mar 12, 2015 penn play promotional profile pictures Mar 12, 2015
    • Jan 21, 2015 fnar 247: environmental animation master post Jan 21, 2015
  • 2014
    • Dec 26, 2014 photographs 01 Dec 26, 2014
    • Aug 21, 2014 Morton Salt Girl 3D Model Aug 21, 2014
    • May 11, 2014 rotary telephone May 11, 2014
    • May 6, 2014 project dump May 6, 2014

Riley Wong © 2014 · contact