Skip to content

Commit

Permalink
Fix issue with the plots for autoencoder tutorials. Add anomaly detec…
Browse files Browse the repository at this point in the history
…tion nbs to the README.

Signed-off-by: Virginia Fernandez <virginia.fernandez@kcl.ac.uk>
  • Loading branch information
Virginia Fernandez committed Sep 18, 2024
1 parent 524ef2f commit f9f329c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions generation/2d_autoencoderkl/2d_autoencoderkl_tutorial.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@
"from torch.nn import L1Loss\n",
"from monai.losses import PatchAdversarialLoss, PerceptualLoss\n",
"from monai.networks.nets import AutoencoderKL, PatchDiscriminator\n",
"from monai.utils.misc import ensure_tuple\n",
"\n",
"print_config()"
]
Expand Down Expand Up @@ -694,6 +695,7 @@
"# Plot every evaluation as a new line and example as columns\n",
"val_samples = np.linspace(val_interval, max_epochs, int(max_epochs / val_interval))\n",
"fig, ax = plt.subplots(nrows=len(val_samples), ncols=1, sharey=True)\n",
"ax = ensure_tuple(ax) \n",
"for image_n in range(len(val_samples)):\n",
" reconstructions = torch.reshape(intermediary_images[image_n], (64 * n_example_images, 64)).T\n",
" ax[image_n].imshow(reconstructions.cpu(), cmap=\"gray\")\n",
Expand Down
2 changes: 2 additions & 0 deletions generation/3d_autoencoderkl/3d_autoencoderkl_tutorial.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
"from torch.amp import autocast\n",
"from monai.networks.nets import AutoencoderKL, PatchDiscriminator\n",
"from monai.losses import PatchAdversarialLoss, PerceptualLoss\n",
"from monai.utils.misc import ensure_tuple\n",
"\n",
"print_config()"
]
Expand Down Expand Up @@ -731,6 +732,7 @@
],
"source": [
"fig, ax = plt.subplots(nrows=1, ncols=2)\n",
"ax = ensure_tuple(ax)\n",
"ax[0].imshow(images[0, channel, ..., images.shape[2] // 2].cpu(), vmin=0, vmax=1, cmap=\"gray\")\n",
"ax[0].axis(\"off\")\n",
"ax[0].title.set_text(\"Inputted Image\")\n",
Expand Down
4 changes: 4 additions & 0 deletions generation/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,7 @@ Example shows how to use a DDPM to inpaint of 2D images from the MedNIST dataset

## [Guiding the 2D diffusion synthesis using ControlNet](./controlnet/2d_controlnet.ipynb)
Example shows how to use ControlNet to condition a diffusion model trained on 2D brain MRI images on binary brain masks.

## Performing anomaly detection with diffusion models: [implicit guidance](./anomaly_detection/2d_classifierfree_guidance_anomalydetection_tutorial.ipynb), [using transformers](./anomaly_detection/anomaly_detection_with_transformers.ipynb) and [classifier free guidance](./anomaly_detection/anomalydetection_tutorial_classifier_guidance.ipynb)
Examples show how to perform anomaly detection in 2D, using implicit guidance [2D-classifier free guiance](./anomaly_detection/2d_classifierfree_guidance_anomalydetection_tutorial.ipynb), transformers [using transformers](./anomaly_detection/anomaly_detection_with_transformers.ipynb) and [classifier free guidance](./anomalydetection_tutorial_classifier_guidance).

0 comments on commit f9f329c

Please sign in to comment.