{ "cells": [ { "cell_type": "markdown", "id": "af81af06", "metadata": {}, "source": [ "# 06 - Final Family Comparison\n", "\n", "Phase 5 is the project-level comparison. It loads the already trained best\n", "recipes from the GAN, VAE, and DDPM branches and compares their saved logs,\n", "sample grids, and checkpoint-based interpolation diagnostics.\n", "\n", "The earlier notebooks explain how each recipe was selected. This notebook asks\n", "the practical question: which family gives the best quality, which is fastest,\n", "and which one should the project recommend overall?\n", "\n", "## What this phase changes\n", "\n", "Nothing new is trained here. The comparison uses the saved Phase 5 artifacts:\n", "\n", "| Family | Selected recipe |\n", "|---|---|\n", "| GAN | WGAN-GP with spectral norm, GroupNorm, and self-attention |\n", "| VAE | MSE + KL + perceptual + PatchGAN losses |\n", "| DDPM | Cosine schedule + v-prediction + wider U-Net |\n", "\n", "**Headline FIDs from saved logs:** p5_ddpm=19.0, p5_gan=22.0, p5_vae=46.2.\n" ] }, { "cell_type": "code", "execution_count": 1, "id": "343b1883", "metadata": { "execution": { "iopub.execute_input": "2026-05-14T19:09:24.497912Z", "iopub.status.busy": "2026-05-14T19:09:24.497912Z", "iopub.status.idle": "2026-05-14T19:09:25.480482Z", "shell.execute_reply": "2026-05-14T19:09:25.479472Z" } }, "outputs": [], "source": [ "import json\n", "from pathlib import Path\n", "\n", "import matplotlib.pyplot as plt\n", "import matplotlib.image as mpimg\n", "import numpy as np\n", "import pandas as pd\n", "\n", "plt.rcParams.update({\"figure.dpi\": 120, \"font.size\": 10})\n", "\n", "try:\n", " display\n", "except NameError:\n", " def display(obj):\n", " print(obj)\n", "\n", "def find_generator_root():\n", " for base in [Path.cwd(), *Path.cwd().parents]:\n", " for candidate in [base, base / \"generator\"]:\n", " if (candidate / \"outputs\" / \"logs\").exists() and (candidate / \"outputs\" / \"samples\").exists():\n", " return candidate.resolve()\n", " raise FileNotFoundError(\"Could not locate generator/outputs from the current working directory\")\n", "\n", "GENERATOR_ROOT = find_generator_root()\n", "PROJECT_ROOT = GENERATOR_ROOT.parent\n", "OUTPUTS = GENERATOR_ROOT / \"outputs\"\n", "LOGS = OUTPUTS / \"logs\"\n", "SAMPLES = OUTPUTS / \"samples\"\n", "\n", "\n", "def load_log(name):\n", " p = LOGS / f\"{name}.json\"\n", " return json.load(open(p)) if p.exists() else None\n", "\n", "def get_fid(log, epoch):\n", " fid = log.get(\"history\", {}).get(\"fid\", {})\n", " return fid.get(str(epoch))\n", "\n", "def fid_series(log):\n", " fid = log.get(\"history\", {}).get(\"fid\", {})\n", " items = sorted((int(k), v) for k, v in fid.items())\n", " return [e for e, _ in items], [v for _, v in items]\n", "\n", "def show_image_or_missing(ax, path, title=None):\n", " if path.exists():\n", " ax.imshow(mpimg.imread(str(path)))\n", " else:\n", " ax.text(0.5, 0.5, f\"missing artifact\\n{path.name}\", ha=\"center\", va=\"center\", transform=ax.transAxes)\n", " if title:\n", " ax.set_title(title, fontsize=9)\n", " ax.axis(\"off\")\n", "\n", "\n", "\n", "FAMILIES = {\n", " \"GAN\": {\"p5\": \"p5_gan\", \"color\": \"#5B8DB8\", \"label\": \"WGAN-GP + SN + Attn\"},\n", " \"VAE\": {\"p5\": \"p5_vae\", \"color\": \"#E8B85A\", \"label\": \"VAE + Perceptual + PatchGAN\"},\n", " \"DDPM\": {\"p5\": \"p5_ddpm\", \"color\": \"#E8705A\", \"label\": \"DDPM cosine v-pred wider\"},\n", "}\n", "\n", "logs_p5 = {fam: load_log(info[\"p5\"]) for fam, info in FAMILIES.items()}\n" ] }, { "cell_type": "markdown", "id": "08c97828", "metadata": {}, "source": [ "## 1. Quantitative summary\n", "\n", "The table compares the saved best-of-family runs under the same Phase 5 setup. Lower FID is better; training time gives the speed side of the tradeoff." ] }, { "cell_type": "code", "execution_count": 2, "id": "02cf9434", "metadata": { "execution": { "iopub.execute_input": "2026-05-14T19:09:25.486018Z", "iopub.status.busy": "2026-05-14T19:09:25.485003Z", "iopub.status.idle": "2026-05-14T19:09:25.565282Z", "shell.execute_reply": "2026-05-14T19:09:25.565282Z" } }, "outputs": [ { "data": { "text/html": [ "\n", "
| \n", " | Family | \n", "Architecture | \n", "Resolution | \n", "Epochs | \n", "Best FID | \n", "Last FID | \n", "Train (min) | \n", "
|---|---|---|---|---|---|---|---|
| 2 | \n", "DDPM | \n", "DDPM cosine v-pred wider | \n", "64x64 | \n", "175 | \n", "19.0 | \n", "20.1 | \n", "667.1 | \n", "
| 0 | \n", "GAN | \n", "WGAN-GP + SN + Attn | \n", "64x64 | \n", "850 | \n", "22.0 | \n", "22.0 | \n", "316.9 | \n", "
| 1 | \n", "VAE | \n", "VAE + Perceptual + PatchGAN | \n", "64x64 | \n", "150 | \n", "46.2 | \n", "48.6 | \n", "50.2 | \n", "