• Home
  • Projects
  • Art
  • Blog
  • CV
Menu

Riley Wong

  • Home
  • Projects
  • Art
  • Blog
  • CV
Gyarados, a water type
Gyarados, a water type
Gyarados as fire type
Gyarados as fire type
Gyarados as grass type
Gyarados as grass type
Gyarados as electric type
Gyarados as electric type

pokemon2pokemon: Using Neural Networks to Generate Pokemon as Different Elemental Types

June 3, 2019

Have you ever wondered what a Gyarados would look like as a fire type? Or grass type, or electric type?

For my last project at the Recurse Center, I trained CycleGAN, an image-to-image translation model, on images of Pokémon of different types.

 
Ho-oh, a fire type
Ho-oh, a fire type
Ho-oh as dark type
Ho-oh as dark type
 

Model Overview

CycleGAN is an image-to-image translation model that allows us to “translate” from one set of images to another. For more on CycleGAN, see previous blog posts on image-to-image translation with CycleGAN and pix2pix.

The open-source implementation used to train and generate these images of Pokémon uses PyTorch and can be found on Github. For this project, I trained the model to translate between sets of Pokémon images of different types, e.g. translating images of water types to fire types.

Training Data

I found the original dataset of Pokémon images and their types on Kaggle, containing Generations 1-7. I wrote a script to sort the Pokémon images by their primary type.

The resulting dataset, as well as the script, can both be found on my Github.

Results

For each pair of images, on the left is the original image of the Pokemon, and on the right is the type-translated version. (Results are best viewed if you turn off f.lux, night shift, or any other display mode that changes the color of your screen.)

Water type -> other types

Dewgong, water type
Dewgong, water type
Dewgong as grass type
Dewgong as grass type
Lapras, water type
Lapras, water type
Lapras as grass type
Lapras as grass type
Azumarill, water type
Azumarill, water type
Azumarill as grass type
Azumarill as grass type
Kingdra, water type
Kingdra, water type
Kingdra as grass type
Kingdra as grass type
Clawitzer, water type
Clawitzer, water type
Clawitzer as fire type
Clawitzer as fire type
Empoleon, water type
Empoleon, water type
Empoleon as grass type
Empoleon as grass type
Greninja, water type
Greninja, water type
Greninja as grass type
Greninja as grass type
Keldeo, water type
Keldeo, water type
Keldeo as grass type
Keldeo as grass type
Cloyster, water type
Cloyster, water type
Cloyster as electric type
Cloyster as electric type
Lapras, water type
Lapras, water type
Lapras as fire type
Lapras as fire type
Kyogre, water type
Kyogre, water type
Kyogre as grass type
Kyogre as grass type
Feraligatr, water type
Feraligatr, water type
Feraligatr as grass type
Feraligatr as grass type
Clawitzer, water type
Clawitzer, water type
Clawitzer as grass type
Clawitzer as grass type
Carracosta, water type
Carracosta, water type
Carracosta as fire type
Carracosta as fire type
Greninja, water type
Greninja, water type
Greninja as fire type
Greninja as fire type
Clauncher, water type
Clauncher, water type
Clauncher as grass type
Clauncher as grass type


Fire type -> other types

Slugma, fire type
Slugma, fire type
Slugma as dark type
Slugma as dark type
Ponyta, fire type
Ponyta, fire type
Ponyta as dark type
Ponyta as dark type
Combusken, fire type
Combusken, fire type
Combusken as dark type
Combusken as dark type
Torkoal, fire type
Torkoal, fire type
Torkoal as water type
Torkoal as water type
Darmanitan, fire type
Darmanitan, fire type
Darmanitan as dark type
Darmanitan as dark type
Delphox, fire type
Delphox, fire type
Delphox as dark type
Delphox as dark type
Simisear, fire type
Simisear, fire type
Simisear as dark type
Simisear as dark type
Pignite, fire type
Pignite, fire type
Pignite as water type
Pignite as water type
Heatmor, fire type
Heatmor, fire type
Heatmor as electric type
Heatmor as electric type
Ho-oh, fire type
Ho-oh, fire type
Ho-oh as electric type
Ho-oh as electric type
Rapidash, fire type
Rapidash, fire type
Rapidash as dark type
Rapidash as dark type
Blaziken, fire type
Blaziken, fire type
Blaziken as dark type
Blaziken as dark type
Flareon, fire type
Flareon, fire type
Flareon as water type
Flareon as water type
Darmanitan, fire type
Darmanitan, fire type
Darmanitan as electric type
Darmanitan as electric type
Delphox, fire type
Delphox, fire type
Delphox as water type
Delphox as water type
Simisear, fire type
Simisear, fire type
Simisear as water type
Simisear as water type
Magmortar, fire type
Magmortar, fire type
Magmortar as electric type
Magmortar as electric type
Talonflame, fire type
Talonflame, fire type
Talonflame as water type
Talonflame as water type


Grass type -> other types

