From 0f010dc3ab99bae7d06841ecbb8419da80723808 Mon Sep 17 00:00:00 2001 From: Ziwen Liu Date: Wed, 9 Oct 2024 15:00:53 -0700 Subject: [PATCH] fix import paths in example notebooks --- .../dlmbl_exercise/exercise.ipynb | 36 +++++++++++++---- .../dlmbl_exercise/solution.ipynb | 40 +++++++++---------- 2 files changed, 48 insertions(+), 28 deletions(-) diff --git a/examples/virtual_staining/dlmbl_exercise/exercise.ipynb b/examples/virtual_staining/dlmbl_exercise/exercise.ipynb index 7e5fadff..2dcf49d8 100644 --- a/examples/virtual_staining/dlmbl_exercise/exercise.ipynb +++ b/examples/virtual_staining/dlmbl_exercise/exercise.ipynb @@ -122,7 +122,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 1, "id": "68d4a6ef", "metadata": { "title": "Imports" @@ -148,6 +148,7 @@ "from natsort import natsorted\n", "from numpy.typing import ArrayLike\n", "from skimage import metrics # for metrics.\n", + "\n", "# pytorch lightning wrapper for Tensorboard.\n", "from skimage.color import label2rgb\n", "from torch.utils.tensorboard import SummaryWriter # for logging to tensorboard\n", @@ -156,15 +157,22 @@ "\n", "# HCSDataModule makes it easy to load data during training.\n", "from viscy.data.hcs import HCSDataModule\n", - "from viscy.evaluation.evaluation_metrics import mean_average_precision\n", + "from viscy.translation.evaluation_metrics import mean_average_precision\n", + "\n", "# Trainer class and UNet.\n", "from viscy.translation.engine import MixedLoss, VSUNet\n", "from viscy.translation.trainer import VSTrainer\n", + "\n", "# training augmentations\n", - "from viscy.transforms import (NormalizeSampled, RandAdjustContrastd,\n", - " RandAffined, RandGaussianNoised,\n", - " RandGaussianSmoothd, RandScaleIntensityd,\n", - " RandWeightedCropd)" + "from viscy.transforms import (\n", + " NormalizeSampled,\n", + " RandAdjustContrastd,\n", + " RandAffined,\n", + " RandGaussianNoised,\n", + " RandGaussianSmoothd,\n", + " RandScaleIntensityd,\n", + " RandWeightedCropd,\n", + ")" ] }, { @@ -2352,8 +2360,22 @@ "cell_metadata_filter": "all", "main_language": "python" }, + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "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.11.9" } }, "nbformat": 4, diff --git a/examples/virtual_staining/dlmbl_exercise/solution.ipynb b/examples/virtual_staining/dlmbl_exercise/solution.ipynb index c0c18c06..c3f853b6 100644 --- a/examples/virtual_staining/dlmbl_exercise/solution.ipynb +++ b/examples/virtual_staining/dlmbl_exercise/solution.ipynb @@ -122,21 +122,12 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": 2, "id": "68d4a6ef", "metadata": { "title": "Imports" }, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "/hpc/mydata/eduardo.hirata/.conda/envs/06_image_translation/lib/python3.10/site-packages/viscy/light/engine.py:107: FutureWarning: `torch.cuda.amp.custom_fwd(args...)` is deprecated. Please use `torch.amp.custom_fwd(args..., device_type='cuda')` instead.\n", - " @torch.cuda.amp.custom_fwd(cast_inputs=torch.float32)\n" - ] - } - ], + "outputs": [], "source": [ "import os\n", "from glob import glob\n", @@ -157,23 +148,30 @@ "from natsort import natsorted\n", "from numpy.typing import ArrayLike\n", "from skimage import metrics # for metrics.\n", + "\n", "# pytorch lightning wrapper for Tensorboard.\n", - "from skimage.color import label2rgb\n", "from torch.utils.tensorboard import SummaryWriter # for logging to tensorboard\n", "from torchmetrics.functional import accuracy, dice, jaccard_index\n", "from tqdm import tqdm\n", "\n", "# HCSDataModule makes it easy to load data during training.\n", "from viscy.data.hcs import HCSDataModule\n", - "from viscy.evaluation.evaluation_metrics import mean_average_precision\n", + "\n", + "# training augmentations\n", + "from viscy.transforms import (\n", + " NormalizeSampled,\n", + " RandAdjustContrastd,\n", + " RandAffined,\n", + " RandGaussianNoised,\n", + " RandGaussianSmoothd,\n", + " RandScaleIntensityd,\n", + " RandWeightedCropd,\n", + ")\n", + "\n", "# Trainer class and UNet.\n", "from viscy.translation.engine import MixedLoss, VSUNet\n", - "from viscy.translation.trainer import VSTrainer\n", - "# training augmentations\n", - "from viscy.transforms import (NormalizeSampled, RandAdjustContrastd,\n", - " RandAffined, RandGaussianNoised,\n", - " RandGaussianSmoothd, RandScaleIntensityd,\n", - " RandWeightedCropd)" + "from viscy.translation.evaluation_metrics import mean_average_precision\n", + "from viscy.translation.trainer import VSTrainer" ] }, { @@ -4541,7 +4539,7 @@ "main_language": "python" }, "kernelspec": { - "display_name": "06_image_translation", + "display_name": "Python 3", "language": "python", "name": "python3" }, @@ -4555,7 +4553,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.14" + "version": "3.11.9" } }, "nbformat": 4,