• Home
  • Projects
  • Art
  • Blog
  • CV
Menu

Riley Wong

  • Home
  • Projects
  • Art
  • Blog
  • CV
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
← Implementing Neural Style Transfer from Scratch using PyTorchDogspotting: Using Machine Learning to Draw Bounding Boxes around Dogs in Pictures →
  • 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