Skip to content
Merged
137 changes: 133 additions & 4 deletions nbs/adaptive_discriminator_augmentation_preset.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"execution": {
"iopub.execute_input": "2026-03-20T00:35:24.041970Z",
"iopub.status.busy": "2026-03-20T00:35:24.041834Z",
"iopub.status.idle": "2026-03-20T00:35:25.415061Z",
"shell.execute_reply": "2026-03-20T00:35:25.414513Z"
},
"id": "AM7V1IZiQzfG"
},
"outputs": [],
Expand All @@ -63,6 +69,12 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"execution": {
"iopub.execute_input": "2026-03-20T00:35:25.417753Z",
"iopub.status.busy": "2026-03-20T00:35:25.417425Z",
"iopub.status.idle": "2026-03-20T00:35:26.242382Z",
"shell.execute_reply": "2026-03-20T00:35:26.242029Z"
},
"id": "X16VOLFWQJs0"
},
"outputs": [],
Expand Down Expand Up @@ -111,6 +123,12 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"execution": {
"iopub.execute_input": "2026-03-20T00:35:26.244222Z",
"iopub.status.busy": "2026-03-20T00:35:26.244087Z",
"iopub.status.idle": "2026-03-20T00:35:27.342674Z",
"shell.execute_reply": "2026-03-20T00:35:27.342276Z"
},
"id": "ZHOopcuY7Lbr"
},
"outputs": [],
Expand All @@ -136,10 +154,31 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"execution": {
"iopub.execute_input": "2026-03-20T00:35:27.344703Z",
"iopub.status.busy": "2026-03-20T00:35:27.344489Z",
"iopub.status.idle": "2026-03-20T00:35:27.365959Z",
"shell.execute_reply": "2026-03-20T00:35:27.365555Z"
},
"id": "CRp0FV_z7Shh"
},
"outputs": [],
"source": "panda_image = kornia.image_to_tensor(np.array(Image.open(\"panda.jpg\").convert(\"RGB\"))).float() / 255.0 # C, H, W\npanda_images = panda_image.unsqueeze(0).repeat(8, 1, 1, 1) # 8, C, H, W\n\n\ndef plot_images(images_tensor, n_rows=4, figscale=1):\n \"\"\"utility function to plot expects a B, C, H, W tensor and plot them as a grid\"\"\"\n b, c, h, w = images_tensor.shape\n assert len(images_tensor) % n_rows == 0\n n_cols = len(images_tensor) // n_rows\n images_tensor = images_tensor.view(n_rows, n_cols, c, h, w).permute(2, 0, 3, 1, 4).reshape(c, h * n_rows, w * n_cols)\n plt.figure(figsize=(h // figscale, w // figscale))\n plt.imshow(kornia.tensor_to_image(images_tensor))\n plt.axis(\"off\")\n plt.show()"
"source": [
"panda_image = kornia.image_to_tensor(np.array(Image.open(\"panda.jpg\").convert(\"RGB\"))).float() / 255.0 # C, H, W\n",
"panda_images = panda_image.unsqueeze(0).repeat(8, 1, 1, 1) # 8, C, H, W\n",
"\n",
"\n",
"def plot_images(images_tensor, n_rows=4, figscale=1):\n",
" \"\"\"utility function to plot expects a B, C, H, W tensor and plot them as a grid\"\"\"\n",
" b, c, h, w = images_tensor.shape\n",
" assert len(images_tensor) % n_rows == 0\n",
" n_cols = len(images_tensor) // n_rows\n",
" images_tensor = images_tensor.view(n_rows, n_cols, c, h, w).permute(2, 0, 3, 1, 4).reshape(c, h * n_rows, w * n_cols)\n",
" plt.figure(figsize=(h // figscale, w // figscale))\n",
" plt.imshow(kornia.tensor_to_image(images_tensor))\n",
" plt.axis(\"off\")\n",
" plt.show()"
]
},
{
"cell_type": "code",
Expand All @@ -149,6 +188,12 @@
"base_uri": "https://localhost:8080/",
"height": 200
},
"execution": {
"iopub.execute_input": "2026-03-20T00:35:27.367861Z",
"iopub.status.busy": "2026-03-20T00:35:27.367731Z",
"iopub.status.idle": "2026-03-20T00:35:27.686390Z",
"shell.execute_reply": "2026-03-20T00:35:27.685767Z"
},
"id": "bfIU-mQFtUzW",
"outputId": "a65e6ed3-9aef-47b2-bd0a-bd756d656de3"
},
Expand Down Expand Up @@ -179,6 +224,12 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"execution": {
"iopub.execute_input": "2026-03-20T00:35:27.717817Z",
"iopub.status.busy": "2026-03-20T00:35:27.717639Z",
"iopub.status.idle": "2026-03-20T00:35:27.722181Z",
"shell.execute_reply": "2026-03-20T00:35:27.721876Z"
},
"id": "js_sWEDvRjWL"
},
"outputs": [],
Expand All @@ -194,6 +245,12 @@
"base_uri": "https://localhost:8080/",
"height": 398
},
"execution": {
"iopub.execute_input": "2026-03-20T00:35:27.723676Z",
"iopub.status.busy": "2026-03-20T00:35:27.723585Z",
"iopub.status.idle": "2026-03-20T00:35:28.358888Z",
"shell.execute_reply": "2026-03-20T00:35:28.358483Z"
},
"id": "ylqtkhXMTAH0",
"outputId": "db880256-9d30-4fc5-92b7-801436789c39"
},
Expand All @@ -208,6 +265,12 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"execution": {
"iopub.execute_input": "2026-03-20T00:35:28.369465Z",
"iopub.status.busy": "2026-03-20T00:35:28.369247Z",
"iopub.status.idle": "2026-03-20T00:35:28.372530Z",
"shell.execute_reply": "2026-03-20T00:35:28.372260Z"
},
"id": "3WdFmmi6fqKA"
},
"outputs": [],
Expand All @@ -229,6 +292,12 @@
"base_uri": "https://localhost:8080/",
"height": 381
},
"execution": {
"iopub.execute_input": "2026-03-20T00:35:28.373857Z",
"iopub.status.busy": "2026-03-20T00:35:28.373775Z",
"iopub.status.idle": "2026-03-20T00:35:28.739155Z",
"shell.execute_reply": "2026-03-20T00:35:28.738851Z"
},
"id": "_x8uvJnzvaax",
"outputId": "4e0805b3-1872-4930-b00d-5ebdb772cb91"
},
Expand Down Expand Up @@ -261,6 +330,12 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"execution": {
"iopub.execute_input": "2026-03-20T00:35:28.747056Z",
"iopub.status.busy": "2026-03-20T00:35:28.746872Z",
"iopub.status.idle": "2026-03-20T00:35:28.753805Z",
"shell.execute_reply": "2026-03-20T00:35:28.753507Z"
},
"id": "Q_uzg2nLge7l"
},
"outputs": [],
Expand Down Expand Up @@ -300,6 +375,12 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"execution": {
"iopub.execute_input": "2026-03-20T00:35:28.755104Z",
"iopub.status.busy": "2026-03-20T00:35:28.755020Z",
"iopub.status.idle": "2026-03-20T00:35:28.758024Z",
"shell.execute_reply": "2026-03-20T00:35:28.757790Z"
},
"id": "gu906vdhjtfl"
},
"outputs": [],
Expand Down Expand Up @@ -339,10 +420,25 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"execution": {
"iopub.execute_input": "2026-03-20T00:35:28.759353Z",
"iopub.status.busy": "2026-03-20T00:35:28.759271Z",
"iopub.status.idle": "2026-03-20T00:35:28.761440Z",
"shell.execute_reply": "2026-03-20T00:35:28.761164Z"
},
"id": "tq1g9FEAyAjH"
},
"outputs": [],
"source": "def create_batch(images_folder):\n images = []\n for image_file in os.listdir(images_folder):\n image = kornia.image_to_tensor(np.array(Image.open(os.path.join(images_folder, image_file)).convert(\"RGB\")))\n image = (image.float() / 127.5) - 1 # normalizing to be in (-1, 1) as the generator output\n images.append(image)\n batch = torch.stack(images, dim=0)\n return batch"
"source": [
"def create_batch(images_folder):\n",
" images = []\n",
" for image_file in os.listdir(images_folder):\n",
" image = kornia.image_to_tensor(np.array(Image.open(os.path.join(images_folder, image_file)).convert(\"RGB\")))\n",
" image = (image.float() / 127.5) - 1 # normalizing to be in (-1, 1) as the generator output\n",
" images.append(image)\n",
" batch = torch.stack(images, dim=0)\n",
" return batch"
]
},
{
"cell_type": "code",
Expand All @@ -351,6 +447,12 @@
"colab": {
"base_uri": "https://localhost:8080/"
},
"execution": {
"iopub.execute_input": "2026-03-20T00:35:28.762943Z",
"iopub.status.busy": "2026-03-20T00:35:28.762835Z",
"iopub.status.idle": "2026-03-20T00:35:29.502345Z",
"shell.execute_reply": "2026-03-20T00:35:29.502036Z"
},
"id": "8dGez6UhoUuK",
"outputId": "080b5600-5ccc-4393-99d0-45b34ecfdc79"
},
Expand Down Expand Up @@ -397,6 +499,12 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"execution": {
"iopub.execute_input": "2026-03-20T00:35:29.503887Z",
"iopub.status.busy": "2026-03-20T00:35:29.503712Z",
"iopub.status.idle": "2026-03-20T00:35:29.507204Z",
"shell.execute_reply": "2026-03-20T00:35:29.506966Z"
},
"id": "4ViQbI5LCdBS"
},
"outputs": [],
Expand Down Expand Up @@ -426,6 +534,12 @@
"colab": {
"base_uri": "https://localhost:8080/"
},
"execution": {
"iopub.execute_input": "2026-03-20T00:35:29.508751Z",
"iopub.status.busy": "2026-03-20T00:35:29.508598Z",
"iopub.status.idle": "2026-03-20T00:37:45.959164Z",
"shell.execute_reply": "2026-03-20T00:37:45.958698Z"
},
"id": "Luo-sw4yppKE",
"outputId": "da5e9412-8870-40ff-f9e3-4577a345da33"
},
Expand Down Expand Up @@ -501,6 +615,12 @@
"base_uri": "https://localhost:8080/",
"height": 693
},
"execution": {
"iopub.execute_input": "2026-03-20T00:37:45.961451Z",
"iopub.status.busy": "2026-03-20T00:37:45.961328Z",
"iopub.status.idle": "2026-03-20T00:37:46.034559Z",
"shell.execute_reply": "2026-03-20T00:37:46.034127Z"
},
"id": "TkkDHuhVEctz",
"outputId": "5639d89b-13a5-4825-98e2-16e3c4139e5a"
},
Expand Down Expand Up @@ -554,9 +674,18 @@
"name": "python3"
},
"language_info": {
"name": "python"
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.15"
}
},
"nbformat": 4,
"nbformat_minor": 0
}
}
64 changes: 32 additions & 32 deletions nbs/aliased_and_not_aliased_patch_extraction.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@
"execution_count": null,
"metadata": {
"execution": {
"iopub.execute_input": "2026-03-19T21:37:03.566822Z",
"iopub.status.busy": "2026-03-19T21:37:03.566357Z",
"iopub.status.idle": "2026-03-19T21:37:04.196898Z",
"shell.execute_reply": "2026-03-19T21:37:04.196535Z"
"iopub.execute_input": "2026-03-20T00:19:14.511078Z",
"iopub.status.busy": "2026-03-20T00:19:14.510851Z",
"iopub.status.idle": "2026-03-20T00:19:15.044569Z",
"shell.execute_reply": "2026-03-20T00:19:15.044155Z"
}
},
"outputs": [],
Expand Down Expand Up @@ -83,10 +83,10 @@
"execution_count": null,
"metadata": {
"execution": {
"iopub.execute_input": "2026-03-19T21:37:04.219178Z",
"iopub.status.busy": "2026-03-19T21:37:04.219010Z",
"iopub.status.idle": "2026-03-19T21:37:05.509416Z",
"shell.execute_reply": "2026-03-19T21:37:05.509107Z"
"iopub.execute_input": "2026-03-20T00:19:15.069687Z",
"iopub.status.busy": "2026-03-20T00:19:15.069514Z",
"iopub.status.idle": "2026-03-20T00:19:16.087411Z",
"shell.execute_reply": "2026-03-20T00:19:16.087085Z"
}
},
"outputs": [],
Expand All @@ -106,10 +106,10 @@
"execution_count": null,
"metadata": {
"execution": {
"iopub.execute_input": "2026-03-19T21:37:05.511569Z",
"iopub.status.busy": "2026-03-19T21:37:05.511367Z",
"iopub.status.idle": "2026-03-19T21:37:05.573370Z",
"shell.execute_reply": "2026-03-19T21:37:05.573027Z"
"iopub.execute_input": "2026-03-20T00:19:16.089097Z",
"iopub.status.busy": "2026-03-20T00:19:16.088943Z",
"iopub.status.idle": "2026-03-20T00:19:16.157385Z",
"shell.execute_reply": "2026-03-20T00:19:16.157031Z"
}
},
"outputs": [],
Expand All @@ -127,10 +127,10 @@
"execution_count": null,
"metadata": {
"execution": {
"iopub.execute_input": "2026-03-19T21:37:05.575009Z",
"iopub.status.busy": "2026-03-19T21:37:05.574898Z",
"iopub.status.idle": "2026-03-19T21:37:05.658175Z",
"shell.execute_reply": "2026-03-19T21:37:05.657895Z"
"iopub.execute_input": "2026-03-20T00:19:16.159174Z",
"iopub.status.busy": "2026-03-20T00:19:16.159044Z",
"iopub.status.idle": "2026-03-20T00:19:16.245571Z",
"shell.execute_reply": "2026-03-20T00:19:16.245288Z"
}
},
"outputs": [],
Expand All @@ -155,10 +155,10 @@
"execution_count": null,
"metadata": {
"execution": {
"iopub.execute_input": "2026-03-19T21:37:05.659631Z",
"iopub.status.busy": "2026-03-19T21:37:05.659520Z",
"iopub.status.idle": "2026-03-19T21:37:05.746269Z",
"shell.execute_reply": "2026-03-19T21:37:05.745932Z"
"iopub.execute_input": "2026-03-20T00:19:16.247101Z",
"iopub.status.busy": "2026-03-20T00:19:16.246985Z",
"iopub.status.idle": "2026-03-20T00:19:16.332104Z",
"shell.execute_reply": "2026-03-20T00:19:16.331845Z"
}
},
"outputs": [],
Expand Down Expand Up @@ -194,10 +194,10 @@
"execution_count": null,
"metadata": {
"execution": {
"iopub.execute_input": "2026-03-19T21:37:05.748034Z",
"iopub.status.busy": "2026-03-19T21:37:05.747912Z",
"iopub.status.idle": "2026-03-19T21:37:05.763255Z",
"shell.execute_reply": "2026-03-19T21:37:05.762907Z"
"iopub.execute_input": "2026-03-20T00:19:16.333584Z",
"iopub.status.busy": "2026-03-20T00:19:16.333480Z",
"iopub.status.idle": "2026-03-20T00:19:16.349135Z",
"shell.execute_reply": "2026-03-20T00:19:16.348801Z"
}
},
"outputs": [],
Expand Down Expand Up @@ -244,10 +244,10 @@
"execution_count": null,
"metadata": {
"execution": {
"iopub.execute_input": "2026-03-19T21:37:05.765237Z",
"iopub.status.busy": "2026-03-19T21:37:05.765084Z",
"iopub.status.idle": "2026-03-19T21:37:05.833477Z",
"shell.execute_reply": "2026-03-19T21:37:05.832925Z"
"iopub.execute_input": "2026-03-20T00:19:16.350769Z",
"iopub.status.busy": "2026-03-20T00:19:16.350659Z",
"iopub.status.idle": "2026-03-20T00:19:16.418756Z",
"shell.execute_reply": "2026-03-20T00:19:16.418248Z"
}
},
"outputs": [],
Expand All @@ -268,10 +268,10 @@
"execution_count": null,
"metadata": {
"execution": {
"iopub.execute_input": "2026-03-19T21:37:05.835763Z",
"iopub.status.busy": "2026-03-19T21:37:05.835593Z",
"iopub.status.idle": "2026-03-19T21:37:05.855579Z",
"shell.execute_reply": "2026-03-19T21:37:05.855224Z"
"iopub.execute_input": "2026-03-20T00:19:16.421014Z",
"iopub.status.busy": "2026-03-20T00:19:16.420857Z",
"iopub.status.idle": "2026-03-20T00:19:16.444108Z",
"shell.execute_reply": "2026-03-20T00:19:16.443661Z"
}
},
"outputs": [],
Expand Down
Loading
Loading