Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix dependencies and license #332

Merged
merged 2 commits into from
Mar 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,16 +1,35 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"id": "99d4a6b2",
"metadata": {},
"outputs": [],
"source": [
"# Copyright (c) MONAI Consortium\n",
"# Licensed under the Apache License, Version 2.0 (the \"License\");\n",
"# you may not use this file except in compliance with the License.\n",
"# You may obtain a copy of the License at\n",
"# http://www.apache.org/licenses/LICENSE-2.0\n",
"# Unless required by applicable law or agreed to in writing, software\n",
"# distributed under the License is distributed on an \"AS IS\" BASIS,\n",
"# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n",
"# See the License for the specific language governing permissions and\n",
"# limitations under the License."
]
},
{
"cell_type": "markdown",
"id": "d6ae75bf",
"metadata": {},
"source": [
"# AutoencoderKL\n",
"\n",
"This demo is a toy example of how to use MONAI's AutoencoderKL. In particular, it uses\n",
"This demo is a toy example of how to use MONAI's `AutoencoderKL` class. In particular, it uses\n",
"the Autoencoder with a Kullback-Leibler regularisation as implemented by Rombach et. al [1].\n",
"\n",
"[1] Rombach et. al - [\"High-Resolution Image Synthesis with Latent Diffusion Models\"](https://arxiv.org/pdf/2112.10752.pdf)\n",
"[1] Rombach et. al \"High-Resolution Image Synthesis with Latent Diffusion Models\" https://arxiv.org/pdf/2112.10752.pdf\n",
"\n",
"\n",
"\n",
Expand Down Expand Up @@ -38,9 +57,8 @@
"metadata": {},
"outputs": [],
"source": [
"!pip install -q \"monai-weekly[tqdm]==1.1.dev2239\"\n",
"!pip install -q matplotlib\n",
"!pip install -q einops\n",
"!python -c \"import monai\" || pip install -q \"monai-weekly[tqdm]\"\n",
"!python -c \"import matplotlib\" || pip install -q matplotlib\n",
"%matplotlib inline"
]
},
Expand Down Expand Up @@ -236,7 +254,7 @@
" ]\n",
")\n",
"train_ds = Dataset(data=train_datalist, transform=train_transforms)\n",
"train_loader = DataLoader(train_ds, batch_size=64, shuffle=True, num_workers=4)"
"train_loader = DataLoader(train_ds, batch_size=64, shuffle=True, num_workers=4, persistent_workers=True)"
]
},
{
Expand Down Expand Up @@ -315,7 +333,7 @@
" ]\n",
")\n",
"val_ds = Dataset(data=val_datalist, transform=val_transforms)\n",
"val_loader = DataLoader(val_ds, batch_size=64, shuffle=True, num_workers=4)"
"val_loader = DataLoader(val_ds, batch_size=64, shuffle=True, num_workers=4, persistent_workers=True)"
]
},
{
Expand Down Expand Up @@ -794,7 +812,6 @@
"metadata": {},
"outputs": [],
"source": [
"# %%\n",
"l1_loss = L1Loss()\n",
"adv_loss = PatchAdversarialLoss(criterion=\"least_squares\")\n",
"adv_weight = 0.01\n",
Expand Down
27 changes: 19 additions & 8 deletions tutorials/generative/2d_autoencoderkl/2d_autoencoderkl_tutorial.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,22 @@
# +
# Copyright (c) MONAI Consortium
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# -

# # AutoencoderKL
#
# This demo is a toy example of how to use MONAI's AutoencoderKL. In particular, it uses
# This demo is a toy example of how to use MONAI's `AutoencoderKL` class. In particular, it uses
# the Autoencoder with a Kullback-Leibler regularisation as implemented by Rombach et. al [1].
#
# [1] Rombach et. al - ["High-Resolution Image Synthesis with Latent Diffusion Models"](https://arxiv.org/pdf/2112.10752.pdf)
# [1] Rombach et. al "High-Resolution Image Synthesis with Latent Diffusion Models" https://arxiv.org/pdf/2112.10752.pdf
#
#
#
Expand All @@ -18,9 +31,8 @@

# ## Set up environment using Colab

# !pip install -q "monai-weekly[tqdm]==1.1.dev2239"
# !pip install -q matplotlib
# !pip install -q einops
# !python -c "import monai" || pip install -q "monai-weekly[tqdm]"
# !python -c "import matplotlib" || pip install -q matplotlib
# %matplotlib inline

# ## Setup imports
Expand Down Expand Up @@ -83,7 +95,7 @@
]
)
train_ds = Dataset(data=train_datalist, transform=train_transforms)
train_loader = DataLoader(train_ds, batch_size=64, shuffle=True, num_workers=4)
train_loader = DataLoader(train_ds, batch_size=64, shuffle=True, num_workers=4, persistent_workers=True)

# ### Visualise examples from the training set

Expand All @@ -106,7 +118,7 @@
]
)
val_ds = Dataset(data=val_datalist, transform=val_transforms)
val_loader = DataLoader(val_ds, batch_size=64, shuffle=True, num_workers=4)
val_loader = DataLoader(val_ds, batch_size=64, shuffle=True, num_workers=4, persistent_workers=True)

# ## Define the network

Expand Down Expand Up @@ -144,7 +156,6 @@
optimizer_g = torch.optim.Adam(params=model.parameters(), lr=1e-4)
optimizer_d = torch.optim.Adam(params=discriminator.parameters(), lr=5e-4)