Bellossom, grass type
Bellossom, grass type
Bellossom as water type
Bellossom as water type
Grovyle, grass type
Grovyle, grass type
Grovyle as water type
Grovyle as water type
Maractus, grass type
Maractus, grass type
Maractus as water type
Maractus as water type
Leafeon, grass type
Leafeon, grass type
Leafeon as water type
Leafeon as water type
Sceptile, grass type
Sceptile, grass type
Sceptile as water type
Sceptile as water type
Pansage, grass type
Pansage, grass type
Pansage as water type
Pansage as water type


Electric type -> other types

Electivire, electric type
Electivire, electric type
Electivire as dark type
Electivire as dark type
Thundurus, electric type
Thundurus, electric type
Thundurus as fire type
Thundurus as fire type


Dragon type -> other types

Latios, dragon type
Latios, dragon type
Latios as grass type
Latios as grass type
Kyurem, dragon type
Kyurem, dragon type
Kyurem as dark type
Kyurem as dark type
Garchomp, dragon type
Garchomp, dragon type
Garchomp as dark type
Garchomp as dark type
Zekrom, dragon type
Zekrom, dragon type
Zekrom as fire type
Zekrom as fire type
Rayquaza, dragon type
Rayquaza, dragon type
Rayquaza as fire type
Rayquaza as fire type
Salamence, dragon type
Salamence, dragon type
Salamence as fire type
Salamence as fire type
Haxorus, dragon type
Haxorus, dragon type
Haxorus as fire type
Haxorus as fire type
Zygarde, dragon type
Zygarde, dragon type
Zygarde as fire type
Zygarde as fire type


Dark type -> other types

Darkrai, dark type
Darkrai, dark type
Darkrai as dragon type
Darkrai as dragon type
Yveltal, dark type
Yveltal, dark type
Yveltal as electric type
Yveltal as electric type
Hydreigon, dark type
Hydreigon, dark type
Hydreigon as fire type
Hydreigon as fire type



Tags cycleGAN, neural networks, neural network, image-to-image translation, pokemon, images, image processing, pytorch, GANs, generative adversarial networks, machine learning
2 Comments
n02111889_1020_real_A.png
n02111889_1020_fake_B.png

samoyed2bernese: Using CycleGAN for Image-to-Image Translation between Samoyeds and Bernese Mountain Dogs

April 19, 2019

Dogs!!! More dogs this week!!! Is it possible I picked this project because I was in the mood for dog pictures? Absolutely.

This week, I used the CycleGAN image-to-image translation model to translate between images of Samoyeds and Bernese mountain dogs, two of my favorite dogs. If you’re not familiar with these breeds, you’re in luck, because here are some dog pictures for your reference. (Such good dogs!!)

 
One very good Samoyed

One very good Samoyed

Two very good Bernese mountain dogs

Two very good Bernese mountain dogs

 

Model Overview

CycleGAN builds off of the pix2pix network, a conditional generative adversarial network (or cGAN) that can map paired input and output images. Unlike pix2pix, CycleGAN is able to train on unpaired sets of images. For more on pix2pix and CycleGAN, see my previous blog post here.

The CycleGAN implementation used to train and generate dog pictures uses PyTorch and can be found on Github here. (This repo also contains a pix2pix implementation, which I had used previously to generate circuit cities.)

A major strength of CycleGAN over pix2pix is that your datasets can be unpaired. For pix2pix, you may have to really dig, curate, or create your own dataset of 1-to-1 paired images. For example, if you wanted to translate daytime photos to nighttime photos with pix2pix, you would need a pair of daytime and nighttime photos of the same location. With CycleGan, you can just have a set of daytime photos of any location and a set of nighttime photos of any location and call it a day (no pun intended).

Another strength of CycleGAN over, say, neural style transfer, is that the translations can be localized. In the following examples, you’ll see that the translation applies only to the dog. Object recognition is implied, and the non-dog portions of the images are not really affected. With neural style transfer, you’re applying a style transformation to the entire image.

As an aside, I originally ran CycleGAN on a set of images of forests, and a set of images of forest paintings. While the results did turn out as expected, I realized this kind of task is really best suited for neural style transfer. (Which inspired me to implement it from scratch! See previous blog post on implementing neural style transfer from scratch in PyTorch.)

Training Data

To train the model, I used 218 images of Samoyeds and 218 images of Bernese mountain dogs from one of my favorite datasets currently on the internet: the Stanford Dogs Dataset. So many good dogs!! My heart!!

GPU training time took a couple of hours on an NVIDIA GeForce GTX 1080 Ti, and generating results only took a few minutes.

Results

In the following examples, on the left is the input, a real photo of a Samoyed. On the right is the CycleGAN output, a generated image translated from the input into a Bernese mountain dog.

 
n02111889_10059_real_A.png
n02111889_10059_fake_B.png
n02111889_1020_real_A.png
n02111889_1020_fake_B.png
n02111889_10084_real_A.png
n02111889_10084_fake_B.png
n02111889_1019_real_A.png
n02111889_1019_fake_B.png
n02111889_10734_real_A.png
n02111889_10734_fake_B.png
n02111889_1145_real_A.png
n02111889_1145_fake_B.png
n02111889_11502_real_A.png
n02111889_11502_fake_B.png
n02111889_12171_real_A.png
n02111889_12171_fake_B.png
n02111889_1314_real_A.png
n02111889_1314_fake_B.png
 

