This repository contains part of the code used to make the images visible in the article "How does an AI Imagine the Universe?" published on Towards Data Science: https://towardsdatascience.com/how-does-an-ai-imagine-the-universe-d1d01139b50a
You can also explore the dataset on https://davide-coccomini.github.io/GAN-Universe/
The aim of the article was to create a dataset of celestial bodies and then train a Generative Adversarial Network to generate new ones. Then real galaxy images were used to generate new ones and merge them into a single wide view of space.
The first step is to build the dataset. For this purpose, the following methods may be used:
- Flickr Scraper: https://github.com/ultralytics/flickr_scraper
- Unsplash Scraper: https://www.scrapestorm.com/
- Download All Images Extension: https://chrome.google.com/webstore/detail/download-all-images/ifipmflagepipjokmbdecpmjbibjnakm
Always make sure you have the right to use the images you download before starting training.
In order to be able to generate credible galaxies in our case, the Galaxy Zoo dataset was also used as a dataset in one of the experiments: https://www.kaggle.com/c/galaxy-zoo-the-galaxy-challenge
The images obtained should be carefully checked to ensure consistency and good quality of the dataset. A dataset that is too heterogeneous, too small or at too low a resolution may not lead to the desired results. In our case, a crop_images.py file has been written to crop the images in a squared way in order to avoid deformations when resizing.
The gan.py file was used to train an initial model capable of generating 128x128 images. Experiments were also carried out using the following networks:
- StyleGAN2: https://github.com/lucidrains/stylegan2-pytorch
- Lightweight GAN: https://github.com/lucidrains/lightweight-gan
The repositories used already offer some approaches for generating grids or evolutions of the images obtained. For our own needs, we have created the file create_grid.py which generates a grid of NxM images.
Below we show some of the results obtained from the GANs:
GENERATED CELESTIAL BODIES LIGHTWEIGHT GAN
Since our aim was also to obtain a wide view of the universe, we created the file generate_universe.py which combines the galaxies generated by the network in a chaotic manner, thus obtaining the following result: