Skip to content

Commit

Permalink
[DLMED] update rotate angle (Project-MONAI#57)
Browse files Browse the repository at this point in the history
Signed-off-by: Nic Ma <nma@nvidia.com>
  • Loading branch information
Nic-Ma authored Nov 5, 2020
1 parent 1f9f8e0 commit bb5bc27
Show file tree
Hide file tree
Showing 11 changed files with 85 additions and 19 deletions.
32 changes: 29 additions & 3 deletions 2d_classification/mednist_tutorial.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,32 @@
"## Setup environment"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"%pip install -q \"monai[pillow, tqdm]\""
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# FIXME: install MONAI from source code, will remove it when v0.4.0 released\n",
"pip install git+https://github.com/Project-MONAI/MONAI#egg=MONAI"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Setup environment"
]
},
{
"cell_type": "code",
"execution_count": 2,
Expand Down Expand Up @@ -99,7 +125,7 @@
"import numpy as np\n",
"import PIL\n",
"import torch\n",
"\n",
"import numpy as np\n",
"from monai.apps import download_and_extract\n",
"from monai.config import print_config\n",
"from monai.metrics import compute_roc_auc\n",
Expand Down Expand Up @@ -358,7 +384,7 @@
" LoadPNG(image_only=True),\n",
" AddChannel(),\n",
" ScaleIntensity(),\n",
" RandRotate(range_x=15, prob=0.5, keep_size=True),\n",
" RandRotate(range_x=np.pi / 12, prob=0.5, keep_size=True),\n",
" RandFlip(spatial_axis=0, prob=0.5),\n",
" RandZoom(min_zoom=0.9, max_zoom=1.1, prob=0.5),\n",
" ToTensor(),\n",
Expand Down Expand Up @@ -757,7 +783,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.3"
"version": "3.6.10"
}
},
"nbformat": 4,
Expand Down
2 changes: 1 addition & 1 deletion acceleration/automatic_mixed_precision.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
}
],
"source": [
"%pip install -q \"monai[gdown, nibabel, tqdm]\""
"%pip install -q \"monai[nibabel, tqdm]\""
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion acceleration/dataset_type_performance.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
},
"outputs": [],
"source": [
"%pip install -q \"monai[gdown, nibabel, tqdm]\""
"%pip install -q \"monai[nibabel, tqdm]\""
]
},
{
Expand Down
14 changes: 12 additions & 2 deletions acceleration/transform_speed.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,16 @@
"%pip install -q \"monai[nibabel]\""
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# FIXME: install MONAI from source code, will remove it when v0.4.0 released\n",
"pip install git+https://github.com/Project-MONAI/MONAI#egg=MONAI"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down Expand Up @@ -273,7 +283,7 @@
" LoadNifti(image_only=True),\n",
" ScaleIntensity(),\n",
" AddChannel(),\n",
" Rotate(angle=45.0),\n",
" Rotate(angle=np.pi / 4),\n",
" RandSpatialCrop((64, 64, 64), random_size=False),\n",
" ToTensor(),\n",
" ]\n",
Expand All @@ -283,7 +293,7 @@
" [\n",
" LoadNifti(image_only=True),\n",
" AddChannel(),\n",
" Rotate(angle=45.0),\n",
" Rotate(angle=np.pi / 4),\n",
" RandSpatialCrop((64, 64, 64), random_size=False),\n",
" ToTensor(),\n",
" ]\n",
Expand Down
2 changes: 1 addition & 1 deletion modules/3d_image_transforms.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
}
],
"source": [
"%pip install -q \"monai[gdown, nibabel]\""
"%pip install -q \"monai[nibabel]\""
]
},
{
Expand Down
4 changes: 2 additions & 2 deletions modules/autoencoder_mednist.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@
" LoadPNGD(keys=[\"im\"]),\n",
" AddChannelD(keys=[\"im\"]),\n",
" ScaleIntensityD(keys=[\"im\"]),\n",
" RandRotateD(keys=[\"im\"], range_x=15, prob=0.5, keep_size=True),\n",
" RandRotateD(keys=[\"im\"], range_x=np.pi / 12, prob=0.5, keep_size=True),\n",
" RandFlipD(keys=[\"im\"], spatial_axis=0, prob=0.5),\n",
" RandZoomD(keys=[\"im\"], min_zoom=0.9, max_zoom=1.1, prob=0.5),\n",
" ToTensorD(keys=[\"im\"]),\n",
Expand Down Expand Up @@ -521,7 +521,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.3"
"version": "3.6.10"
}
},
"nbformat": 4,
Expand Down
4 changes: 2 additions & 2 deletions modules/engines/gan_training.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import sys

import torch