Notes

Note that, since this is a blog post and not a scientific paper, I’ve only included the more effective results in this post. For example, bernese2samoyed doesn’t look quite as good — it just looks like white-out was applied to the dog lol.

 
n02111889_1020_real_B.png
n02111889_1020_fake_A.png
 

I would add that a major strength of cycleGAN is that the changes are applied locally, and not to the entire image. The network is able to identify the boundaries of dog and not-dog.

Another note is that this approach seems to work best when translating between inputs with similar shapes. In these results, mainly the coloring was transferred, and not so much the dog shape. I would posit that breeds that are similar in shape would yield more effective results, e.g. translating between golden and chocolate labs, or between tabby cats and tortoise shell cats.

Tags neural networks, neural network, cycleGAN, generative adversarial networks, dogs, machine learning, GANs, images, image processing, image-to-image translation
Comment
circuits08_fake_B.png
circuits19_fake_B.png
circuits20_fake_B.png

Circuit Cities with Pix2Pix: Using Image-to-Image Translation with Generative Adversarial Networks to Create Buildings, Maps, and Satellite Images from Circuit Boards

March 6, 2019

I’ve been playing around with generative adversarial networks this week. In particular, using image-to-image translation to see what we can create using images of circuit boards.

I’ve noticed before that circuit boards mildly resemble aerial geospatial images. What kinds of cities could we build with them?

Model Overview

GANs

GAN stands for Generative Adversarial Network: generative, because we are using it to generate data; adversarial, because it comprises of two competing networks; and network, because we are describing a neural network architecture.

Essentially, you have two models competing: a generator that generates fake images, and a discriminator that judges whether an image is fake or real.

First, we generate a bunch of fake images using the generator. Then, we take these fake images to the discriminator, which classifies images as fake or real. Using the information on how the discriminator determined which images are fake, we take that back to the generator so we can generate better fake images. We repeat this process, taking turns training the generator, then the discriminator, until the discriminator can no longer tell which images are real or fake (generated).

Pix2Pix

The pix2pix model uses conditional adversarial networks (aka cGANs, conditional GANs) trained to map input to output images, where the output is a “translation” of the input. For image-to-image translation, instead of simply generating realistic images, we add the condition that the generated image is a translation of an input image. To train cGANs, we use pairs of images, one as an input and one as the translated output.

For example, if we train pairs of black-and-white images (input) alongside the color image (translation), we then have a model that can generate color photos given a black-and-white photo. If we train pairs of day (input) and night (translation) images of the same location, we have a model that can generate night photos from day photos.

CycleGAN

A related model architecture is CycleGAN (original CycleGAN paper), which builds off of the pix2pix architecture, but allows you to train the model without having explicit pairings. For example, we can have one dataset of day images, and one dataset of night images; it’s not necessary to have a specific pairing of a day and night image of the same location. To train CycleGAN, we can use unpaired training data. (CycleGAN is not used here but I hope to explore it more this week!)

The pretrained models I used for these explorations are from a PyTorch implementation of pix2pix that can be found on Github.

Results

In the results below, on the left is the circuit board image input, and on the right is the generated translation.

Circuit Boards to Buildings

For these, I used the facades_label2photo pretrained model, originally trained on paired images like this:

 
Labels to Facade

Labels to Facade

 
 
circuits24_real_A.png
circuits24_fake_B.png
circuits22_real_A.png
circuits22_fake_B.png
circuits25_real_A.png
circuits25_fake_B.png
circuits21_real_A.png
circuits21_fake_B.png
circuits17_real_A.png
circuits17_fake_B.png
circuits16_real_A.png
circuits16_fake_B.png
circuits10_real_A.png
circuits10_fake_B.png
circuits02_real_A.png
circuits02_fake_B.png
circuits01_real_A.png
circuits01_fake_B.png
 

Circuits to Maps

For these, I used the sat2map pretrained model, originally trained on paired of satellite aerial images (input) and Google maps (translation).

 
circuits12_real_A.png
circuits12_fake_B.png
circuits19_real_A.png
circuits19_fake_B.png
 

Circuits to Satellite Images

For these, I used the map2sat pretrained model, originally trained on paired of Google maps images (input) and satellite aerial images (translation).

 
circuits05_real_A.png
circuits05_fake_B.png
circuits06_real_A.png
circuits06_fake_B.png
circuits07_real_A.png
circuits07_fake_B.png
circuits20_real_A.png
circuits20_fake_B.png
 
Tags machine learning, generative adversarial networks, pix2pix, GANs, neural networks, neural network, images, image processing, image-to-image translation
Comment
  • 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