This Icon Does Not Exist
Using GANs to generate unique icon designs, with model behavior examples and creative applications for design workflows.
- Dataset
- ~1000 icons
- Baseline
- DCGAN
- Compute
- Colab T4
- Issue
- Mode collapse
Generative Adversarial Networks (aka. GANs) are one of the most important type of neural networks. As they provide a direct way to create something new out of the thin air. There is a lot of literature out there which explains GANs from their working in theory to their practical implications.
In this article, I will share my experience of applying GAN to a specific problem. The problem statement is “Given large enough Icons dataset, can a GAN learn its distribution?” GANs are well know to learn the underlying distribution of data. This helps not only to fit the entire dataset in a single neural network but also related data points not present in the dataset.
The “This Does Not Exist” Trend
this*doesnotexist.com is a general trend many people use to display output of GAN for their application. e.g. thispersondoesnotexist.com is website which shows new face generated by a GAN. Hence the title of this article.
The Experiment Setup
Step 1: Baseline Implementation
I started off this experiment by implementing vanilla DC GAN and then fitting it to MNIST, which worked as expected.
Step 2: Data Collection
Next step was to scrape data around the internet. I wrote some scraping scripts and collected around ~1000 different icons of size 512x512.
Step 3: Data Cleaning
Even though this data is small compared to 60,000 MNIST samples, it was enough for a baseline. The data was not clean, so I wrote cleaning scripts and converted icons to mimic MNIST-like style.
Training Infrastructure
Google Colab Setup
I used Google Colab for training my network. They (sometime) offer Tesla T4 for free for at max 24 hours (can be interrupted in between). Tesla T4 has comparable performance with RTX 2070. You can use Google Drive to provide storage for Colab. So if you modify your code so that interruptions, jupyter notebook and Google Drive does not affect you, you get a free high performance GPU for training.
Training Progress Visualization
Following are snapshots from training (losses in left, output in the middle and ground truth in right):
Epoch ~ 1: Initial Patterns
It started off as expected, trying to pick up some patterns:
Epoch ~ 10: Basic Shapes
After 10 epochs, it is trying to produce basic patterns:
Epoch ~ 40: Recognizable Forms
After around 50 epochs, it is producing blurry and broken shapes but good progress so far.
Epoch ~ 70: Hand-drawn Quality
But around 70 epochs, shapes look like hand-drawn icons:
Epoch ~ 700: Mode Collapse
However, after 500 epochs, generator loss became very high but discriminator loss got almost zero, which means the discriminator got too good and the generator lost this game.
Challenges & Insights
- Mode collapse: the discriminator became too strong, causing the generator to fail at diverse output.
- Limited dataset: ~1000 icons is small compared with MNIST’s 60,000 samples.
- Training time: Colab’s 24-hour sessions and interruptions constrained iteration.
- Hyperparameter tuning: generator and discriminator learning rates need careful balance.
Future Directions
- Text-to-icon generation: use word embeddings to describe icons and generate them from keywords.
- Larger dataset: collect more diverse icon samples.
- Advanced architectures: try more modern GAN variants such as StyleGAN or Progressive GAN.
Conclusion
Thanks for reading this article. This project is work in progress and I will share the update once I have some promising results. In the meantime you can checkout the repository I created for this project. If you have any questions, let me know in the comments.
This post is application supplement in machine learning for toptal application.
NaxAlpha/xgan is a highly customizable implementation of GAN for rapid prototyping using PyTorch.