Skip to content

Commit

Permalink
Revert "notebooks 00-quickstart and 02-eigendistortions line-length c…
Browse files Browse the repository at this point in the history
…orrection"

This reverts commit 4bb4333.
  • Loading branch information
hmd101 committed Aug 8, 2024
1 parent 4bb4333 commit 7786cad
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 148 deletions.
68 changes: 22 additions & 46 deletions examples/00_quickstart.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -95,18 +95,15 @@
" def __init__(self, kernel_size=(7, 7)):\n",
" super().__init__()\n",
" self.kernel_size = kernel_size\n",
" self.conv = torch.nn.Conv2d(\n",
" 1, 1, kernel_size=kernel_size, padding=(0, 0), bias=False\n",
" )\n",
" self.conv.weight.data[0, 0] = circular_gaussian2d(kernel_size, 3.0)\n",
"\n",
" self.conv = torch.nn.Conv2d(1, 1, kernel_size=kernel_size, padding=(0, 0), bias=False)\n",
" self.conv.weight.data[0, 0] = circular_gaussian2d(kernel_size, 3.)\n",
" \n",
" # the forward pass of the model defines how to get from an image to the representation\n",
" def forward(self, x):\n",
" # use circular padding so our output is the same size as our input\n",
" x = po.tools.conv.same_padding(x, self.kernel_size, pad_mode=\"circular\")\n",
" x = po.tools.conv.same_padding(x, self.kernel_size, pad_mode='circular')\n",
" return self.conv(x)\n",
"\n",
"\n",
"model = SimpleModel()\n",
"rep = model(im)"
]
Expand Down Expand Up @@ -165,7 +162,7 @@
}
],
"source": [
"fig = po.imshow(torch.cat([im, rep]), title=[\"Original image\", \"Model output\"])"
"fig = po.imshow(torch.cat([im, rep]), title=['Original image', 'Model output'])"
]
},
{
Expand Down Expand Up @@ -314,17 +311,10 @@
}
],
"source": [
"fig = po.imshow(\n",
" [im, rep, metamer.metamer, model(metamer.metamer)],\n",
" col_wrap=2,\n",
" vrange=\"auto1\",\n",
" title=[\n",
" \"Original image\",\n",
" \"Model representation\\nof original image\",\n",
" \"Synthesized metamer\",\n",
" \"Model representation\\nof synthesized metamer\",\n",
" ],\n",
")"
"fig = po.imshow([im, rep, metamer.metamer, model(metamer.metamer)], \n",
" col_wrap=2, vrange='auto1',\n",
" title=['Original image', 'Model representation\\nof original image',\n",
" 'Synthesized metamer', 'Model representation\\nof synthesized metamer']);"
]
},
{
Expand Down Expand Up @@ -4239,9 +4229,7 @@
}
],
"source": [
"po.synth.metamer.animate(\n",
" metamer, included_plots=[\"display_metamer\", \"plot_loss\"], figsize=(12, 5)\n",
")"
"po.synth.metamer.animate(metamer, included_plots=['display_metamer', 'plot_loss'], figsize=(12, 5))"
]
},
{
Expand Down Expand Up @@ -4269,7 +4257,7 @@
],
"source": [
"curie = po.data.curie()\n",
"po.imshow([curie])"
"po.imshow([curie]);"
]
},
{
Expand Down Expand Up @@ -4309,16 +4297,12 @@
}
],
"source": [
"metamer = po.synthesize.Metamer(\n",
" im,\n",
" model,\n",
" initial_image=curie,\n",
")\n",
"metamer = po.synthesize.Metamer(im, model, initial_image=curie, )\n",
"\n",
"# we increase the length of time we run synthesis and decrease the\n",
"# stop_criterion, which determines when we think loss has converged\n",
"# for stopping synthesis early.\n",
"synth_image = metamer.synthesize(max_iter=500, stop_criterion=1e-6)"
"synth_image = metamer.synthesize(max_iter=500, stop_criterion=1e-6)"
]
},
{
Expand Down Expand Up @@ -4382,17 +4366,10 @@
}
],
"source": [
"fig = po.imshow(\n",
" [im, rep, metamer.metamer, model(metamer.metamer)],\n",
" col_wrap=2,\n",
" vrange=\"auto1\",\n",
" title=[\n",
" \"Original image\",\n",
" \"Model representation\\nof original image\",\n",
" \"Synthesized metamer\",\n",
" \"Model representation\\nof synthesized metamer\",\n",
" ],\n",
")"
"fig = po.imshow([im, rep, metamer.metamer, model(metamer.metamer)], \n",
" col_wrap=2, vrange='auto1',\n",
" title=['Original image', 'Model representation\\nof original image',\n",
" 'Synthesized metamer', 'Model representation\\nof synthesized metamer']);"
]
},
{
Expand Down Expand Up @@ -4450,7 +4427,7 @@
],
"source": [
"eig = po.synthesize.Eigendistortion(im, model)\n",
"eig.synthesize()"
"eig.synthesize();"
]
},
{
Expand All @@ -4477,9 +4454,8 @@
}
],
"source": [
"po.imshow(\n",
" eig.eigendistortions, title=[\"Maximum eigendistortion\", \"Minimum eigendistortion\"]\n",
")"
"po.imshow(eig.eigendistortions, title=['Maximum eigendistortion', \n",
" 'Minimum eigendistortion']);"
]
},
{
Expand All @@ -4496,7 +4472,7 @@
"kernelspec": {
"display_name": "plenoptic",
"language": "python",
"name": "python3"
"name": "plenoptic"
},
"language_info": {
"codemirror_mode": {
Expand All @@ -4508,7 +4484,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.10"
"version": "3.10.13"
}
},
"nbformat": 4,
Expand Down
Loading

0 comments on commit 7786cad

Please sign in to comment.