Skip to content

Commit

Permalink
fix import paths in example notebooks
Browse files Browse the repository at this point in the history
  • Loading branch information
ziw-liu committed Oct 9, 2024
1 parent 0e8ae5b commit 0f010dc
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 28 deletions.
36 changes: 29 additions & 7 deletions examples/virtual_staining/dlmbl_exercise/exercise.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 1,
"id": "68d4a6ef",
"metadata": {
"title": "Imports"
Expand All @@ -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",
Expand All @@ -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",
")"
]
},
{
Expand Down Expand Up @@ -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,
Expand Down
40 changes: 19 additions & 21 deletions examples/virtual_staining/dlmbl_exercise/solution.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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"
]
},
{
Expand Down Expand Up @@ -4541,7 +4539,7 @@
"main_language": "python"
},
"kernelspec": {
"display_name": "06_image_translation",
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
Expand All @@ -4555,7 +4553,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.14"
"version": "3.11.9"
}
},
"nbformat": 4,
Expand Down

0 comments on commit 0f010dc

Please sign in to comment.