"Finally, run this cell to install StyleGAN2-ADA on your Drive. If you’ve already installed the repository, it will skip the installation process and only check for updates. If you haven’t installed it, it will install all the necessary files. Beside, **in**, **out**, **datasets** and **training** folders are generated for data storage. Everything will be available on your Google Drive in the folder **StyleGAN2-ADA** even after closing this Notebook."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "8HX77jscX2zV"
},
"outputs": [],
"source": [
"stylegan2_repo_url = 'https://github.com/dvschultz/stylegan2-ada' # or https://github.com/NVlabs/stylegan2-ada\n",
"Once you have installed StyleGAN2-ADA on your Google Drive and set up the working directory, you can upload your training dataset images in the associated folder."
" print('Upload your images dataset as {}'.format(datasets_source_path))"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "-y1-tvr5617d"
},
"source": [
"Unfortunately, large datasets might exceed the Google Drive quota after a few training batches. Indeed, StyleGAN2 download datasets multiple times during training. You might have to import your dataset in the local storage session. However, large files cannot be copy/paste from Drive *(Input/Output error)*. \n",
"\n",
"Run this cell to download your zipped dataset from your Drive and unzip it in the local session."
"There are numerous arguments to tune the training of your model. To obtain nice results, you will certainly have to experiment. Here are the most popular parameters:\n",
"\n",
"\n",
"* *mirror:* Should the images be mirrored vertically?\n",
"* *mirrory:* Should the images be mirrored horizontally?\n",
"* *snap:* How often should the model generate image samples and a network pickle (.pkl file)?\n",
"* *resume:* Network pickle to resume training from?\n",
"\n",
"To see all the options, run the following ```help``` cell.\n",
"\n",
"Please note that Google Colab Pro gives access to V100 GPUs, which drastically decreases (~3x) processing time over P100 GPUs."
"You can finally generate images using a pre-trained network once everything is set-up. You can naturally use [your own model once it is trained](#scrollTo=Ti11YiPAiQpb&uniqifier=1) or use the ones NVLab published on [their website](https://nvlabs-fi-cdn.nvidia.com/stylegan2-ada/pretrained/).\n",
"... learn more about Generative Adversarial Networks and StyleGAN2-ADA:\n",
"\n",
"* [This Night Sky Does Not Exist](https://arthurfindelair.com/thisnightskydoesnotexist/): Generation of images from a model created using this Notebook on Google Colab Pro.\n",
"* [This **X** Does Not Exist](https://thisxdoesnotexist.com/): Collection of sites showing the power of GANs.\n",
"* [Karras, Tero, et al. _Analyzing and Improving the Image Quality of StyleGAN._ CVPR 2020.](https://arxiv.org/pdf/2006.06676.pdf): Paper published for the release of StyleGAN2-ADA.\n",
"* [Official implementation of StyleGAN2-ADA](https://github.com/NVlabs/stylegan2-ada)\n",
"* [StyleGAN v2: notes on training and latent space exploration](https://towardsdatascience.com/stylegan-v2-notes-on-training-and-latent-space-exploration-e51cf96584b3): Interesting article from Toward Data Science"
1.[Install StyleGAN2-ADA on your Google Drive](#scrollTo=5YcUMPQp6ipP)
2.[Train a custom model](#scrollTo=Ti11YiPAiQpb)
3.[Generate images from pre-trained model](#scrollTo=f0A9ZNtferpk)
4.[Latent space exploration](#scrollTo=5yG1UyHXXqsO)
%% Cell type:markdown id: tags:
## Install StyleGAN2-ADA on your Google Drive
%% Cell type:markdown id: tags:
StyleGAN2-ADA only works with Tensorflow 1. Run the next cell before anything else to make sure we’re using TF1 and not TF2.
%% Cell type:code id: tags:
``` python
%tensorflow_version1.x
!nvidia-smi
```
%% Output
UsageError: Line magic function `%tensorflow_version` not found.
%% Cell type:markdown id: tags:
Then, mount your Drive to the Colab notebook:
%% Cell type:code id: tags:
``` python
fromgoogle.colabimportdrive
frompathlibimportPath
content_path=Path('/').absolute()/'content'
drive_path=content_path/'drive'
drive.mount(str(drive_path))
```
%% Cell type:markdown id: tags:
Finally, run this cell to install StyleGAN2-ADA on your Drive. If you’ve already installed the repository, it will skip the installation process and only check for updates. If you haven’t installed it, it will install all the necessary files. Beside, **in**, **out**, **datasets** and **training** folders are generated for data storage. Everything will be available on your Google Drive in the folder **StyleGAN2-ADA** even after closing this Notebook.
%% Cell type:code id: tags:
``` python
stylegan2_repo_url='https://github.com/dvschultz/stylegan2-ada'# or https://github.com/NVlabs/stylegan2-ada
Once you have installed StyleGAN2-ADA on your Google Drive and set up the working directory, you can upload your training dataset images in the associated folder.
print('Upload your images dataset as {}'.format(datasets_source_path))
```
%% Cell type:markdown id: tags:
Unfortunately, large datasets might exceed the Google Drive quota after a few training batches. Indeed, StyleGAN2 download datasets multiple times during training. You might have to import your dataset in the local storage session. However, large files cannot be copy/paste from Drive *(Input/Output error)*.
Run this cell to download your zipped dataset from your Drive and unzip it in the local session.
There are numerous arguments to tune the training of your model. To obtain nice results, you will certainly have to experiment. Here are the most popular parameters:
**mirror:* Should the images be mirrored vertically?
**mirrory:* Should the images be mirrored horizontally?
**snap:* How often should the model generate image samples and a network pickle (.pkl file)?
**resume:* Network pickle to resume training from?
To see all the options, run the following ```help``` cell.
Please note that Google Colab Pro gives access to V100 GPUs, which drastically decreases (~3x) processing time over P100 GPUs.
You can finally generate images using a pre-trained network once everything is set-up. You can naturally use [your own model once it is trained](#scrollTo=Ti11YiPAiQpb&uniqifier=1) or use the ones NVLab published on [their website](https://nvlabs-fi-cdn.nvidia.com/stylegan2-ada/pretrained/).
... learn more about Generative Adversarial Networks and StyleGAN2-ADA:
*[This Night Sky Does Not Exist](https://arthurfindelair.com/thisnightskydoesnotexist/): Generation of images from a model created using this Notebook on Google Colab Pro.
*[This **X** Does Not Exist](https://thisxdoesnotexist.com/): Collection of sites showing the power of GANs.
*[Karras, Tero, et al. _Analyzing and Improving the Image Quality of StyleGAN._ CVPR 2020.](https://arxiv.org/pdf/2006.06676.pdf): Paper published for the release of StyleGAN2-ADA.
*[Official implementation of StyleGAN2-ADA](https://github.com/NVlabs/stylegan2-ada)
*[StyleGAN v2: notes on training and latent space exploration](https://towardsdatascience.com/stylegan-v2-notes-on-training-and-latent-space-exploration-e51cf96584b3): Interesting article from Toward Data Science