None of the butterflies on this website exist in reality. They were generated from a neural network which had been shown many real butterflies as examples.
Sites like thispersondoesnotexist.com and thiswaifudoesnotexist.net have popularised the uncanny ability of Generative Adversarial Networks (GANs) to produce new content through machine learning, with results close to undistinguishable from the real thing. I wanted to try the concept in the natural world.
Visiting the Natural History Museum in London is a wonderful experience, full of creatures large and small. Luckily for those without easy access to the collection in person, they are busy digitising specimens and publishing them on a fantastic data portal that is free and open to the public. You can read about their digitisation efforts here and here.
The butterfly and moth collection is one of the newest to be digitised. Using the api to the data portal, I gathered more than 100,000 images of papilionoidea (true butterflies), in the order lepidopetera (butterflies and moths), from the museum’s icollections project.
I used the amazing fast.ai framework which sits upon pytorch to segment butterflies away from their specimen trays. The goal here was to generate butterflies, not specimen photos, so segmentation removes all the unwanted background. This involved labelling a few hundred butterflies with the rectlabel tool before running a u-net model not unlike that from fastai lesson 3.
This is the magic. The neural network architecture is StyleGAN and I used the pytorch implementation recently released by Facebook Research. The network was trained for 140,000 epochs on a 2080 Ti GPU, which took about 30 hours to run.
30,000 fake butterflies at 512px size were produced. Each refresh of the screen loads another butterfly.
If you’d like a copy of all the images, I’d be happy to provide. But please email me rather than scrape the website.
Add more variety by finetuning on certain species; Generate Birdwings; Show latent interpolations; Publish code.
You can reach me at rob [at] digitalspecialists [dot] ai