This repository is under construction as a compagnon repository to an article in preparation. Here is the purpose of the study:
"Generative models have recently revolutionized image generation tasks across diverse domains, including galaxy image synthesis. This study investigates the statistical learning and consistency of three generative models: light-weight-gan (a GAN-based model), Glow (a Normalizing Flow-based model), and a diffusion model based on a U-Net denoiser, all trained on non-overlapping subsets of the SDSS DR7 dataset of 64 × 64 grayscale images. While all models produce visually realistic images with well-preserved morphological variable distributions, we focus on their ability to learn and generalize the underlying data distribution.[...]"
Concerning the galaxy image datasets and trained models and generated samples, as their sized are too large for this GitHub repository, they are available on a publicly accessible CNRS Cloud, and one can ask me to get the link.
One can use the following models:
- a diffusion model based on
U-Net(diffusion_model_sdss). The source of the original code is available here. The associated article is available Kadkhodaie et al. (2024) - a flow-based model (
glow_model_sdss). The source of the Pytorch implementation used of theGlowarchitecture is avaliable here. Notice that the original architecture was implemented in TensorFlow here. The associated article is available at Kingma & Dhariwal (2018) - a GAN-based model (
lightweight_gan). The source of the implementation used is available here and the official code is available here. The associated article is available at Liu et al. (2021)
In the three mentioned directories, one may find SLURM submission scripts (exemple for Jean Zay at IDRIS a French supercomputer ), some adaptations of python codes to be used in the context of the article and notebooks to reproduce figures.
A the top directory one can use two notebooks:
models_sample_images.ipynbto display generated galaxy samples of the three models (see below how to get the provided samples)morphology_sdss_gen.ipynbto compute and display morphological variable distribution based on thestatmorphpython package.
They are available on demand, here is a brief description:
sdss_100000_A.tarandsdss_100000_B.tartwo independant sets composed of 100,000 images each used to trained independantly 2 models ofglow_model_sdssorlightweight_ganarchitectures. These tar-files are structured to be used bytorchvision.datasets.ImageFolder. The images are stored in 64x64 grayscale PNG 8-bits. From these two datasets, then one can extract 10,000 and 1,000 images to explore the training on smaller datasets.sdss_train_no_repeats_64x64.pt: a collection of 250,000 images as Pytorch tensor (float32) to be used bydiffusion_model_sdss. They are issued from the same original dataset used to make thesdss_100000_(A|B).tarfiles.- The datasets may conveniently be placed at the root of the repository such that for exemple
./datasets/sdss_100000_A/...
They are available on demand too, here is a brief description:
- The
diffusion_models.taranddiffusion_results.tarfiles to be extracted such that thediffusion_model_sdssdirectory looks likediffusion_model_sdss/denoisers/...anddiffusion_model_sdss/results/.... The "denoisers" are the optimized models trained with corresponding datasets (A or B and 10^n with n=0,1,2,3,4,5 images). The "results" are 10,000 samples generated by models trained with 10^5, 10^4 and 10^3 images. - The
gan_models.tarandgan_results.tarfiles to extracted in thelightweight_gandirectory. Thelightweight_gan/models/...files are optimized models trained with 10^5, 10^4 and 10^3 images and at different epochs (eg. 0,10,50,100,150) (nb. last epoch is 147 for the case 10^5). Thelightweight_gan/results/...are generated samples by models optimized with 10^5, 10^4 and 10^3 images. - The
glow_models_results.tarfile group both the optimized models and generated images as well as latent variables used in the context of the "inversion test" described in the article. The extraction is to be done in theglow_model_sdssdirectory. The structure looks likeresults/results_glow_model_1000/...where 1000 is the size of the training dataset used (one gets also the same structure with 10,000 and 100,000 dataset sizes). Then, one gets two directoriesoutput_1000_2ndmod_Aandoutput_1000_2ndmod_Bfocued on A & B models with the optimized models. One also getsglow_samples...ptfiles identified by their source "A" or "B" models, the training size repeate, and some tags lioke4000_T1.0_2.ptwhich indicates the sulber of samples the temperature used and an possible index (nb. the 10^4 and 10^3 dataset cases are merging the A & B generated samples).