import numpy as np
import monai
from monai.apps.utils import download_and_extract
from monai.data import CacheDataset, DataLoader, png_writer
Expand Down Expand Up @@ -69,7 +69,7 @@ def main():
LoadPNGD(keys=["hand"]),
AddChannelD(keys=["hand"]),
ScaleIntensityD(keys=["hand"]),
RandRotateD(keys=["hand"], range_x=15, prob=0.5, keep_size=True),
RandRotateD(keys=["hand"], range_x=np.pi / 12, prob=0.5, keep_size=True),
RandFlipD(keys=["hand"], spatial_axis=0, prob=0.5),
RandZoomD(keys=["hand"], min_zoom=0.9, max_zoom=1.1, prob=0.5),
ToTensorD(keys=["hand"]),
Expand Down
2 changes: 1 addition & 1 deletion modules/integrate_3rd_party_transforms.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
}
],
"source": [
"%pip install -q \"monai[gdown]\""
"%pip install -q \"monai[nibabel]\""
]
},
{
Expand Down
14 changes: 12 additions & 2 deletions modules/mednist_GAN_tutorial.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,16 @@
"%pip install -q monai"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# FIXME: install MONAI from source code, will remove it when v0.4.0 released\n",
"pip install git+https://github.com/Project-MONAI/MONAI#egg=MONAI"
]
},
{
"cell_type": "code",
"execution_count": 2,
Expand Down Expand Up @@ -117,7 +127,7 @@
"\n",
"import matplotlib.pyplot as plt\n",
"import torch\n",
"\n",
"import numpy as np\n",
"from monai.config import print_config\n",
"from monai.data import CacheDataset\n",
"from monai.networks import normal_init\n",
Expand Down Expand Up @@ -242,7 +252,7 @@
" LoadTarJpeg(),\n",
" AddChannel(),\n",
" ScaleIntensity(),\n",
" RandRotate(range_x=15, prob=0.5, keep_size=True),\n",
" RandRotate(range_x=np.pi / 12, prob=0.5, keep_size=True),\n",
" RandFlip(spatial_axis=0, prob=0.5),\n",
" RandZoom(min_zoom=0.9, max_zoom=1.1, prob=0.5),\n",
" ToTensor(),\n",
Expand Down
14 changes: 12 additions & 2 deletions modules/mednist_GAN_workflow_array.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,16 @@
"%pip install -q \"monai[ignite, tqdm]\""
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# FIXME: install MONAI from source code, will remove it when v0.4.0 released\n",
"pip install git+https://github.com/Project-MONAI/MONAI#egg=MONAI"
]
},
{
"cell_type": "code",
"execution_count": 3,
Expand Down Expand Up @@ -127,7 +137,7 @@
"\n",
"import matplotlib.pyplot as plt\n",
"import torch\n",
"\n",
"import numpy as np\n",
"import monai\n",
"print(monai.__file__)\n",
"\n",
Expand Down Expand Up @@ -285,7 +295,7 @@
" LoadTarJpeg(),\n",
" AddChannel(),\n",
" ScaleIntensity(),\n",
" RandRotate(range_x=15, prob=0.5, keep_size=True),\n",
" RandRotate(range_x=np.pi / 12, prob=0.5, keep_size=True),\n",
" RandFlip(spatial_axis=0, prob=0.5),\n",
" RandZoom(min_zoom=0.9, max_zoom=1.1, prob=0.5),\n",
" ToTensor(),\n",
Expand Down
14 changes: 12 additions & 2 deletions modules/mednist_GAN_workflow_dict.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,16 @@
"%pip install -q \"monai[ignite, tqdm]\""
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# FIXME: install MONAI from source code, will remove it when v0.4.0 released\n",
"pip install git+https://github.com/Project-MONAI/MONAI#egg=MONAI"
]
},
{
"cell_type": "code",
"execution_count": 3,
Expand Down Expand Up @@ -119,7 +129,7 @@
"\n",
"import matplotlib.pyplot as plt\n",
"import torch\n",
"\n",
"import numpy as np\n",
"from monai.apps import download_and_extract\n",
"from monai.config import print_config\n",
"from monai.data import CacheDataset, DataLoader\n",
Expand Down Expand Up @@ -281,7 +291,7 @@
" LoadPNGD(keys=[\"hand\"]),\n",
" AddChannelD(keys=[\"hand\"]),\n",
" ScaleIntensityD(keys=[\"hand\"]),\n",
" RandRotateD(keys=[\"hand\"], range_x=15, prob=0.5, keep_size=True),\n",
" RandRotateD(keys=[\"hand\"], range_x=np.pi / 12, prob=0.5, keep_size=True),\n",
" RandFlipD(keys=[\"hand\"], spatial_axis=0, prob=0.5),\n",
" RandZoomD(keys=[\"hand\"], min_zoom=0.9, max_zoom=1.1, prob=0.5),\n",
" ToTensorD(keys=[\"hand\"]),\n",
Expand Down

0 comments on commit bb5bc27

Please sign in to comment.