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

Update bundle related notebook #1508

Merged
merged 2 commits into from
Sep 7, 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
45 changes: 27 additions & 18 deletions bundle/pythonic_usage_guidance/pythonic_bundle_access.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 4,
"metadata": {},
"outputs": [
{
Expand All @@ -159,18 +159,18 @@
"url None\n",
"remove_prefix monai_\n",
"progress True\n",
"2023-09-06 08:44:11,165 - INFO - --- input summary of monai.bundle.scripts.download ---\n",
"2023-09-06 08:44:11,167 - INFO - > name: 'spleen_ct_segmentation'\n",
"2023-09-06 08:44:11,167 - INFO - > bundle_dir: '/workspace/Data'\n",
"2023-09-06 08:44:11,167 - INFO - > source: 'github'\n",
"2023-09-06 08:44:11,167 - INFO - > remove_prefix: 'monai_'\n",
"2023-09-06 08:44:11,168 - INFO - > progress: True\n",
"2023-09-06 08:44:11,168 - INFO - ---\n",
"2023-09-07 12:19:11,083 - INFO - --- input summary of monai.bundle.scripts.download ---\n",
"2023-09-07 12:19:11,086 - INFO - > name: 'spleen_ct_segmentation'\n",
"2023-09-07 12:19:11,088 - INFO - > bundle_dir: '/workspace/Data'\n",
"2023-09-07 12:19:11,089 - INFO - > source: 'github'\n",
"2023-09-07 12:19:11,090 - INFO - > remove_prefix: 'monai_'\n",
"2023-09-07 12:19:11,091 - INFO - > progress: True\n",
"2023-09-07 12:19:11,092 - INFO - ---\n",
"\n",
"\n",
"2023-09-06 08:44:12,165 - INFO - Expected md5 is None, skip md5 check for file /workspace/Data/spleen_ct_segmentation_v0.5.3.zip.\n",
"2023-09-06 08:44:12,165 - INFO - File exists: /workspace/Data/spleen_ct_segmentation_v0.5.3.zip, skipped downloading.\n",
"2023-09-06 08:44:12,166 - INFO - Writing into directory: /workspace/Data.\n"
"2023-09-07 12:19:11,991 - INFO - Expected md5 is None, skip md5 check for file /workspace/Data/spleen_ct_segmentation_v0.5.3.zip.\n",
"2023-09-07 12:19:11,992 - INFO - File exists: /workspace/Data/spleen_ct_segmentation_v0.5.3.zip, skipped downloading.\n",
"2023-09-07 12:19:11,994 - INFO - Writing into directory: /workspace/Data.\n"
]
}
],
Expand Down Expand Up @@ -198,13 +198,13 @@
"workflow_name None\n",
"config_file /workspace/Data/spleen_ct_segmentation/configs/train.json\n",
"workflow_type train\n",
"2023-09-06 09:18:47,393 - INFO - --- input summary of monai.bundle.scripts.run ---\n",
"2023-09-06 09:18:47,395 - INFO - > config_file: '/workspace/Data/spleen_ct_segmentation/configs/train.json'\n",
"2023-09-06 09:18:47,396 - INFO - > workflow_type: 'train'\n",
"2023-09-06 09:18:47,397 - INFO - ---\n",
"2023-09-07 12:19:14,769 - INFO - --- input summary of monai.bundle.scripts.run ---\n",
"2023-09-07 12:19:14,772 - INFO - > config_file: '/workspace/Data/spleen_ct_segmentation/configs/train.json'\n",
"2023-09-07 12:19:14,775 - INFO - > workflow_type: 'train'\n",
"2023-09-07 12:19:14,776 - INFO - ---\n",
"\n",
"\n",
"2023-09-06 09:18:47,397 - INFO - Setting logging properties based on config: /workspace/Data/spleen_ct_segmentation/configs/logging.conf.\n"
"2023-09-07 12:19:14,778 - INFO - Setting logging properties based on config: /workspace/Data/spleen_ct_segmentation/configs/logging.conf.\n"
]
}
],
Expand Down Expand Up @@ -395,18 +395,27 @@
"metadata": {},
"outputs": [],
"source": [
"# Here we specify `return_state_dict=False` to return an instantiated model only for compatibility, will remove after MONAI v1.5.\n",
"# directly get an instantiated network that loaded the weights.\n",
"model = load(name=\"brats_mri_segmentation\", bundle_dir=root_dir, source=\"monaihosting\")\n",
"model = load(name=\"brats_mri_segmentation\", bundle_dir=root_dir, source=\"monaihosting\", return_state_dict=False)\n",
"\n",
"# directly update the parameters for the model from the bundle.\n",
"model = load(name=\"brats_mri_segmentation\", bundle_dir=root_dir, source=\"monaihosting\", in_channels=3, out_channels=1)\n",
"model = load(\n",
" name=\"brats_mri_segmentation\",\n",
" bundle_dir=root_dir,\n",
" source=\"monaihosting\",\n",
" in_channels=3,\n",
" out_channels=1,\n",
" return_state_dict=False,\n",
")\n",
"\n",
"# using `exclude_vars` to filter loading weights.\n",
"model = load(\n",
" name=\"brats_mri_segmentation\",\n",
" bundle_dir=root_dir,\n",
" source=\"monaihosting\",\n",
" copy_model_args={\"exclude_vars\": \"convInit|conv_final\"},\n",
" return_state_dict=False,\n",
")\n",
"\n",
"# pass model and return an instantiated network that loaded the weights.\n",
Expand Down
Loading