stylegan3/Build_Style_Archive.ipynb

684 lines
1.4 MiB
Plaintext
Raw Permalink Normal View History

2022-11-25 19:54:23 +01:00
{
"cells": [
{
"cell_type": "code",
"execution_count": 21,
2022-11-25 19:54:23 +01:00
"id": "ec691ce5-5b12-427d-8335-c4779c0c46a1",
"metadata": {},
"outputs": [],
"source": [
"from runs import Run, Snapshot, get_runs_in_dir\n",
"import tabulate\n",
"import os\n",
"from IPython.display import Markdown as md\n",
"from IPython.display import HTML\n",
2022-11-25 19:54:23 +01:00
"\n",
"import matplotlib.pyplot as plt\n",
"import matplotlib\n",
"import shutil\n",
"import jinja2\n",
"from tqdm.notebook import trange, tqdm"
]
},
{
"cell_type": "markdown",
"id": "388b8a60-cb43-4e82-838d-ee1e5f02819e",
"metadata": {},
"source": [
"# Build an archive of the various runs & snapshots\n",
"\n",
"This notebook can be used to generate a printable html archive, of all runs and their snapshots.\n",
"\n",
"template in [templates/runs.j2](./templates/runs.j2), style in [templates/style.css](./templates/style.css)"
2022-11-25 19:54:23 +01:00
]
},
{
"cell_type": "markdown",
"id": "a6c0aba8-5cd9-4673-a294-bf868bfd85ab",
"metadata": {},
"source": [
"## Configuration"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "65386eb4-e8b1-47b5-9847-4e6b136e03cd",
"metadata": {},
"outputs": [],
"source": [
"\n",
"outdir = os.path.abspath('out/html')"
]
},
{
"cell_type": "markdown",
"id": "cf0c190a-b61f-4840-8096-1e56b9a50eb3",
"metadata": {},
"source": [
"## Output Run Index"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "7fe658a8-79d4-4f06-901a-04ec8270082d",
"metadata": {},
"outputs": [],
"source": [
"#see also https://github.com/matplotlib/matplotlib/blob/f6e0ee49c598f59c6e6cf4eefe473e4dc634a58a/lib/matplotlib/_cm.py#L859\n",
"palette = matplotlib.cm.datad['Accent']['listed']\n",
"palette = matplotlib.cm.datad['Set3']['listed']"
]
},
{
"cell_type": "code",
"execution_count": 4,
2022-11-25 19:54:23 +01:00
"id": "7ab22d2b-70fe-4c38-b661-3fd5fb92adfb",
"metadata": {},
"outputs": [],
"source": [
"def get_rgb_for_idx(i):\n",
" return f\"rgb({palette[i%len(palette)][0]*255}, {palette[i%len(palette)][1]*255},{palette[i%len(palette)][2]*255})\""
2022-11-25 19:54:23 +01:00
]
},
{
"cell_type": "code",
"execution_count": 5,
2022-11-25 19:54:23 +01:00
"id": "652c367f-8e3b-498a-b941-85fc5ab41c21",
"metadata": {},
"outputs": [],
"source": [
"%run ThisPlaceDoesExist.ipynb"
]
},
{
"cell_type": "markdown",
"id": "14bd992a-d1e7-41d6-8484-aff19b999384",
2022-11-25 19:54:23 +01:00
"metadata": {},
"source": [
"Create a plot of the Fréchet inception distance metric for all runs. Use 'cumulative iteration'. That is, if the run picks up from an existing network -- e.g. when the resuming a stopped run -- it plots the line as a continuation.\n",
"\n",
">The Inception Score (IS) is an algorithm used to assess the quality of images created by a generative image model such as a generative adversarial network (GAN). The score is calculated based on the output of a separate, pretrained Inceptionv3 image classification model applied to a sample of (typically around 30,000) images generated by the generative model. The Inception Score is maximized when the following conditions are true:\n",
"\n",
"> 1. The entropy of the distribution of labels predicted by the Inceptionv3 model for the generated images is minimized. In other words, the classification model confidently predicts a single label for each image. Intuitively, this corresponds to the desideratum of generated images being \"sharp\" or \"distinct\".\n",
"> 2. The predictions of the classification model are evenly distributed across all possible labels. This corresponds to the desideratum that the output of the generative model is \"diverse\".\n",
"\n",
"> It has been somewhat superseded by the related Fréchet inception distance. While the Inception Score only evaluates the distribution of generated images, the FID compares the distribution of generated images with the distribution of a set of real images (\"ground truth\"). \n",
"\n",
"([Wikipedia](https://en.wikipedia.org/wiki/Inception_score))"
]
2022-11-25 19:54:23 +01:00
},
{
"cell_type": "code",
"execution_count": 7,
2022-11-25 19:54:23 +01:00
"id": "8529ef31-064d-45bd-b9d7-77991f0e0e0e",
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAADX4AAARHC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8Q/AKAOlBQQfDLdD7BL1/3wS+zraTCZQIAAAAAAAAAAAAAAAAAAAAAgPqF4BcA1IFCDyEsH41WdJpzPzQ3NZo8jkuzFJzzfAEAAAAAAAAAAAAAAAAAAAAAQO0i+AUAdcBT9a3zqfYlIuKr00uA3sftuLRCgl8AAAAAAAAAAAAAAAAAAAAAAFwoCH4BQB0w11DwS0SkqdHP7XAqfgEAAAAAAAAAAAAAAAAAAAAAcOEg+AUAdaBGg1++HoJfVPwCAAAAAAAAAAAAAAAAAAAAAOCCQfALAOqA5+CX7rzn7aniV25JsRRarec9fwAAAAAAAAAAAAAAAAAAAAAAUPPOP2EAAKgyj8EvbXVU/DJ5HJduKZAW/kHnvQwAAAAAAACgIUpISNCIiElEzv9CHQAAAAAAAAAAAIALSYmIFPTo0UOt64Y4IvgFAHXAU/DLT3f+/Un8dT7iq9VJoa18da80gl8AAAAAAABAmYSEhEARuVRE+ovIJSISWrctAgAAAAAAAAAAAFCH7AkJCckiskJElonI3roOghH8AoA6YLa5D375VkPwS1EUaerrJ8fyc8qNSyssOO/5AwAAAAAAABe6hIQEfxGZKiKXi4imblsDAAAAAAAAAAAAoJ7QiEiMiIw/+y85ISHhpR49emypqwYR/EKDpSjKHSJyh5tRptptCeCsxG6TErvd7bjqqPglItLU6CH4ZSH4BQAAAAAAgMYtISGhqYi8IyLtREQURfHRarUBGo3GX1EUH0VRtCKi1GkjAQAAAAAAAAAAANQ2VVVVm6qqZpvNlmuz2fJFpJmIvJuQkDCxrsJfBL/QkMWKyIC6bgTgymx1X+1LRMRUXcEvXz+3wzOLLFJit4leo62W5QAAAAAAAAAXkoSEhFYi8r6
2022-11-25 19:54:23 +01:00
"text/plain": [
"<Figure size 1800x1200 with 1 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"%matplotlib inline\n",
"\n",
"plot = plot_runs(runs, dpi=300, palette=palette)\n",
"plot.legend(bbox_to_anchor=(1,0), loc=\"lower left\")\n",
"# plot.show()\n",
"\n",
"plt.xlabel('Iterations')\n",
"plt.ylabel('Fréchet inception distance (FID)')\n",
"plt.savefig(os.path.join(outdir, 'runs.png'), bbox_inches='tight', transparent=True)"
]
},
{
"cell_type": "markdown",
"id": "05a1422a-e268-4326-8be7-fb0687ceb9f6",
"metadata": {},
"source": [
"Create plots of the loss for both the StyleGAN discriminator (D) and generator (G)."
]
},
2022-11-25 19:54:23 +01:00
{
"cell_type": "code",
"execution_count": 8,
2022-11-25 19:54:23 +01:00
"id": "505733a8-accc-4f2d-a560-b677f538f3c8",
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAEwUAAAi0CAYAAABYAgqYAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/MnkTPAAAACXBIWXMAAC4jAAAuIwF4pT92AAEAAElEQVR4nOzd269c53nY4XdmD0nxIEqxZEuWJR9kOYnjNM2hCYoWaXrRBkgTIGmAFGmv+l8Vve4BSNLCaW8aFC7apC2QxnVTx/GhiRXJskMdSIsUz9wz6/t6wdnUcGsdvjWz96zhrOe5kbjXWjNr+45+X/2+Sc45AAAAAAAAAAAAAAAAAAAAAAAAgOFMh34BAAAAAAAAAAAAAAAAAAAAAAAAGDtRMAAAAAAAAAAAAAAAAAAAAAAAABiYKBgAAAAAAAAAAAAAAAAAAAAAAAAMTBQMAAAAAAAAAAAAAAAAAAAAAAAABiYKBgAAAAAAAAAAAAAAAAAAAAAAAAMTBQMAAAAAAAAAAAAAAAAAAAAAAICBiYIBAAAAAAAAAAAAAAAAAAAAAADAwETBAAAAAAAAAAAAAAAAAAAAAAAAYGCiYAAAAAAAAAAAAAAAAAAAAAAAADAwUTAAAAAAAAAAAAAAAAAAAAAAAAAYmCgYAAAAAAAAAAAAAAAAAAAAAAAADEwUDAAAAAAAAAAAAAAAAAAAAAAAAAYmCgYAAAAAAAAAAAAAAAAAAA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KBgAAAAAAAAAAAAAAAAAAAAAAAAMTBQMAAAAAAAAAAAAAAAAAAAAAAICBiYIBAAAAAAAAAAAAAAAAAAAAAADAwETBAAAAAAAAAAAAAAAAAAAAAAAAYGCzoV8AAAAAdtHNwwfxf374dly9fzc+eeFS/Nxzn4zzszNDvxYAAAAAAAAAbNW1+3fj6++/G9cf3I+XLz4dP/f8S3Fm6mxqAAA
2022-11-25 19:54:23 +01:00
"text/plain": [
"<Figure size 6000x2700 with 2 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"plot = plot_stats([\n",
" 'Loss/D/loss',\n",
" 'Loss/G/loss',\n",
"], runs, palette=palette)\n",
"# plot.legend()\n",
"plt.savefig(os.path.join(outdir, 'run_losses.png'), bbox_inches='tight', transparent=True)"
]
},
{
"cell_type": "code",
"execution_count": 9,
2022-11-25 19:54:23 +01:00
"id": "5e930b94-bcf3-4535-a2f4-213033ea201b",
"metadata": {},
"outputs": [],
"source": [
"index_html = tabulate.tabulate([\n",
" {\n",
" # \"idx\": i,\n",
" # \"conditional\": run.dataset_is_conditional(),\n",
" **run.get_summary(),\n",
" \"nr\": f\"<a href='#run{run.as_nr}'>{run.as_nr}</a>\",\n",
" \n",
" \"page\": f\"<span class='tocitem' style='color:{get_rgb_for_idx(i)}' data-ref='#run{run.as_nr}'>&#129926;</span>\",\n",
" \n",
" } for i, run in enumerate(runs)\n",
" ], tablefmt='unsafehtml', headers=\"keys\", colalign=(\"left\",\"left\")\n",
")"
]
},
{
"cell_type": "code",
"execution_count": 10,
2022-11-25 19:54:23 +01:00
"id": "5158563d-46df-4827-b759-a1c2dc7fcd15",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<table>\n",
"<thead>\n",
"<tr><th>nr </th><th>dataset </th><th>conditional </th><th style=\"text-align: right;\"> resolution</th><th style=\"text-align: right;\"> gamma</th><th>duration </th><th style=\"text-align: right;\"> iterations</th><th style=\"text-align: right;\"> last_fid</th><th>page </th></tr>\n",
2022-11-25 19:54:23 +01:00
"</thead>\n",
"<tbody>\n",
"<tr><td><a href='#run00001'>00001</a></td><td>paris3 </td><td>True </td><td style=\"text-align: right;\"> 256</td><td style=\"text-align: right;\"> 8.2</td><td>3 days, 10:34:26 </td><td style=\"text-align: right;\"> 2600</td><td style=\"text-align: right;\"> 502.277 </td><td><span class='tocitem' style='color:rgb(141.0, 211.0,199.0)' data-ref='#run00001'>&#129926;</span></td></tr>\n",
"<tr><td><a href='#run00002'>00002</a></td><td>paris3 </td><td>True </td><td style=\"text-align: right;\"> 256</td><td style=\"text-align: right;\"> 2 </td><td>5 days, 3:43:08 </td><td style=\"text-align: right;\"> 6560</td><td style=\"text-align: right;\"> 190.346 </td><td><span class='tocitem' style='color:rgb(255.0, 255.0,179.0)' data-ref='#run00002'>&#129926;</span></td></tr>\n",
"<tr><td><a href='#run00003'>00003</a></td><td>paris3 </td><td>True </td><td style=\"text-align: right;\"> 256</td><td style=\"text-align: right;\"> 2 </td><td>18 days, 13:01:50</td><td style=\"text-align: right;\"> 25000</td><td style=\"text-align: right;\"> 42.9661</td><td><span class='tocitem' style='color:rgb(190.0, 186.0,218.0)' data-ref='#run00003'>&#129926;</span></td></tr>\n",
"<tr><td><a href='#run00004'>00004</a></td><td>paris3 </td><td>False </td><td style=\"text-align: right;\"> 256</td><td style=\"text-align: right;\"> 2 </td><td>15 days, 16:13:20</td><td style=\"text-align: right;\"> 22800</td><td style=\"text-align: right;\"> 15.6691</td><td><span class='tocitem' style='color:rgb(251.0, 128.0,114.0)' data-ref='#run00004'>&#129926;</span></td></tr>\n",
"<tr><td><a href='#run00009'>00009</a></td><td>paris3-1024.zip </td><td>False </td><td style=\"text-align: right;\"> 1024</td><td style=\"text-align: right;\"> 32 </td><td>0:00:00 </td><td style=\"text-align: right;\"> 0</td><td style=\"text-align: right;\"> 549.99 </td><td><span class='tocitem' style='color:rgb(128.0, 177.0,211.0)' data-ref='#run00009'>&#129926;</span></td></tr>\n",
"<tr><td><a href='#run00010'>00010</a></td><td>paris3-1024.zip </td><td>False </td><td style=\"text-align: right;\"> 1024</td><td style=\"text-align: right;\"> 32 </td><td>50 days, 3:15:24 </td><td style=\"text-align: right;\"> 15200</td><td style=\"text-align: right;\"> 33.2466</td><td><span class='tocitem' style='color:rgb(253.0, 180.0,98.0)' data-ref='#run00010'>&#129926;</span> </td></tr>\n",
"<tr><td><a href='#run00011'>00011</a></td><td>paris3-1024.zip </td><td>False </td><td style=\"text-align: right;\"> 1024</td><td style=\"text-align: right;\"> 10 </td><td>5 days, 18:48:04 </td><td style=\"text-align: right;\"> 1760</td><td style=\"text-align: right;\"> 200.356 </td><td><span class='tocitem' style='color:rgb(179.0, 222.0,105.0)' data-ref='#run00011'>&#129926;</span></td></tr>\n",
"<tr><td><a href='#run00014'>00014</a></td><td>paris3-cropped-256 </td><td>False </td><td style=\"text-align: right;\"> 256</td><td style=\"text-align: right;\"> 8 </td><td>2 days, 20:08:22 </td><td style=\"text-align: right;\"> 4160</td><td style=\"text-align: right;\"> 20.1699</td><td><span class='tocitem' style='color:rgb(252.0, 205.0,229.0)' data-ref='#run00014'>&#129926;</span></td></tr>\n",
"<tr><td><a href='#run00016'>00016</a></td><td>paris3-cropped-256 </td><td>False </td><td style=\"text-align: right;\"> 256</td><td style=\"text-align: right;\"> 8 </td><td>12 days, 16:48:33</td><td style=\"text-align: right;\"> 18560</td><td style=\"text-align: right;\"> 18.1838</td><td><span class='tocitem' style='color:rgb(217.0, 217.0,217.0)' data-ref='#run00016'>&#129926;</span></td></tr>\n",
"<tr><td><a href='#run00022'>00022</a></td><td>VLoD-cropped2048-scaled1024</td><td>False </td><td style=\"text-align: right;\"> 1024</td><td style=\"text-align: right;\"> 32 </td><td>0:00:00 </td><td style=\"text-align: right;\"> 0</td><td style=\"text-align: right;\"> 539.38 </td><td><span class='tocitem' style='color:rgb(188.0, 128.0,189.0)' data-ref='#run00022'>&#129926;</span></td></tr>\n",
"<tr><td><a href='#run00023'>00023</a></td><td>VLoD-cropped2048-scaled1024</td><td>False </td><td style=\"text-align: right;\"> 1024</td><td style=\"text-align: right;\"> 32 </td><td>1 day, 13:17:19 </td><td style=\"text-align: right;\"> 480</td><td style=\"text-align: right;\"> 201.189 </td><td><span class='tocitem' style='color:rgb(204.0, 235.0,197.0)' data-ref='#run00023'>&#129926;</span></td></tr>\n",
"<tr><td><a href='#run00024'>00024</a></td><td>VLoD-cropped2048-scaled1024</td><td>False </td><td style=\"text-align: right;\"> 1024</td><td style=\"text-align: right;\"> 32 </td><td>13 days, 1:04:11 </td><td style=\"text-align: right;\"> 4000</td><td style=\"text-align: right;\"> 65.2584</td><td><span class='tocitem' style='color:rgb(255.0, 237.0,111.0)' data-ref='#run00024'>&#129926;</span></td></tr>\n",
"<tr><td><a href='#run00025'>00025</a></td><td>VLoD-cropped2048-scaled1024</td><td>False </td><td style=\"text-align: right;\"> 1024</td><td style=\"text-align: right;\"> 16 </td><td>19 days, 8:47:32 </td><td style=\"text-align: right;\"> 5920</td><td style=\"text-align: right;\"> 391.724 </td><td><span class='tocitem' style='color:rgb(141.0, 211.0,199.0)' data-ref='#run00025'>&#129926;</span></td></tr>\n",
2022-11-25 19:54:23 +01:00
"</tbody>\n",
"</table>"
],
"text/plain": [
"'<table>\\n<thead>\\n<tr><th>nr </th><th>dataset </th><th>conditional </th><th style=\"text-align: right;\"> resolution</th><th style=\"text-align: right;\"> gamma</th><th>duration </th><th style=\"text-align: right;\"> iterations</th><th style=\"text-align: right;\"> last_fid</th><th>page </th></tr>\\n</thead>\\n<tbody>\\n<tr><td><a href=\\'#run00001\\'>00001</a></td><td>paris3 </td><td>True </td><td style=\"text-align: right;\"> 256</td><td style=\"text-align: right;\"> 8.2</td><td>3 days, 10:34:26 </td><td style=\"text-align: right;\"> 2600</td><td style=\"text-align: right;\"> 502.277 </td><td><span class=\\'tocitem\\' style=\\'color:rgb(141.0, 211.0,199.0)\\' data-ref=\\'#run00001\\'>&#129926;</span></td></tr>\\n<tr><td><a href=\\'#run00002\\'>00002</a></td><td>paris3 </td><td>True </td><td style=\"text-align: right;\"> 256</td><td style=\"text-align: right;\"> 2 </td><td>5 days, 3:43:08 </td><td style=\"text-align: right;\"> 6560</td><td style=\"text-align: right;\"> 190.346 </td><td><span class=\\'tocitem\\' style=\\'color:rgb(255.0, 255.0,179.0)\\' data-ref=\\'#run00002\\'>&#129926;</span></td></tr>\\n<tr><td><a href=\\'#run00003\\'>00003</a></td><td>paris3 </td><td>True </td><td style=\"text-align: right;\"> 256</td><td style=\"text-align: right;\"> 2 </td><td>18 days, 13:01:50</td><td style=\"text-align: right;\"> 25000</td><td style=\"text-align: right;\"> 42.9661</td><td><span class=\\'tocitem\\' style=\\'color:rgb(190.0, 186.0,218.0)\\' data-ref=\\'#run00003\\'>&#129926;</span></td></tr>\\n<tr><td><a href=\\'#run00004\\'>00004</a></td><td>paris3 </td><td>False </td><td style=\"text-align: right;\"> 256</td><td style=\"text-align: right;\"> 2 </td><td>15 days, 16:13:20</td><td style=\"text-align: right;\"> 22800</td><td style=\"text-align: right;\"> 15.6691</td><td><span class=\\'tocitem\\' style=\\'color:rgb(251.0, 128.0,114.0)\\' data-ref=\\'#run00004\\'>&#129926;</span></td></tr>\\n<tr><td><a href=\\'#run00009\\'>00009</a></td><td>paris3-1024.zip </td><td>False </td><td style=\"text-align: right;\"> 1024</td><td style=\"text-align: right;\"> 32 </td><td>0:00:00 </td><td style=\"text-align: right;\"> 0</td><td style=\"text-align: right;\"> 549.99 </td><td><span class=\\'tocitem\\' style=\\'color:rgb(128.0, 177.0,211.0)\\' data-ref=\\'#run00009\\'>&#129926;</span></td></tr>\\n<tr><td><a href=\\'#run00010\\'>00010</a></td><td>paris3-1024.zip </td><td>False </td><td style=\"text-align: right;\"> 1024</td><td style=\"text-align: right;\"> 32 </td><td>50 days, 3:15:24 </td><td style=\"text-align: right;\"> 15200</td><td style=\"text-align: right;\"> 33.2466</td><td><span class=\\'tocitem\\' style=\\'color:rgb(253.0, 180.0,98.0)\\' data-ref=\\'#run00010\\'>&#129926;</span> </td></tr>\\n<tr><td><a href=\\'#run00011\\'>00011</a></td><td>paris3-1024.zip </td><td>False </td><td style=\"text-align: right;\"> 1024</td><td style=\"text-align: right;\"> 10 </td><td>5 days, 18:48:04 </td><td style=\"text-align: right;\"> 1760</td><td style=\"text-align: right;\"> 200.356 </td><td><span class=\\'tocitem\\' style=\\'color:rgb(179.0, 222.0,105.0)\\' data-ref=\\'#run00011\\'>&#129926;</span></td></tr>\\n<tr><td><a href=\\'#run00014\\'>00014</a></td><td>paris3-cropped-256 </td><td>False </td><td style=\"text-align: right;\"> 256</td><td style=\"text-align: right;\"> 8 </td><td>2 days, 20:08:22 </td><td style=\"text-align: right;\"> 4160</td><td style=\"text-align: right;\"> 20.1699</td><td><span class=\\'tocitem\\' style=\\'color:rgb(252.0, 205.0,229.0)\\' data-ref=\\'#run00014\\'>&#129926;</span></td></tr>\\n<tr><td><a href=\\'#
2022-11-25 19:54:23 +01:00
]
},
"execution_count": 10,
2022-11-25 19:54:23 +01:00
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"index_html"
]
},
{
"cell_type": "markdown",
"id": "63135d88-f55d-4653-944e-b1e55e526409",
"metadata": {},
"source": [
"The pages are generated in HTML using the jinja2 templating library. "
]
},
2022-11-25 19:54:23 +01:00
{
"cell_type": "code",
"execution_count": 42,
2022-11-25 19:54:23 +01:00
"id": "db1e8346-a8df-48ab-a184-7e9330b5c691",
"metadata": {},
"outputs": [],
"source": [
"jinja_env = jinja2.Environment(\n",
" loader=jinja2.FileSystemLoader(\"templates\"),\n",
" autoescape=jinja2.select_autoescape()\n",
")\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": 43,
2022-11-25 19:54:23 +01:00
"id": "90096383-ecaa-4c05-8d8b-f992e26c283b",
"metadata": {},
"outputs": [],
"source": [
"template = jinja_env.get_template(\"runs.j2\")\n"
]
},
{
"cell_type": "code",
"execution_count": 56,
"id": "1180a4aa-4d1d-4999-b838-e607d22077f3",
"metadata": {
"jupyter": {
"source_hidden": true
},
"tags": []
},
"outputs": [
{
"data": {
"text/html": [
"\n",
"<h2>Introduction</h2>\n",
"<p>This document is part of <em>This Place Does Exist</em>. In this project a StyleGAN3 network was trained on a series of just over 3000 photos of shopfronts in Paris. This document provides an overview of all networks that were trained, including their intermediary snapshots. For every snapshot of the network a series of preview images is provided.</p>\n",
"\n",
"<p>Some of our observations:</p>\n",
"\n",
"<ul>\n",
"<li>\n",
"Right of the start it proved important to pick the right network. For example run 00002 contained rotated images because it used the <em>stylegan3-t</em> (translation equivalent) instead of <em>stylegan3-r</em> (translation and rotation equivalent) configuration.\n",
"</li><li>\n",
"The first runs were trained using a conditional dataset, in which the arrondissement was encoded. However, we got the impression that the training without an arrondissement condition lead to more diverse images.\n",
"</li>\n",
"<li>\n",
"On some occasions a 'mode collapse' occurs, which means that the generator start producing only a limited variety of images. This effect is particularly visible in run 00001 and 00025 in which the generated images suddenly become indistinguishable blurbs. \n",
"However, in some extend this is also visible in other networks, which shift from rather saturated images to generating images in which have more washed out sepia colours. This can be seen quite clearly in run 00002, 00004, or 00010.\n",
"This most likely occurs due to the dominance of Paris' Haussmannian architecture that frames the shop fronts, and which is visible in a large number of the training images.\n",
"</li>\n",
"<li>\n",
"In order to overcome this, we tried cropping the images to about 70% of their original size. For a large part this removed the Haussmannian limestone from the images, indeed leading to generated images that were richer in colour. \n",
"</li><li>\n",
"When generating larger images, 1024x1024 pixels instead of 256x256, different training parameters were needed. Over the course of the project we were unable to have the large images match the quality of the smaller images.\n",
"</li>\n",
"</ul>\n",
"\n",
"<p>In order to make sense of the first graph in this document, which shows the FID, or Fréchet Inception distance, it might be good to have a sense of what this metric means:</p>\n",
"<figure>\n",
"<blockquote>\n",
" <p>The Inception Score (IS) is an algorithm used to assess the quality of images created by a generative image model such as a generative adversarial network (GAN). The score is calculated based on the output of a separate, pretrained Inceptionv3 image classification model applied to a sample of (typically around 30,000) images generated by the generative model. The Inception Score is maximized when the following conditions are true:</p>\n",
" <ol>\n",
" <li>The entropy of the distribution of labels predicted by the Inceptionv3 model for the generated images is minimized. In other words, the classification model confidently predicts a single label for each image. Intuitively, this corresponds to the desideratum of generated images being \"sharp\" or \"distinct\".</li>\n",
" <li>The predictions of the classification model are evenly distributed across all possible labels. This corresponds to the desideratum that the output of the generative model is \"diverse\".</li>\n",
" </ol>\n",
"\n",
" <p>It has been somewhat superseded by the related Fréchet inception distance. While the Inception Score only evaluates the distribution of generated images, the FID compares the distribution of generated images with the distribution of a set of real images (\"ground truth\"). </p>\n",
"</blockquote>\n",
"<figcaption>(from: <a href=\"https://en.wikipedia.org/wiki/Inception_score\">Wikipedia, Inception Score</a>)</figcaption>\n",
"</figure>\n"
],
"text/plain": [
"<IPython.core.display.HTML object>"
]
},
"execution_count": 56,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"introduction = \"\"\"\n",
"<h2>Introduction</h2>\n",
"<p>This document is part of <em>This Place Does Exist</em>. In this project a StyleGAN3 network was trained on a series of just over 3000 photos of shopfronts in Paris. This document provides an overview of all networks that were trained, including their intermediary snapshots. For every snapshot of the network a series of preview images is provided.</p>\n",
"\n",
"<p>Some of our observations:</p>\n",
"\n",
"<ul>\n",
"<li>\n",
"Right of the start it proved important to pick the right network. For example run 00002 contained rotated images because it used the <em>stylegan3-t</em> (translation equivalent) instead of <em>stylegan3-r</em> (translation and rotation equivalent) configuration.\n",
"</li><li>\n",
"The first runs were trained using a conditional dataset, in which the arrondissement was encoded. However, we got the impression that the training without an arrondissement condition lead to more diverse images.\n",
"</li>\n",
"<li>\n",
"On some occasions a 'mode collapse' occurs, which means that the generator start producing only a limited variety of images. This effect is particularly visible in run 00001 and 00025 in which the generated images suddenly become indistinguishable blurbs. \n",
"However, in some extend this is also visible in other networks, which shift from rather saturated images to generating images in which have more washed out sepia colours. This can be seen quite clearly in run 00002, 00004, or 00010.\n",
"This most likely occurs due to the dominance of Paris' Haussmannian architecture that frames the shop fronts, and which is visible in a large number of the training images.\n",
"</li>\n",
"<li>\n",
"In order to overcome this, we tried cropping the images to about 70% of their original size. For a large part this removed the Haussmannian limestone from the images, indeed leading to generated images that were richer in colour. \n",
"</li><li>\n",
"When generating larger images, 1024x1024 pixels instead of 256x256, different training parameters were needed. Over the course of the project we were unable to have the large images match the quality of the smaller images.\n",
"</li>\n",
"</ul>\n",
"\n",
"<p>In order to make sense of the first graph in this document, which shows the FID, or Fréchet Inception distance, it might be good to have a sense of what this metric means:</p>\n",
"<figure>\n",
"<blockquote>\n",
" <p>The Inception Score (IS) is an algorithm used to assess the quality of images created by a generative image model such as a generative adversarial network (GAN). The score is calculated based on the output of a separate, pretrained Inceptionv3 image classification model applied to a sample of (typically around 30,000) images generated by the generative model. The Inception Score is maximized when the following conditions are true:</p>\n",
" <ol>\n",
" <li>The entropy of the distribution of labels predicted by the Inceptionv3 model for the generated images is minimized. In other words, the classification model confidently predicts a single label for each image. Intuitively, this corresponds to the desideratum of generated images being \"sharp\" or \"distinct\".</li>\n",
" <li>The predictions of the classification model are evenly distributed across all possible labels. This corresponds to the desideratum that the output of the generative model is \"diverse\".</li>\n",
" </ol>\n",
"\n",
" <p>It has been somewhat superseded by the related Fréchet inception distance. While the Inception Score only evaluates the distribution of generated images, the FID compares the distribution of generated images with the distribution of a set of real images (\"ground truth\"). </p>\n",
"</blockquote>\n",
"<figcaption>(from: <a href=\"https://en.wikipedia.org/wiki/Inception_score\">Wikipedia, Inception Score</a>)</figcaption>\n",
"</figure>\n",
"\"\"\"\n",
"HTML(introduction)"
]
},
{
"cell_type": "code",
"execution_count": 57,
2022-11-25 19:54:23 +01:00
"id": "460fef2f-19a2-435b-959d-279215a5cd05",
"metadata": {},
"outputs": [],
"source": [
"template_vars = {\n",
" \"runs_graph\": \"runs.png\",\n",
" \"runs_losses_graph\": \"run_losses.png\",\n",
" \"runs_table\": index_html,\n",
" \"runs\": runs,\n",
" \"introduction\": introduction,\n",
2022-11-25 19:54:23 +01:00
"}"
]
},
{
"cell_type": "code",
"execution_count": 58,
2022-11-25 19:54:23 +01:00
"id": "361e549e-27a4-4ce8-9e7c-5a2906bcab5e",
"metadata": {},
"outputs": [],
"source": [
"with open(os.path.join(outdir, 'index.html'), 'w') as fp:\n",
" fp.write(template.render(**template_vars))"
]
},
{
"cell_type": "markdown",
"id": "02f0ca23-4476-4006-908e-82ad7dfec4c2",
"metadata": {},
"source": [
"Copy necessary auxilary files to the output directory:"
]
},
{
"cell_type": "code",
"execution_count": 59,
2022-11-25 19:54:23 +01:00
"id": "9baf8011-5be8-46b2-ae90-89a859667a39",
"metadata": {},
"outputs": [],
"source": [
"files = [\n",
" \"templates/style.css\", \n",
" \"templates/pagedjs-interface.css\",\n",
"]\n",
"for src in files:\n",
" shutil.copy(src, outdir)"
]
},
{
"cell_type": "markdown",
"id": "635a9374-96a9-4caa-bc39-60a748591d74",
"metadata": {},
"source": [
"All network snaphots also have a some preview images stored. Crop these into smaller preview images and save these to the output folder."
]
},
2022-11-25 19:54:23 +01:00
{
"cell_type": "code",
"execution_count": 60,
2022-11-25 19:54:23 +01:00
"id": "0e8f4dce-4e55-4912-b4eb-ab3e9814aec1",
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "18de0998a0814c2aa9ea874bcd223fbc",
2022-11-25 19:54:23 +01:00
"version_major": 2,
"version_minor": 0
},
"text/plain": [
" 0%| | 0/14 [00:00<?, ?it/s]"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "6d93bd5a1c9846bb80c34fbb2eac740f",
2022-11-25 19:54:23 +01:00
"version_major": 2,
"version_minor": 0
},
"text/plain": [
" 0%| | 0/83 [00:00<?, ?it/s]"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "020310d0e6d44b97a18ddc5f3d799036",
2022-11-25 19:54:23 +01:00
"version_major": 2,
"version_minor": 0
},
"text/plain": [
" 0%| | 0/314 [00:00<?, ?it/s]"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "98cfb05063b0425db317c41a23245830",
2022-11-25 19:54:23 +01:00
"version_major": 2,
"version_minor": 0
},
"text/plain": [
" 0%| | 0/115 [00:00<?, ?it/s]"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "0f9d766fff5a4baa82cfc75f45289e75",
2022-11-25 19:54:23 +01:00
"version_major": 2,
"version_minor": 0
},
"text/plain": [
" 0%| | 0/1 [00:00<?, ?it/s]"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "e8404869786944219a58f379117cfaab",
2022-11-25 19:54:23 +01:00
"version_major": 2,
"version_minor": 0
},
"text/plain": [
" 0%| | 0/96 [00:00<?, ?it/s]"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "f9aafcc934364dd5b2f69edf9ba690fc",
2022-11-25 19:54:23 +01:00
"version_major": 2,
"version_minor": 0
},
"text/plain": [
" 0%| | 0/12 [00:00<?, ?it/s]"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "d471ca711fe04d5997955918a5c03d02",
2022-11-25 19:54:23 +01:00
"version_major": 2,
"version_minor": 0
},
"text/plain": [
" 0%| | 0/27 [00:00<?, ?it/s]"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "cec0860fac684031b853c32f83e9fc6c",
2022-11-25 19:54:23 +01:00
"version_major": 2,
"version_minor": 0
},
"text/plain": [
" 0%| | 0/117 [00:00<?, ?it/s]"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "9e3d6a4b9ce3464095f52d71a2e05875",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
" 0%| | 0/1 [00:00<?, ?it/s]"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "2c542083ac02420197db65b49a6e22fb",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
" 0%| | 0/4 [00:00<?, ?it/s]"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "8044bc90a09442c0bf3f6ab4ba6391f2",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
" 0%| | 0/26 [00:00<?, ?it/s]"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "68603224b2ce4ced83b8d9f784a035b1",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
" 0%| | 0/38 [00:00<?, ?it/s]"
2022-11-25 19:54:23 +01:00
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"for run in runs:\n",
" nr = 7 if run.resolution > 512 else 8\n",
" for snapshot in tqdm(run.snapshots):\n",
" filename = os.path.join(outdir, 'imgs', snapshot.id + \".jpg\")\n",
" if not os.path.exists(filename):\n",
" img = snapshot.get_preview_img(nr,1)\n",
" img.save(filename)"
]
},
{
"cell_type": "markdown",
"id": "1137b09b-f458-406d-bf53-a6cb1de4f831",
"metadata": {},
"source": [
"Run the python http server to serve the document and images. These can now be opened with any browser. In my experience however is that the pdfs produced by Chromium are of a much, much smaller filesize than those produced by Firefox -- which unfortunately sometimes even crashes on producing the >100 page PDF."
]
},
2022-11-25 19:54:23 +01:00
{
"cell_type": "code",
"execution_count": null,
"id": "62ce4172-edd5-439f-a83a-7be7f2b7c4fe",
"metadata": {},
"outputs": [],
"source": [
"!cd out/html && python -m http.server"
]
2022-11-25 19:54:23 +01:00
},
{
"cell_type": "code",
"execution_count": null,
"id": "422a7731-cc1b-4480-9f67-0683c0b3e988",
2022-11-25 19:54:23 +01:00
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "paris-stylegan3",
"language": "python",
"name": "paris-stylegan3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.10"
}
},
"nbformat": 4,
"nbformat_minor": 5
}