Skip to content

Commit

Permalink
update bundle related notebook
Browse files Browse the repository at this point in the history
Signed-off-by: KumoLiu <[email protected]>
  • Loading branch information
KumoLiu committed Sep 7, 2023
1 parent 799f40b commit b442f83
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 46 deletions.
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

0 comments on commit b442f83

Please sign in to comment.