# %%
l1_loss = L1Loss()
adv_loss = PatchAdversarialLoss(criterion="least_squares")
adv_weight = 0.01
Expand Down
39 changes: 20 additions & 19 deletions tutorials/generative/2d_ddpm/2d_ddpm_compare_schedulers.ipynb
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"id": "6bbe8286",
"metadata": {},
"outputs": [],
"source": [
"# Copyright (c) MONAI Consortium\n",
"# Licensed under the Apache License, Version 2.0 (the \"License\");\n",
"# you may not use this file except in compliance with the License.\n",
"# You may obtain a copy of the License at\n",
"# http://www.apache.org/licenses/LICENSE-2.0\n",
"# Unless required by applicable law or agreed to in writing, software\n",
"# distributed under the License is distributed on an \"AS IS\" BASIS,\n",
"# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n",
"# See the License for the specific language governing permissions and\n",
"# limitations under the License."
]
},
{
"cell_type": "markdown",
"id": "d462dbf4",
Expand Down Expand Up @@ -27,7 +46,7 @@
"metadata": {},
"outputs": [],
"source": [
"!python -c \"import monai\" || pip install -q \"monai-weekly[pillow, tqdm, einops]\"\n",
"!python -c \"import monai\" || pip install -q \"monai-weekly[tqdm]\"\n",
"!python -c \"import matplotlib\" || pip install -q matplotlib\n",
"%matplotlib inline"
]
Expand Down Expand Up @@ -81,16 +100,6 @@
}
],
"source": [
"# Copyright 2020 MONAI Consortium\n",
"# Licensed under the Apache License, Version 2.0 (the \"License\");\n",
"# you may not use this file except in compliance with the License.\n",
"# You may obtain a copy of the License at\n",
"# http://www.apache.org/licenses/LICENSE-2.0\n",
"# Unless required by applicable law or agreed to in writing, software\n",
"# distributed under the License is distributed on an \"AS IS\" BASIS,\n",
"# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n",
"# See the License for the specific language governing permissions and\n",
"# limitations under the License.\n",
"import os\n",
"import shutil\n",
"import tempfile\n",
Expand Down Expand Up @@ -1064,14 +1073,6 @@
"if directory is None:\n",
" shutil.rmtree(root_dir)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "7e9e8df5-4127-44f3-bdeb-d8bf381d01a2",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand Down
26 changes: 13 additions & 13 deletions tutorials/generative/2d_ddpm/2d_ddpm_compare_schedulers.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,18 @@
# name: python3
# ---

# %%
# Copyright (c) MONAI Consortium
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# %% [markdown]
# # Denoising Diffusion Probabilistic Models with MedNIST Dataset
#
Expand All @@ -29,24 +41,14 @@
# ## Setup environment

# %%
# !python -c "import monai" || pip install -q "monai-weekly[pillow, tqdm, einops]"
# !python -c "import monai" || pip install -q "monai-weekly[tqdm]"
# !python -c "import matplotlib" || pip install -q matplotlib
# %matplotlib inline

# %% [markdown]
# ## Setup imports

# %%
# Copyright 2020 MONAI Consortium
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import os
import shutil
import tempfile
Expand Down Expand Up @@ -368,5 +370,3 @@
# %%
if directory is None:
shutil.rmtree(root_dir)

# %%
31 changes: 20 additions & 11 deletions tutorials/generative/2d_ddpm/2d_ddpm_inpainting.ipynb
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"id": "4c8ec6e8",
"metadata": {},
"outputs": [],
"source": [
"# Copyright (c) MONAI Consortium\n",
"# Licensed under the Apache License, Version 2.0 (the \"License\");\n",
"# you may not use this file except in compliance with the License.\n",
"# You may obtain a copy of the License at\n",
"# http://www.apache.org/licenses/LICENSE-2.0\n",
"# Unless required by applicable law or agreed to in writing, software\n",
"# distributed under the License is distributed on an \"AS IS\" BASIS,\n",
"# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n",
"# See the License for the specific language governing permissions and\n",
"# limitations under the License."
]
},
{
"cell_type": "markdown",
"id": "9d71306f",
Expand All @@ -24,7 +43,7 @@
"metadata": {},
"outputs": [],
"source": [
"!python -c \"import monai\" || pip install -q \"monai-weekly[pillow, tqdm, einops]\"\n",
"!python -c \"import monai\" || pip install -q \"monai-weekly[tqdm]\"\n",
"!python -c \"import matplotlib\" || pip install -q matplotlib\n",
"%matplotlib inline"
]
Expand Down Expand Up @@ -80,16 +99,6 @@
}
],
"source": [
"# Copyright 2020 MONAI Consortium\n",
"# Licensed under the Apache License, Version 2.0 (the \"License\");\n",
"# you may not use this file except in compliance with the License.\n",
"# You may obtain a copy of the License at\n",
"# http://www.apache.org/licenses/LICENSE-2.0\n",
"# Unless required by applicable law or agreed to in writing, software\n",
"# distributed under the License is distributed on an \"AS IS\" BASIS,\n",
"# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n",
"# See the License for the specific language governing permissions and\n",
"# limitations under the License.\n",
"import os\n",
"import shutil\n",
"import tempfile\n",
Expand Down
24 changes: 13 additions & 11 deletions tutorials/generative/2d_ddpm/2d_ddpm_inpainting.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,18 @@
# name: python3
# ---

# %%
# Copyright (c) MONAI Consortium
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# %% [markdown]
# # Inpainting with Denoising Diffusion Probabilistic Models
#
Expand All @@ -26,24 +38,14 @@
# ## Setup environment

# %%
# !python -c "import monai" || pip install -q "monai-weekly[pillow, tqdm, einops]"
# !python -c "import monai" || pip install -q "monai-weekly[tqdm]"
# !python -c "import matplotlib" || pip install -q matplotlib
# %matplotlib inline

# %% [markdown]
# ## Setup imports

# %% tags=[]
# Copyright 2020 MONAI Consortium
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import os
import shutil
import tempfile
Expand Down
Loading