From d7978130459ac65e9dda54eccbefd4515e39603c Mon Sep 17 00:00:00 2001 From: YunLiu <55491388+KumoLiu@users.noreply.github.com> Date: Wed, 18 Sep 2024 16:38:13 +0800 Subject: [PATCH] make notebooks under bundle runable Signed-off-by: YunLiu <55491388+KumoLiu@users.noreply.github.com> --- bundle/01_bundle_intro.ipynb | 303 +++++++++++------ bundle/02_mednist_classification.ipynb | 168 ++++++---- bundle/03_mednist_classification_v2.ipynb | 306 ++++++++++-------- bundle/04_integrating_code.ipynb | 211 ++++++++---- bundle/05_spleen_segmentation_lightning.ipynb | 258 +++++++-------- runner.sh | 4 - 6 files changed, 761 insertions(+), 489 deletions(-) diff --git a/bundle/01_bundle_intro.ipynb b/bundle/01_bundle_intro.ipynb index 976e61e71e..c6fb68880a 100644 --- a/bundle/01_bundle_intro.ipynb +++ b/bundle/01_bundle_intro.ipynb @@ -27,7 +27,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 1, "id": "1bf88e03-1c87-4901-9cfb-9c626d454b98", "metadata": {}, "outputs": [], @@ -45,10 +45,55 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 2, "id": "280efd0a-74dd-41c7-8a2b-0de382dc0657", "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/usr/local/lib/python3.10/dist-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n", + " from .autonotebook import tqdm as notebook_tqdm\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "MONAI version: 1.4.0rc8+1.gab3ee18ba\n", + "Numpy version: 1.24.4\n", + "Pytorch version: 2.5.0a0+872d972e41.nv24.08\n", + "MONAI flags: HAS_EXT = False, USE_COMPILED = False, USE_META_DICT = False\n", + "MONAI rev id: ab3ee18ba32bb9bd67cd3a55717684bbd343c94c\n", + "MONAI __file__: /workspace/Code/MONAI/monai/__init__.py\n", + "\n", + "Optional dependencies:\n", + "Pytorch Ignite version: 0.4.11\n", + "ITK version: 5.4.0\n", + "Nibabel version: 5.2.1\n", + "scikit-image version: 0.23.2\n", + "scipy version: 1.14.0\n", + "Pillow version: 10.4.0\n", + "Tensorboard version: 2.16.2\n", + "gdown version: 5.2.0\n", + "TorchVision version: 0.20.0a0\n", + "tqdm version: 4.66.5\n", + "lmdb version: 1.5.1\n", + "psutil version: 6.0.0\n", + "pandas version: 2.2.2\n", + "einops version: 0.8.0\n", + "transformers version: 4.40.2\n", + "mlflow version: 2.16.0\n", + "pynrrd version: 1.0.0\n", + "clearml version: 1.16.4\n", + "\n", + "For details about installing the optional dependencies, please visit:\n", + " https://docs.monai.io/en/latest/installation.html#installing-the-recommended-dependencies\n", + "\n" + ] + } + ], "source": [ "from monai.config import print_config\n", "\n", @@ -101,7 +146,7 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": 3, "id": "a1d9d107-58d6-4ed8-9cf1-6e9103e78a92", "metadata": {}, "outputs": [ @@ -140,7 +185,7 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 4, "id": "3e19c030-4e03-4a96-a127-ee0daa604052", "metadata": {}, "outputs": [ @@ -153,10 +198,10 @@ " \"changelog\": {\n", " \"0.0.1\": \"Initial version\"\n", " },\n", - " \"monai_version\": \"1.2.0\",\n", - " \"pytorch_version\": \"2.0.0\",\n", - " \"numpy_version\": \"1.23.5\",\n", - " \"optional_packages_version\": {},\n", + " \"monai_version\": \"1.4.0rc8+1.gab3ee18ba\",\n", + " \"pytorch_version\": \"2.5.0\",\n", + " \"numpy_version\": \"1.24.4\",\n", + " \"required_packages_version\": {},\n", " \"task\": \"Describe what the network predicts\",\n", " \"description\": \"A longer description of what the network does, use context, inputs, outputs, etc.\",\n", " \"authors\": \"Your Name Here\",\n", @@ -183,7 +228,7 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 5, "id": "a56e4833-171c-432c-8145-f325fad3bfcb", "metadata": {}, "outputs": [ @@ -206,7 +251,7 @@ " \"monai_version\": \"1.2.0\",\n", " \"pytorch_version\": \"2.0.0\",\n", " \"numpy_version\": \"1.23.5\",\n", - " \"optional_packages_version\": {},\n", + " \"required_packages_version\": {},\n", " \"name\": \"TestBundle\",\n", " \"task\": \"Demonstration Bundle Network\",\n", " \"description\": \"This is a demonstration bundle meant to showcase features of the MONAI bundle system only and does nothing useful\",\n", @@ -238,7 +283,7 @@ }, { "cell_type": "code", - "execution_count": 32, + "execution_count": 6, "id": "63322909-1a24-426e-a744-39452cdff14f", "metadata": {}, "outputs": [ @@ -288,7 +333,7 @@ }, { "cell_type": "code", - "execution_count": 33, + "execution_count": 7, "id": "7968ceb4-89ef-40a9-ac9b-f048c6cca73b", "metadata": {}, "outputs": [ @@ -296,11 +341,11 @@ "name": "stdout", "output_type": "stream", "text": [ - "2023-07-14 15:34:52,646 - INFO - --- input summary of monai.bundle.scripts.run ---\n", - "2023-07-14 15:34:52,647 - INFO - > run_id: 'test_config'\n", - "2023-07-14 15:34:52,647 - INFO - > meta_file: './TestBundle/configs/metadata.json'\n", - "2023-07-14 15:34:52,647 - INFO - > config_file: './TestBundle/configs/test_config.yaml'\n", - "2023-07-14 15:34:52,647 - INFO - ---\n", + "2024-09-18 08:15:12,299 - INFO - --- input summary of monai.bundle.scripts.run ---\n", + "2024-09-18 08:15:12,299 - INFO - > config_file: './TestBundle/configs/test_config.yaml'\n", + "2024-09-18 08:15:12,299 - INFO - > meta_file: './TestBundle/configs/metadata.json'\n", + "2024-09-18 08:15:12,299 - INFO - > run_id: 'test_config'\n", + "2024-09-18 08:15:12,299 - INFO - ---\n", "\n", "\n" ] @@ -309,46 +354,49 @@ "name": "stderr", "output_type": "stream", "text": [ - "/home/localek10/workspace/monai/MONAI_mine/monai/bundle/workflows.py:213: UserWarning: Default logging file in 'configs/logging.conf' does not exist, skipping logging.\n", - " warnings.warn(\"Default logging file in 'configs/logging.conf' does not exist, skipping logging.\")\n" + "WARNING:py.warnings:The 'warn' method is deprecated, use 'warning' instead\n", + "\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ - "MONAI version: 1.2.0\n", - "Numpy version: 1.23.5\n", - "Pytorch version: 2.0.0\n", + "2024-09-18 08:15:12,301 - WARNING - Default logging file in TestBundle/configs/logging.conf does not exist, skipping logging.\n", + "MONAI version: 1.4.0rc8+1.gab3ee18ba\n", + "Numpy version: 1.24.4\n", + "Pytorch version: 2.5.0a0+872d972e41.nv24.08\n", "MONAI flags: HAS_EXT = False, USE_COMPILED = False, USE_META_DICT = False\n", - "MONAI rev id: c33f1ba588ee00229a309000e888f9817b4f1934\n", - "MONAI __file__: /home/localek10/workspace/monai/MONAI_mine/monai/__init__.py\n", + "MONAI rev id: ab3ee18ba32bb9bd67cd3a55717684bbd343c94c\n", + "MONAI __file__: /workspace/Code/MONAI/monai/__init__.py\n", "\n", "Optional dependencies:\n", - "Pytorch Ignite version: 0.4.12\n", - "ITK version: NOT INSTALLED or UNKNOWN VERSION.\n", - "Nibabel version: 5.0.1\n", - "scikit-image version: NOT INSTALLED or UNKNOWN VERSION.\n", - "Pillow version: 9.4.0\n", - "Tensorboard version: NOT INSTALLED or UNKNOWN VERSION.\n", - "gdown version: NOT INSTALLED or UNKNOWN VERSION.\n", - "TorchVision version: 0.15.0\n", - "tqdm version: 4.65.0\n", - "lmdb version: NOT INSTALLED or UNKNOWN VERSION.\n", - "psutil version: 5.9.0\n", - "pandas version: 1.5.3\n", - "einops version: 0.6.1\n", - "transformers version: NOT INSTALLED or UNKNOWN VERSION.\n", - "mlflow version: NOT INSTALLED or UNKNOWN VERSION.\n", - "pynrrd version: NOT INSTALLED or UNKNOWN VERSION.\n", + "Pytorch Ignite version: 0.4.11\n", + "ITK version: 5.4.0\n", + "Nibabel version: 5.2.1\n", + "scikit-image version: 0.23.2\n", + "scipy version: 1.14.0\n", + "Pillow version: 10.4.0\n", + "Tensorboard version: 2.16.2\n", + "gdown version: 5.2.0\n", + "TorchVision version: 0.20.0a0\n", + "tqdm version: 4.66.5\n", + "lmdb version: 1.5.1\n", + "psutil version: 6.0.0\n", + "pandas version: 2.2.2\n", + "einops version: 0.8.0\n", + "transformers version: 4.40.2\n", + "mlflow version: 2.16.0\n", + "pynrrd version: 1.0.0\n", + "clearml version: 1.16.4\n", "\n", "For details about installing the optional dependencies, please visit:\n", " https://docs.monai.io/en/latest/installation.html#installing-the-recommended-dependencies\n", "\n", - "Test tensor: tensor([[0.5281, 0.1114, 0.5124, 0.2523],\n", - " [0.6561, 0.0298, 0.6393, 0.8636],\n", - " [0.3730, 0.8315, 0.1390, 0.6233],\n", - " [0.2646, 0.8929, 0.5250, 0.0472]], device='cuda:0')\n" + "Test tensor: tensor([[0.7786, 0.5913, 0.6661, 0.2732],\n", + " [0.6756, 0.3978, 0.7760, 0.7936],\n", + " [0.0093, 0.6293, 0.1988, 0.0280],\n", + " [0.8460, 0.5727, 0.6339, 0.7825]], device='cuda:0')\n" ] } ], @@ -384,7 +432,7 @@ }, { "cell_type": "code", - "execution_count": 30, + "execution_count": 8, "id": "cb762695-8c5d-4f42-9c29-eb6260990b0c", "metadata": {}, "outputs": [ @@ -392,7 +440,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "Overwriting TestBundle/configs/test_object.yaml\n" + "Writing TestBundle/configs/test_object.yaml\n" ] } ], @@ -415,7 +463,7 @@ }, { "cell_type": "code", - "execution_count": 31, + "execution_count": 9, "id": "2cd1287c-f287-4831-bfc7-4cbdc394a3a1", "metadata": {}, "outputs": [ @@ -423,16 +471,31 @@ "name": "stdout", "output_type": "stream", "text": [ - "2023-07-14 15:28:36,063 - INFO - --- input summary of monai.bundle.scripts.run ---\n", - "2023-07-14 15:28:36,063 - INFO - > run_id: 'test'\n", - "2023-07-14 15:28:36,063 - INFO - > meta_file: './TestBundle/configs/metadata.json'\n", - "2023-07-14 15:28:36,063 - INFO - > config_file: './TestBundle/configs/test_object.yaml'\n", - "2023-07-14 15:28:36,063 - INFO - ---\n", + "2024-09-18 08:15:22,338 - INFO - --- input summary of monai.bundle.scripts.run ---\n", + "2024-09-18 08:15:22,338 - INFO - > config_file: './TestBundle/configs/test_object.yaml'\n", + "2024-09-18 08:15:22,338 - INFO - > meta_file: './TestBundle/configs/metadata.json'\n", + "2024-09-18 08:15:22,338 - INFO - > run_id: 'test'\n", + "2024-09-18 08:15:22,338 - INFO - ---\n", "\n", - "\n", - "Dataset \n", + "\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "WARNING:py.warnings:The 'warn' method is deprecated, use 'warning' instead\n", + "\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "2024-09-18 08:15:22,339 - WARNING - Default logging file in TestBundle/configs/logging.conf does not exist, skipping logging.\n", + "Dataset \n", "Size 10\n", - "Transform member None\n", + "Transform member \n", "Values [{0: 0}, {1: 1}, {2: 4}, {3: 9}, {4: 16}, {5: 25}, {6: 36}, {7: 49}, {8: 64}, {9: 81}]\n" ] } @@ -470,7 +533,7 @@ }, { "cell_type": "code", - "execution_count": 20, + "execution_count": 10, "id": "391ec82b-43a2-4b6f-8307-e3c853986719", "metadata": {}, "outputs": [ @@ -496,7 +559,7 @@ }, { "cell_type": "code", - "execution_count": 21, + "execution_count": 11, "id": "229617a0-1120-4054-9232-1991cfa21ae9", "metadata": {}, "outputs": [ @@ -504,35 +567,80 @@ "name": "stdout", "output_type": "stream", "text": [ - "2023-07-14 15:22:37,435 - INFO - --- input summary of monai.bundle.scripts.run ---\n", - "2023-07-14 15:22:37,435 - INFO - > run_id: 'test'\n", - "2023-07-14 15:22:37,436 - INFO - > meta_file: './TestBundle/configs/metadata.json'\n", - "2023-07-14 15:22:37,436 - INFO - > config_file: './TestBundle/configs/test_cmdline.yaml'\n", - "2023-07-14 15:22:37,436 - INFO - ---\n", - "\n", + "2024-09-18 08:15:32,092 - INFO - --- input summary of monai.bundle.scripts.run ---\n", + "2024-09-18 08:15:32,092 - INFO - > config_file: './TestBundle/configs/test_cmdline.yaml'\n", + "2024-09-18 08:15:32,092 - INFO - > meta_file: './TestBundle/configs/metadata.json'\n", + "2024-09-18 08:15:32,092 - INFO - > run_id: 'test'\n", + "2024-09-18 08:15:32,092 - INFO - ---\n", "\n", + "\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "WARNING:py.warnings:The 'warn' method is deprecated, use 'warning' instead\n", + "\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "2024-09-18 08:15:32,093 - WARNING - Default logging file in TestBundle/configs/logging.conf does not exist, skipping logging.\n", "Height 8\n", "Width 8\n", "Area 64\n", - "2023-07-14 15:22:40,876 - INFO - --- input summary of monai.bundle.scripts.run ---\n", - "2023-07-14 15:22:40,876 - INFO - > run_id: 'test'\n", - "2023-07-14 15:22:40,876 - INFO - > meta_file: './TestBundle/configs/metadata.json'\n", - "2023-07-14 15:22:40,876 - INFO - > config_file: './TestBundle/configs/test_cmdline.yaml'\n", - "2023-07-14 15:22:40,876 - INFO - > shape#0: 4\n", - "2023-07-14 15:22:40,876 - INFO - ---\n", - "\n", + "2024-09-18 08:15:41,817 - INFO - --- input summary of monai.bundle.scripts.run ---\n", + "2024-09-18 08:15:41,817 - INFO - > config_file: './TestBundle/configs/test_cmdline.yaml'\n", + "2024-09-18 08:15:41,817 - INFO - > meta_file: './TestBundle/configs/metadata.json'\n", + "2024-09-18 08:15:41,817 - INFO - > run_id: 'test'\n", + "2024-09-18 08:15:41,817 - INFO - > shape#0: 4\n", + "2024-09-18 08:15:41,817 - INFO - ---\n", "\n", + "\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "WARNING:py.warnings:The 'warn' method is deprecated, use 'warning' instead\n", + "\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "2024-09-18 08:15:41,818 - WARNING - Default logging file in TestBundle/configs/logging.conf does not exist, skipping logging.\n", "Height 4\n", "Width 8\n", "Area 32\n", - "2023-07-14 15:22:44,279 - INFO - --- input summary of monai.bundle.scripts.run ---\n", - "2023-07-14 15:22:44,279 - INFO - > run_id: 'test'\n", - "2023-07-14 15:22:44,279 - INFO - > meta_file: './TestBundle/configs/metadata.json'\n", - "2023-07-14 15:22:44,279 - INFO - > config_file: './TestBundle/configs/test_cmdline.yaml'\n", - "2023-07-14 15:22:44,279 - INFO - > area: 32\n", - "2023-07-14 15:22:44,279 - INFO - ---\n", - "\n", + "2024-09-18 08:15:51,574 - INFO - --- input summary of monai.bundle.scripts.run ---\n", + "2024-09-18 08:15:51,574 - INFO - > config_file: './TestBundle/configs/test_cmdline.yaml'\n", + "2024-09-18 08:15:51,574 - INFO - > meta_file: './TestBundle/configs/metadata.json'\n", + "2024-09-18 08:15:51,574 - INFO - > run_id: 'test'\n", + "2024-09-18 08:15:51,574 - INFO - > area: 32\n", + "2024-09-18 08:15:51,574 - INFO - ---\n", "\n", + "\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "WARNING:py.warnings:The 'warn' method is deprecated, use 'warning' instead\n", + "\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "2024-09-18 08:15:51,575 - WARNING - Default logging file in TestBundle/configs/logging.conf does not exist, skipping logging.\n", "Height 8\n", "Width 8\n", "Area 32\n" @@ -574,7 +682,7 @@ }, { "cell_type": "code", - "execution_count": 17, + "execution_count": 12, "id": "55c034c5-b03f-4ac1-8aa0-a7b768bbbb7e", "metadata": {}, "outputs": [ @@ -595,7 +703,7 @@ }, { "cell_type": "code", - "execution_count": 18, + "execution_count": 13, "id": "2511798a-cd44-4aec-954c-c766b29f0a43", "metadata": {}, "outputs": [ @@ -618,7 +726,7 @@ }, { "cell_type": "code", - "execution_count": 19, + "execution_count": 14, "id": "dc6adf63-c4b5-4f97-805a-2321dc1e8d2c", "metadata": {}, "outputs": [ @@ -626,13 +734,28 @@ "name": "stdout", "output_type": "stream", "text": [ - "2023-07-14 15:09:59,663 - INFO - --- input summary of monai.bundle.scripts.run ---\n", - "2023-07-14 15:09:59,663 - INFO - > run_id: 'test'\n", - "2023-07-14 15:09:59,663 - INFO - > meta_file: './TestBundle/configs/metadata.json'\n", - "2023-07-14 15:09:59,663 - INFO - > config_file: ['./TestBundle/configs/multifile1.yaml', './TestBundle/configs/multifile2.yaml']\n", - "2023-07-14 15:09:59,663 - INFO - ---\n", - "\n", + "2024-09-18 08:16:01,272 - INFO - --- input summary of monai.bundle.scripts.run ---\n", + "2024-09-18 08:16:01,273 - INFO - > config_file: ['./TestBundle/configs/multifile1.yaml', './TestBundle/configs/multifile2.yaml']\n", + "2024-09-18 08:16:01,273 - INFO - > meta_file: './TestBundle/configs/metadata.json'\n", + "2024-09-18 08:16:01,273 - INFO - > run_id: 'test'\n", + "2024-09-18 08:16:01,273 - INFO - ---\n", "\n", + "\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "WARNING:py.warnings:The 'warn' method is deprecated, use 'warning' instead\n", + "\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "2024-09-18 08:16:01,274 - WARNING - Default logging file in TestBundle/configs/logging.conf does not exist, skipping logging.\n", "Area 64\n" ] } @@ -676,9 +799,9 @@ ], "metadata": { "kernelspec": { - "display_name": "Python [conda env:monai]", + "display_name": "Python 3", "language": "python", - "name": "conda-env-monai-py" + "name": "python3" }, "language_info": { "codemirror_mode": { @@ -690,7 +813,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.10" + "version": "3.10.12" } }, "nbformat": 4, diff --git a/bundle/02_mednist_classification.ipynb b/bundle/02_mednist_classification.ipynb index 9a351de68b..d786f0c46a 100644 --- a/bundle/02_mednist_classification.ipynb +++ b/bundle/02_mednist_classification.ipynb @@ -27,7 +27,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 1, "id": "886952c4-0be4-459d-9c53-b81b29199c76", "metadata": {}, "outputs": [], @@ -45,10 +45,55 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 2, "id": "b1144d87-ec2f-4b9b-907a-16ea2da279c4", "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/usr/local/lib/python3.10/dist-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n", + " from .autonotebook import tqdm as notebook_tqdm\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "MONAI version: 1.4.0rc8+1.gab3ee18ba\n", + "Numpy version: 1.24.4\n", + "Pytorch version: 2.5.0a0+872d972e41.nv24.08\n", + "MONAI flags: HAS_EXT = False, USE_COMPILED = False, USE_META_DICT = False\n", + "MONAI rev id: ab3ee18ba32bb9bd67cd3a55717684bbd343c94c\n", + "MONAI __file__: /workspace/Code/MONAI/monai/__init__.py\n", + "\n", + "Optional dependencies:\n", + "Pytorch Ignite version: 0.4.11\n", + "ITK version: 5.4.0\n", + "Nibabel version: 5.2.1\n", + "scikit-image version: 0.23.2\n", + "scipy version: 1.14.0\n", + "Pillow version: 10.4.0\n", + "Tensorboard version: 2.16.2\n", + "gdown version: 5.2.0\n", + "TorchVision version: 0.20.0a0\n", + "tqdm version: 4.66.5\n", + "lmdb version: 1.5.1\n", + "psutil version: 6.0.0\n", + "pandas version: 2.2.2\n", + "einops version: 0.8.0\n", + "transformers version: 4.40.2\n", + "mlflow version: 2.16.0\n", + "pynrrd version: 1.0.0\n", + "clearml version: 1.16.4\n", + "\n", + "For details about installing the optional dependencies, please visit:\n", + " https://docs.monai.io/en/latest/installation.html#installing-the-recommended-dependencies\n", + "\n" + ] + } + ], "source": [ "from monai.config import print_config\n", "\n", @@ -137,7 +182,7 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": 3, "id": "eb9dc6ec-13da-4a37-8afa-28e2766b9343", "metadata": {}, "outputs": [ @@ -178,7 +223,7 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 4, "id": "b29f053b-cf16-4ffc-bbe7-d9433fdfa872", "metadata": {}, "outputs": [ @@ -201,7 +246,7 @@ " \"monai_version\": \"1.2.0\",\n", " \"pytorch_version\": \"2.0.0\",\n", " \"numpy_version\": \"1.23.5\",\n", - " \"optional_packages_version\": {},\n", + " \"required_packages_version\": {},\n", " \"name\": \"MedNISTClassifier\",\n", " \"task\": \"MedNIST Classification Network\",\n", " \"description\": \"This is a demo network for classifying MedNIST images by type/modality\",\n", @@ -263,7 +308,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 5, "id": "d11681af-3210-4b2b-b7bd-8ad8dedfe230", "metadata": { "lines_to_next_cell": 2 @@ -338,7 +383,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 6, "id": "4dfd052e-abe7-473a-bbf4-25674a3b20ea", "metadata": {}, "outputs": [ @@ -406,7 +451,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 7, "id": "8357670d-fe69-4789-9b9a-77c0d8144b10", "metadata": {}, "outputs": [ @@ -414,22 +459,13 @@ "name": "stdout", "output_type": "stream", "text": [ - "workflow_name None\n", - "config_file ['./MedNISTClassifier/configs/common.yaml', './MedNISTClassifier/configs/train.yaml']\n", - "meta_file ./MedNISTClassifier/configs/metadata.json\n", - "logging_file None\n", - "init_id None\n", - "run_id train\n", - "final_id None\n", - "tracking None\n", - "max_epochs 2\n", - "2023-09-11 16:19:49,915 - INFO - --- input summary of monai.bundle.scripts.run ---\n", - "2023-09-11 16:19:49,915 - INFO - > config_file: ['./MedNISTClassifier/configs/common.yaml',\n", + "2024-09-18 08:16:57,243 - INFO - --- input summary of monai.bundle.scripts.run ---\n", + "2024-09-18 08:16:57,243 - INFO - > config_file: ['./MedNISTClassifier/configs/common.yaml',\n", " './MedNISTClassifier/configs/train.yaml']\n", - "2023-09-11 16:19:49,915 - INFO - > meta_file: './MedNISTClassifier/configs/metadata.json'\n", - "2023-09-11 16:19:49,915 - INFO - > run_id: 'train'\n", - "2023-09-11 16:19:49,915 - INFO - > max_epochs: 2\n", - "2023-09-11 16:19:49,915 - INFO - ---\n", + "2024-09-18 08:16:57,243 - INFO - > meta_file: './MedNISTClassifier/configs/metadata.json'\n", + "2024-09-18 08:16:57,243 - INFO - > run_id: 'train'\n", + "2024-09-18 08:16:57,243 - INFO - > max_epochs: 2\n", + "2024-09-18 08:16:57,243 - INFO - ---\n", "\n", "\n" ] @@ -438,24 +474,42 @@ "name": "stderr", "output_type": "stream", "text": [ - "/home/localek10/workspace/monai/MONAI_mine/monai/bundle/workflows.py:257: UserWarning: Default logging file in MedNISTClassifier/configs/logging.conf does not exist, skipping logging.\n", - " warnings.warn(f\"Default logging file in {logging_file} does not exist, skipping logging.\")\n" + "WARNING:py.warnings:The 'warn' method is deprecated, use 'warning' instead\n", + "\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ - "2023-09-11 16:19:50,055 - INFO - Verified 'MedNIST.tar.gz', md5: 0bc7306e7427e00ad1c5526a6677552d.\n", - "2023-09-11 16:19:50,055 - INFO - File exists: MedNIST.tar.gz, skipped downloading.\n", - "2023-09-11 16:19:50,055 - INFO - Non-empty folder exists in MedNIST, skipped extracting.\n" + "2024-09-18 08:16:57,244 - WARNING - Default logging file in MedNISTClassifier/configs/logging.conf does not exist, skipping logging.\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ - "Loading dataset: 100%|██████████| 47164/47164 [00:41<00:00, 1145.05it/s]\n" + "MedNIST.tar.gz: 59.0MB [00:03, 20.1MB/s] \n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "2024-09-18 08:17:00,407 - INFO - Downloaded: MedNIST.tar.gz\n", + "2024-09-18 08:17:00,490 - INFO - Verified 'MedNIST.tar.gz', md5: 0bc7306e7427e00ad1c5526a6677552d.\n", + "2024-09-18 08:17:00,490 - INFO - Writing into directory: ..\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "Loading dataset: 100%|██████████| 47164/47164 [00:23<00:00, 2042.89it/s]\n", + "INFO:ignite.engine.engine.SupervisedTrainer:Engine run resuming from iteration 0, epoch 0 until 2 epochs\n", + "INFO:ignite.engine.engine.SupervisedTrainer:Epoch[1] Complete. Time taken: 00:00:16.954\n", + "INFO:ignite.engine.engine.SupervisedTrainer:Epoch[2] Complete. Time taken: 00:00:16.772\n", + "INFO:ignite.engine.engine.SupervisedTrainer:Engine run complete. Time taken: 00:00:34.112\n" ] } ], @@ -494,7 +548,7 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 8, "id": "fbad1a21-4dda-4b80-8e81-7d7e75307f9c", "metadata": {}, "outputs": [], @@ -504,7 +558,7 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 9, "id": "0c8725f7-f1cd-48f5-81a5-3f5a9ee03e9c", "metadata": {}, "outputs": [ @@ -541,7 +595,7 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 10, "id": "b4e1f99a-a68b-4aeb-bcf2-842f26609b52", "metadata": { "lines_to_next_cell": 2 @@ -595,7 +649,7 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 11, "id": "3c5fa39f-8798-4e41-8e2a-3a70a6be3906", "metadata": {}, "outputs": [ @@ -603,22 +657,13 @@ "name": "stdout", "output_type": "stream", "text": [ - "workflow_name None\n", - "config_file ['./MedNISTClassifier/configs/common.yaml', './MedNISTClassifier/configs/evaluate.yaml']\n", - "meta_file ./MedNISTClassifier/configs/metadata.json\n", - "logging_file None\n", - "init_id None\n", - "run_id evaluate\n", - "final_id None\n", - "tracking None\n", - "ckpt_file ./MedNISTClassifier/models/model.pt\n", - "2023-09-11 16:22:56,379 - INFO - --- input summary of monai.bundle.scripts.run ---\n", - "2023-09-11 16:22:56,379 - INFO - > config_file: ['./MedNISTClassifier/configs/common.yaml',\n", + "2024-09-18 08:18:16,102 - INFO - --- input summary of monai.bundle.scripts.run ---\n", + "2024-09-18 08:18:16,102 - INFO - > config_file: ['./MedNISTClassifier/configs/common.yaml',\n", " './MedNISTClassifier/configs/evaluate.yaml']\n", - "2023-09-11 16:22:56,379 - INFO - > meta_file: './MedNISTClassifier/configs/metadata.json'\n", - "2023-09-11 16:22:56,379 - INFO - > run_id: 'evaluate'\n", - "2023-09-11 16:22:56,379 - INFO - > ckpt_file: './MedNISTClassifier/models/model.pt'\n", - "2023-09-11 16:22:56,379 - INFO - ---\n", + "2024-09-18 08:18:16,102 - INFO - > meta_file: './MedNISTClassifier/configs/metadata.json'\n", + "2024-09-18 08:18:16,102 - INFO - > run_id: 'evaluate'\n", + "2024-09-18 08:18:16,102 - INFO - > ckpt_file: './MedNISTClassifier/models/model.pt'\n", + "2024-09-18 08:18:16,102 - INFO - ---\n", "\n", "\n" ] @@ -627,8 +672,23 @@ "name": "stderr", "output_type": "stream", "text": [ - "/home/localek10/workspace/monai/MONAI_mine/monai/bundle/workflows.py:257: UserWarning: Default logging file in MedNISTClassifier/configs/logging.conf does not exist, skipping logging.\n", - " warnings.warn(f\"Default logging file in {logging_file} does not exist, skipping logging.\")\n" + "WARNING:py.warnings:The 'warn' method is deprecated, use 'warning' instead\n", + "\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "2024-09-18 08:18:16,103 - WARNING - Default logging file in MedNISTClassifier/configs/logging.conf does not exist, skipping logging.\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "WARNING:py.warnings:You are using `torch.load` with `weights_only=False` (the current default value), which uses the default pickle module implicitly. It is possible to construct malicious pickle data which will execute arbitrary code during unpickling (See https://github.com/pytorch/pytorch/blob/main/SECURITY.md#untrusted-models for more details). In a future release, the default value for `weights_only` will be flipped to `True`. This limits the functions that could be executed during unpickling. Arbitrary objects will no longer be allowed to be loaded via this mode unless they are explicitly allowlisted by the user via `torch.serialization.add_safe_globals`. We recommend you start setting `weights_only=True` for any use case where you don't have full control of the loaded file. Please open an issue on GitHub for any issues related to this experimental feature.\n", + "\n" ] }, { @@ -677,9 +737,9 @@ ], "metadata": { "kernelspec": { - "display_name": "Python [conda env:monai]", + "display_name": "Python 3", "language": "python", - "name": "conda-env-monai-py" + "name": "python3" }, "language_info": { "codemirror_mode": { @@ -691,7 +751,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.10" + "version": "3.10.12" } }, "nbformat": 4, diff --git a/bundle/03_mednist_classification_v2.ipynb b/bundle/03_mednist_classification_v2.ipynb index c6d0b2a73a..df5cb65444 100644 --- a/bundle/03_mednist_classification_v2.ipynb +++ b/bundle/03_mednist_classification_v2.ipynb @@ -27,7 +27,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 1, "id": "fab1bcae-678b-4b19-a513-d0577d3d7e2b", "metadata": {}, "outputs": [], @@ -45,10 +45,55 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 2, "id": "f1492c89-b19f-4216-b3a0-9960397e72ca", "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/usr/local/lib/python3.10/dist-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n", + " from .autonotebook import tqdm as notebook_tqdm\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "MONAI version: 1.4.0rc8+1.gab3ee18ba\n", + "Numpy version: 1.24.4\n", + "Pytorch version: 2.5.0a0+872d972e41.nv24.08\n", + "MONAI flags: HAS_EXT = False, USE_COMPILED = False, USE_META_DICT = False\n", + "MONAI rev id: ab3ee18ba32bb9bd67cd3a55717684bbd343c94c\n", + "MONAI __file__: /workspace/Code/MONAI/monai/__init__.py\n", + "\n", + "Optional dependencies:\n", + "Pytorch Ignite version: 0.4.11\n", + "ITK version: 5.4.0\n", + "Nibabel version: 5.2.1\n", + "scikit-image version: 0.23.2\n", + "scipy version: 1.14.0\n", + "Pillow version: 10.4.0\n", + "Tensorboard version: 2.16.2\n", + "gdown version: 5.2.0\n", + "TorchVision version: 0.20.0a0\n", + "tqdm version: 4.66.5\n", + "lmdb version: 1.5.1\n", + "psutil version: 6.0.0\n", + "pandas version: 2.2.2\n", + "einops version: 0.8.0\n", + "transformers version: 4.40.2\n", + "mlflow version: 2.16.0\n", + "pynrrd version: 1.0.0\n", + "clearml version: 1.16.4\n", + "\n", + "For details about installing the optional dependencies, please visit:\n", + " https://docs.monai.io/en/latest/installation.html#installing-the-recommended-dependencies\n", + "\n" + ] + } + ], "source": [ "import numpy as np\n", "from monai.apps import MedNISTDataset\n", @@ -71,7 +116,7 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 3, "id": "eb9dc6ec-13da-4a37-8afa-28e2766b9343", "metadata": {}, "outputs": [ @@ -102,7 +147,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 4, "id": "b29f053b-cf16-4ffc-bbe7-d9433fdfa872", "metadata": {}, "outputs": [ @@ -125,7 +170,7 @@ " \"monai_version\": \"1.2.0\",\n", " \"pytorch_version\": \"2.0.0\",\n", " \"numpy_version\": \"1.23.5\",\n", - " \"optional_packages_version\": {},\n", + " \"required_packages_version\": {},\n", " \"name\": \"MedNISTClassifier\",\n", " \"task\": \"MedNIST Classification Network\",\n", " \"description\": \"This is a demo network for classifying MedNIST images by type/modality\",\n", @@ -183,7 +228,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 5, "id": "0cb1b023-d192-4ad7-b2eb-c4a2c6b42b84", "metadata": { "lines_to_next_cell": 2 @@ -233,7 +278,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 6, "id": "d11681af-3210-4b2b-b7bd-8ad8dedfe230", "metadata": { "lines_to_next_cell": 2 @@ -307,7 +352,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 7, "id": "4dfd052e-abe7-473a-bbf4-25674a3b20ea", "metadata": { "lines_to_next_cell": 2 @@ -467,7 +512,7 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": 8, "id": "8357670d-fe69-4789-9b9a-77c0d8144b10", "metadata": {}, "outputs": [], @@ -486,14 +531,14 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 9, "id": "3d7e7e11-db67-47e3-a03d-0955feee1636", "metadata": { "tags": [] }, "outputs": [], "source": [ - "raise Exception(open(\"out.txt\").read())" + "# open(\"out.txt\").read()" ] }, { @@ -509,22 +554,7 @@ "execution_count": 10, "id": "00c84e2c-1709-4136-8612-87142026ac2e", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "/usr/bin/tree\n", - "\u001b[01;34moutput/output_230911_164547\u001b[00m\n", - "├── log.txt\n", - "├── model_epoch=1.pt\n", - "├── model_epoch=2.pt\n", - "└── model_final_iteration=186.pt\n", - "\n", - "0 directories, 4 files\n" - ] - } - ], + "outputs": [], "source": [ "!which tree && tree output/* || true" ] @@ -551,33 +581,33 @@ "name": "stderr", "output_type": "stream", "text": [ - "Loading dataset: 100%|██████████| 5895/5895 [00:03<00:00, 1671.21it/s]\n" + "Loading dataset: 100%|██████████| 5895/5895 [00:01<00:00, 3696.27it/s]\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ - "MedNIST/AbdomenCT/001990.jpeg Label: 0\n", - "MedNIST/BreastMRI/007676.jpeg Label: 1\n", - "MedNIST/ChestCT/006763.jpeg Label: 3\n", - "MedNIST/CXR/001214.jpeg Label: 2\n", - "MedNIST/Hand/004427.jpeg Label: 4\n", - "MedNIST/HeadCT/003806.jpeg Label: 5\n", - "MedNIST/HeadCT/004638.jpeg Label: 5\n", - "MedNIST/CXR/005013.jpeg Label: 2\n", - "MedNIST/ChestCT/008275.jpeg Label: 3\n", - "MedNIST/BreastMRI/000630.jpeg Label: 1\n", - "MedNIST/BreastMRI/007547.jpeg Label: 1\n", - "MedNIST/BreastMRI/008425.jpeg Label: 1\n", - "MedNIST/AbdomenCT/003981.jpeg Label: 0\n", - "MedNIST/Hand/001130.jpeg Label: 4\n", - "MedNIST/BreastMRI/005118.jpeg Label: 1\n", - "MedNIST/CXR/006505.jpeg Label: 2\n", - "MedNIST/ChestCT/008218.jpeg Label: 3\n", - "MedNIST/HeadCT/005305.jpeg Label: 5\n", - "MedNIST/AbdomenCT/007871.jpeg Label: 0\n", - "MedNIST/Hand/007065.jpeg Label: 4\n" + "MedNIST/AbdomenCT/006070.jpeg Label: 0\n", + "MedNIST/BreastMRI/006574.jpeg Label: 1\n", + "MedNIST/ChestCT/009858.jpeg Label: 3\n", + "MedNIST/CXR/007398.jpeg Label: 2\n", + "MedNIST/Hand/005663.jpeg Label: 4\n", + "MedNIST/HeadCT/006896.jpeg Label: 5\n", + "MedNIST/HeadCT/007179.jpeg Label: 5\n", + "MedNIST/CXR/001190.jpeg Label: 2\n", + "MedNIST/ChestCT/005138.jpeg Label: 3\n", + "MedNIST/BreastMRI/000023.jpeg Label: 1\n", + "MedNIST/BreastMRI/006831.jpeg Label: 1\n", + "MedNIST/BreastMRI/006561.jpeg Label: 1\n", + "MedNIST/AbdomenCT/005808.jpeg Label: 0\n", + "MedNIST/Hand/005363.jpeg Label: 4\n", + "MedNIST/BreastMRI/001751.jpeg Label: 1\n", + "MedNIST/CXR/002910.jpeg Label: 2\n", + "MedNIST/ChestCT/003831.jpeg Label: 3\n", + "MedNIST/HeadCT/006337.jpeg Label: 5\n", + "MedNIST/AbdomenCT/005503.jpeg Label: 0\n", + "MedNIST/Hand/003450.jpeg Label: 4\n" ] } ], @@ -589,7 +619,7 @@ "!mkdir -p test_images\n", "\n", "for i in range(num_images):\n", - " filename = dataset[i][\"image_meta_dict\"][\"filename_or_obj\"]\n", + " filename = dataset[i][\"image\"].meta[\"filename_or_obj\"]\n", " print(filename, \"Label:\", dataset[i][\"label\"])\n", " !cp {root_dir}/{filename} test_images" ] @@ -709,7 +739,7 @@ }, { "cell_type": "code", - "execution_count": 22, + "execution_count": 14, "id": "acdcc111-f259-4701-8b1d-31fcf74398bc", "metadata": {}, "outputs": [ @@ -717,23 +747,25 @@ "name": "stdout", "output_type": "stream", "text": [ - "2023-09-11 16:54:49,564 - INFO - --- input summary of monai.bundle.scripts.run ---\n", - "2023-09-11 16:54:49,564 - INFO - > run_id: 'inference'\n", - "2023-09-11 16:54:49,564 - INFO - > meta_file: './MedNISTClassifier_v2/configs/metadata.json'\n", - "2023-09-11 16:54:49,564 - INFO - > config_file: ['./MedNISTClassifier_v2/configs/common.yaml',\n", + "2024-09-18 08:26:35,660 - INFO - --- input summary of monai.bundle.scripts.run ---\n", + "2024-09-18 08:26:35,661 - INFO - > config_file: ['./MedNISTClassifier_v2/configs/common.yaml',\n", " './MedNISTClassifier_v2/configs/inference.yaml']\n", - "2023-09-11 16:54:49,564 - INFO - > logging_file: './MedNISTClassifier_v2/configs/logging.conf'\n", - "2023-09-11 16:54:49,565 - INFO - > bundle_root: './MedNISTClassifier_v2'\n", - "2023-09-11 16:54:49,565 - INFO - > ckpt_path: 'output/output_230911_164547/model_final_iteration=186.pt'\n", - "2023-09-11 16:54:49,565 - INFO - > input_dir: 'test_images'\n", - "2023-09-11 16:54:49,565 - INFO - ---\n", + "2024-09-18 08:26:35,661 - INFO - > meta_file: './MedNISTClassifier_v2/configs/metadata.json'\n", + "2024-09-18 08:26:35,661 - INFO - > logging_file: './MedNISTClassifier_v2/configs/logging.conf'\n", + "2024-09-18 08:26:35,661 - INFO - > run_id: 'inference'\n", + "2024-09-18 08:26:35,661 - INFO - > bundle_root: './MedNISTClassifier_v2'\n", + "2024-09-18 08:26:35,661 - INFO - > ckpt_path: 'output/output_240918_082534/model_final_iteration=186.pt'\n", + "2024-09-18 08:26:35,661 - INFO - > input_dir: 'test_images'\n", + "2024-09-18 08:26:35,661 - INFO - ---\n", + "\n", "\n", + "2024-09-18 08:26:35,661 - INFO - Setting logging properties based on config: ./MedNISTClassifier_v2/configs/logging.conf.\n", + "2024-09-18 08:26:35,899 - ignite.engine.engine.SupervisedEvaluator - INFO - Engine run resuming from iteration 0, epoch 0 until 1 epochs\n", + "2024-09-18 08:26:35,899 - py.warnings - WARNING - You are using `torch.load` with `weights_only=False` (the current default value), which uses the default pickle module implicitly. It is possible to construct malicious pickle data which will execute arbitrary code during unpickling (See https://github.com/pytorch/pytorch/blob/main/SECURITY.md#untrusted-models for more details). In a future release, the default value for `weights_only` will be flipped to `True`. This limits the functions that could be executed during unpickling. Arbitrary objects will no longer be allowed to be loaded via this mode unless they are explicitly allowlisted by the user via `torch.serialization.add_safe_globals`. We recommend you start setting `weights_only=True` for any use case where you don't have full control of the loaded file. Please open an issue on GitHub for any issues related to this experimental feature.\n", "\n", - "2023-09-11 16:54:49,565 - INFO - Setting logging properties based on config: ./MedNISTClassifier_v2/configs/logging.conf.\n", - "2023-09-11 16:54:49,924 - ignite.engine.engine.SupervisedEvaluator - INFO - Engine run resuming from iteration 0, epoch 0 until 1 epochs\n", - "2023-09-11 16:54:50,035 - ignite.engine.engine.SupervisedEvaluator - INFO - Restored all variables from output/output_230911_164547/model_final_iteration=186.pt\n", - "2023-09-11 16:54:50,936 - ignite.engine.engine.SupervisedEvaluator - INFO - Epoch[1] Complete. Time taken: 00:00:00.901\n", - "2023-09-11 16:54:50,936 - ignite.engine.engine.SupervisedEvaluator - INFO - Engine run complete. Time taken: 00:00:01.012\n" + "2024-09-18 08:26:35,958 - ignite.engine.engine.SupervisedEvaluator - INFO - Restored all variables from output/output_240918_082534/model_final_iteration=186.pt\n", + "2024-09-18 08:26:36,545 - ignite.engine.engine.SupervisedEvaluator - INFO - Epoch[1] Complete. Time taken: 00:00:00.586\n", + "2024-09-18 08:26:36,545 - ignite.engine.engine.SupervisedEvaluator - INFO - Engine run complete. Time taken: 00:00:00.646\n" ] } ], @@ -765,7 +797,7 @@ }, { "cell_type": "code", - "execution_count": 23, + "execution_count": 15, "id": "4a695039-7a53-4f9a-9754-769a9f8ebac8", "metadata": {}, "outputs": [ @@ -773,26 +805,26 @@ "name": "stdout", "output_type": "stream", "text": [ - "test_images/000630.jpeg,1.0\n", - "test_images/001130.jpeg,4.0\n", - "test_images/001214.jpeg,2.0\n", - "test_images/001990.jpeg,0.0\n", - "test_images/003806.jpeg,5.0\n", - "test_images/003981.jpeg,0.0\n", - "test_images/004427.jpeg,4.0\n", - "test_images/004638.jpeg,5.0\n", - "test_images/005013.jpeg,2.0\n", - "test_images/005118.jpeg,1.0\n", - "test_images/005305.jpeg,5.0\n", - "test_images/006505.jpeg,2.0\n", - "test_images/006763.jpeg,3.0\n", - "test_images/007065.jpeg,4.0\n", - "test_images/007547.jpeg,1.0\n", - "test_images/007676.jpeg,1.0\n", - "test_images/007871.jpeg,0.0\n", - "test_images/008218.jpeg,3.0\n", - "test_images/008275.jpeg,3.0\n", - "test_images/008425.jpeg,1.0\n" + "test_images/000023.jpeg,1.0\n", + "test_images/001190.jpeg,2.0\n", + "test_images/001751.jpeg,1.0\n", + "test_images/002910.jpeg,2.0\n", + "test_images/003450.jpeg,4.0\n", + "test_images/003831.jpeg,3.0\n", + "test_images/005138.jpeg,3.0\n", + "test_images/005363.jpeg,4.0\n", + "test_images/005503.jpeg,0.0\n", + "test_images/005663.jpeg,4.0\n", + "test_images/005808.jpeg,0.0\n", + "test_images/006070.jpeg,0.0\n", + "test_images/006337.jpeg,5.0\n", + "test_images/006561.jpeg,1.0\n", + "test_images/006574.jpeg,1.0\n", + "test_images/006831.jpeg,1.0\n", + "test_images/006896.jpeg,5.0\n", + "test_images/007179.jpeg,5.0\n", + "test_images/007398.jpeg,2.0\n", + "test_images/009858.jpeg,3.0\n" ] } ], @@ -810,7 +842,7 @@ }, { "cell_type": "code", - "execution_count": 24, + "execution_count": 16, "id": "1065f928-3f66-47af-aed4-be2f0443cf2f", "metadata": {}, "outputs": [ @@ -818,26 +850,26 @@ "name": "stdout", "output_type": "stream", "text": [ - "test_images/000630.jpeg BreastMRI\n", - "test_images/001130.jpeg Hand\n", - "test_images/001214.jpeg CXR\n", - "test_images/001990.jpeg AbdomenCT\n", - "test_images/003806.jpeg HeadCT\n", - "test_images/003981.jpeg AbdomenCT\n", - "test_images/004427.jpeg Hand\n", - "test_images/004638.jpeg HeadCT\n", - "test_images/005013.jpeg CXR\n", - "test_images/005118.jpeg BreastMRI\n", - "test_images/005305.jpeg HeadCT\n", - "test_images/006505.jpeg CXR\n", - "test_images/006763.jpeg ChestCT\n", - "test_images/007065.jpeg Hand\n", - "test_images/007547.jpeg BreastMRI\n", - "test_images/007676.jpeg BreastMRI\n", - "test_images/007871.jpeg AbdomenCT\n", - "test_images/008218.jpeg ChestCT\n", - "test_images/008275.jpeg ChestCT\n", - "test_images/008425.jpeg BreastMRI\n" + "test_images/000023.jpeg BreastMRI\n", + "test_images/001190.jpeg CXR\n", + "test_images/001751.jpeg BreastMRI\n", + "test_images/002910.jpeg CXR\n", + "test_images/003450.jpeg Hand\n", + "test_images/003831.jpeg ChestCT\n", + "test_images/005138.jpeg ChestCT\n", + "test_images/005363.jpeg Hand\n", + "test_images/005503.jpeg AbdomenCT\n", + "test_images/005663.jpeg Hand\n", + "test_images/005808.jpeg AbdomenCT\n", + "test_images/006070.jpeg AbdomenCT\n", + "test_images/006337.jpeg HeadCT\n", + "test_images/006561.jpeg BreastMRI\n", + "test_images/006574.jpeg BreastMRI\n", + "test_images/006831.jpeg BreastMRI\n", + "test_images/006896.jpeg HeadCT\n", + "test_images/007179.jpeg HeadCT\n", + "test_images/007398.jpeg CXR\n", + "test_images/009858.jpeg ChestCT\n" ] } ], @@ -862,7 +894,7 @@ }, { "cell_type": "code", - "execution_count": 25, + "execution_count": 17, "id": "c6672caa-fd51-4dde-a31d-5c4de8c3cc1d", "metadata": { "tags": [] @@ -872,35 +904,33 @@ "name": "stdout", "output_type": "stream", "text": [ - "2023-09-11 16:57:08,807 - INFO - --- input summary of monai.bundle.scripts.ckpt_export ---\n", - "2023-09-11 16:57:08,807 - INFO - > net_id: 'network_def'\n", - "2023-09-11 16:57:08,807 - INFO - > filepath: './MedNISTClassifier_v2/models/model.ts'\n", - "2023-09-11 16:57:08,807 - INFO - > meta_file: './MedNISTClassifier_v2/configs/metadata.json'\n", - "2023-09-11 16:57:08,807 - INFO - > config_file: ['./MedNISTClassifier_v2/configs/common.yaml',\n", + "2024-09-18 08:26:46,705 - INFO - --- input summary of monai.bundle.scripts.ckpt_export ---\n", + "2024-09-18 08:26:46,706 - INFO - > net_id: 'network_def'\n", + "2024-09-18 08:26:46,706 - INFO - > filepath: './MedNISTClassifier_v2/models/model.ts'\n", + "2024-09-18 08:26:46,706 - INFO - > meta_file: './MedNISTClassifier_v2/configs/metadata.json'\n", + "2024-09-18 08:26:46,706 - INFO - > config_file: ['./MedNISTClassifier_v2/configs/common.yaml',\n", " './MedNISTClassifier_v2/configs/inference.yaml']\n", - "2023-09-11 16:57:08,807 - INFO - > ckpt_file: './MedNISTClassifier_v2/models/model.pt'\n", - "2023-09-11 16:57:08,807 - INFO - > key_in_ckpt: 'model'\n", - "2023-09-11 16:57:08,807 - INFO - > bundle_root: './MedNISTClassifier_v2'\n", - "2023-09-11 16:57:08,807 - INFO - ---\n", - "\n", - "\n", - "2023-09-11 16:57:12,519 - INFO - exported to file: ./MedNISTClassifier_v2/models/model.ts.\n", - "/usr/bin/tree\n", - "\u001b[01;34m./MedNISTClassifier_v2\u001b[00m\n", - "├── \u001b[01;34mconfigs\u001b[00m\n", - "│   ├── common.yaml\n", - "│   ├── inference.yaml\n", - "│   ├── logging.conf\n", - "│   ├── metadata.json\n", - "│   └── train.yaml\n", - "├── \u001b[01;34mdocs\u001b[00m\n", - "│   └── README.md\n", - "├── LICENSE\n", - "└── \u001b[01;34mmodels\u001b[00m\n", - " ├── model.pt\n", - " └── model.ts\n", + "2024-09-18 08:26:46,706 - INFO - > ckpt_file: './MedNISTClassifier_v2/models/model.pt'\n", + "2024-09-18 08:26:46,706 - INFO - > key_in_ckpt: 'model'\n", + "2024-09-18 08:26:46,706 - INFO - > bundle_root: './MedNISTClassifier_v2'\n", + "2024-09-18 08:26:46,706 - INFO - ---\n", "\n", - "3 directories, 9 files\n" + "\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "WARNING:py.warnings:You are using `torch.load` with `weights_only=False` (the current default value), which uses the default pickle module implicitly. It is possible to construct malicious pickle data which will execute arbitrary code during unpickling (See https://github.com/pytorch/pytorch/blob/main/SECURITY.md#untrusted-models for more details). In a future release, the default value for `weights_only` will be flipped to `True`. This limits the functions that could be executed during unpickling. Arbitrary objects will no longer be allowed to be loaded via this mode unless they are explicitly allowlisted by the user via `torch.serialization.add_safe_globals`. We recommend you start setting `weights_only=True` for any use case where you don't have full control of the loaded file. Please open an issue on GitHub for any issues related to this experimental feature.\n", + "\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "2024-09-18 08:26:47,818 - INFO - exported to file: ./MedNISTClassifier_v2/models/model.ts.\n" ] } ], @@ -959,9 +989,9 @@ ], "metadata": { "kernelspec": { - "display_name": "Python [conda env:monai1]", + "display_name": "Python 3", "language": "python", - "name": "conda-env-monai1-py" + "name": "python3" }, "language_info": { "codemirror_mode": { @@ -973,7 +1003,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.18" + "version": "3.10.12" } }, "nbformat": 4, diff --git a/bundle/04_integrating_code.ipynb b/bundle/04_integrating_code.ipynb index 7815720017..279e6611ed 100644 --- a/bundle/04_integrating_code.ipynb +++ b/bundle/04_integrating_code.ipynb @@ -27,7 +27,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 1, "id": "cd80c262-cf94-48df-b78e-c54a88a7ffb5", "metadata": {}, "outputs": [], @@ -45,10 +45,55 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 2, "id": "eeeee791-025e-4b1d-9dec-ebc83a8be4eb", "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/usr/local/lib/python3.10/dist-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n", + " from .autonotebook import tqdm as notebook_tqdm\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "MONAI version: 1.4.0rc8+1.gab3ee18ba\n", + "Numpy version: 1.24.4\n", + "Pytorch version: 2.5.0a0+872d972e41.nv24.08\n", + "MONAI flags: HAS_EXT = False, USE_COMPILED = False, USE_META_DICT = False\n", + "MONAI rev id: ab3ee18ba32bb9bd67cd3a55717684bbd343c94c\n", + "MONAI __file__: /workspace/Code/MONAI/monai/__init__.py\n", + "\n", + "Optional dependencies:\n", + "Pytorch Ignite version: 0.4.11\n", + "ITK version: 5.4.0\n", + "Nibabel version: 5.2.1\n", + "scikit-image version: 0.23.2\n", + "scipy version: 1.14.0\n", + "Pillow version: 10.4.0\n", + "Tensorboard version: 2.16.2\n", + "gdown version: 5.2.0\n", + "TorchVision version: 0.20.0a0\n", + "tqdm version: 4.66.5\n", + "lmdb version: 1.5.1\n", + "psutil version: 6.0.0\n", + "pandas version: 2.2.2\n", + "einops version: 0.8.0\n", + "transformers version: 4.40.2\n", + "mlflow version: 2.16.0\n", + "pynrrd version: 1.0.0\n", + "clearml version: 1.16.4\n", + "\n", + "For details about installing the optional dependencies, please visit:\n", + " https://docs.monai.io/en/latest/installation.html#installing-the-recommended-dependencies\n", + "\n" + ] + } + ], "source": [ "import torchvision\n", "from monai.config import print_config\n", @@ -72,7 +117,7 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": 3, "id": "eb9dc6ec-13da-4a37-8afa-28e2766b9343", "metadata": {}, "outputs": [ @@ -108,7 +153,7 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 4, "id": "b29f053b-cf16-4ffc-bbe7-d9433fdfa872", "metadata": { "tags": [] @@ -133,7 +178,7 @@ " \"monai_version\": \"1.2.0\",\n", " \"pytorch_version\": \"2.0.0\",\n", " \"numpy_version\": \"1.23.5\",\n", - " \"optional_packages_version\": {\n", + " \"required_packages_version\": {\n", " \"torchvision\": \"0.15.0\"\n", " },\n", " \"name\": \"IntegrationBundle\",\n", @@ -203,7 +248,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 5, "id": "dcdbe1ae-ea13-49cb-b5a3-3c2c78f91f2b", "metadata": { "lines_to_next_cell": 2, @@ -255,7 +300,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 6, "id": "189d71c5-6556-4891-a382-0adbc8f80d30", "metadata": { "lines_to_next_cell": 2 @@ -281,7 +326,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 7, "id": "3d8f233e-495c-450c-a445-46d295ba7461", "metadata": { "lines_to_next_cell": 2, @@ -331,7 +376,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 8, "id": "1a836b1b-06da-4866-82a2-47d1efed5d7c", "metadata": { "tags": [] @@ -390,7 +435,7 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 9, "id": "0b9764a8-674c-42ae-ad4b-f2dea027bdbf", "metadata": { "lines_to_next_cell": 2, @@ -440,7 +485,7 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": 10, "id": "65149911-3771-4a49-ade6-378305a4b946", "metadata": { "tags": [] @@ -450,12 +495,12 @@ "name": "stdout", "output_type": "stream", "text": [ - "2023-09-11 17:28:16,125 - INFO - --- input summary of monai.bundle.scripts.run ---\n", - "2023-09-11 17:28:16,125 - INFO - > run_id: 'train'\n", - "2023-09-11 17:28:16,125 - INFO - > meta_file: './IntegrationBundle/configs/metadata.json'\n", - "2023-09-11 17:28:16,125 - INFO - > config_file: './IntegrationBundle/configs/train.yaml'\n", - "2023-09-11 17:28:16,125 - INFO - > bundle_root: './IntegrationBundle'\n", - "2023-09-11 17:28:16,125 - INFO - ---\n", + "2024-09-18 08:27:35,376 - INFO - --- input summary of monai.bundle.scripts.run ---\n", + "2024-09-18 08:27:35,376 - INFO - > config_file: './IntegrationBundle/configs/train.yaml'\n", + "2024-09-18 08:27:35,376 - INFO - > meta_file: './IntegrationBundle/configs/metadata.json'\n", + "2024-09-18 08:27:35,376 - INFO - > run_id: 'train'\n", + "2024-09-18 08:27:35,376 - INFO - > bundle_root: './IntegrationBundle'\n", + "2024-09-18 08:27:35,376 - INFO - ---\n", "\n", "\n" ] @@ -464,13 +509,15 @@ "name": "stderr", "output_type": "stream", "text": [ - "Default logging file in 'configs/logging.conf' does not exist, skipping logging.\n" + "WARNING:py.warnings:The 'warn' method is deprecated, use 'warning' instead\n", + "\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ + "2024-09-18 08:27:35,377 - WARNING - Default logging file in IntegrationBundle/configs/logging.conf does not exist, skipping logging.\n", "Downloading https://www.cs.toronto.edu/~kriz/cifar-10-python.tar.gz to ./data/cifar-10-python.tar.gz\n" ] }, @@ -478,7 +525,7 @@ "name": "stderr", "output_type": "stream", "text": [ - "100%|██████████| 170498071/170498071 [00:56<00:00, 3010200.83it/s]\n" + "100%|██████████| 170498071/170498071 [00:16<00:00, 10173810.64it/s]\n" ] }, { @@ -486,18 +533,18 @@ "output_type": "stream", "text": [ "Extracting ./data/cifar-10-python.tar.gz to ./data\n", - "[1, 2000] loss: 2.162\n", - "[1, 4000] loss: 1.888\n", - "[1, 6000] loss: 1.688\n", - "[1, 8000] loss: 1.580\n", - "[1, 10000] loss: 1.487\n", - "[1, 12000] loss: 1.446\n", - "[2, 2000] loss: 1.402\n", - "[2, 4000] loss: 1.392\n", - "[2, 6000] loss: 1.339\n", - "[2, 8000] loss: 1.317\n", - "[2, 10000] loss: 1.276\n", - "[2, 12000] loss: 1.275\n", + "[1, 2000] loss: 2.215\n", + "[1, 4000] loss: 1.863\n", + "[1, 6000] loss: 1.665\n", + "[1, 8000] loss: 1.583\n", + "[1, 10000] loss: 1.534\n", + "[1, 12000] loss: 1.462\n", + "[2, 2000] loss: 1.408\n", + "[2, 4000] loss: 1.376\n", + "[2, 6000] loss: 1.346\n", + "[2, 8000] loss: 1.323\n", + "[2, 10000] loss: 1.315\n", + "[2, 12000] loss: 1.308\n", "Finished Training\n" ] } @@ -527,7 +574,7 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 11, "id": "fc35814e-625d-4871-ac1c-200a0cc562d9", "metadata": { "tags": [] @@ -563,7 +610,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 12, "id": "fb49aef2-9fb5-4e74-83d2-9da935e07648", "metadata": { "lines_to_next_cell": 2 @@ -601,7 +648,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 13, "id": "ab171286-045c-4067-a2ea-be359168869d", "metadata": { "tags": [] @@ -611,12 +658,12 @@ "name": "stdout", "output_type": "stream", "text": [ - "2023-09-11 17:31:17,644 - INFO - --- input summary of monai.bundle.scripts.run ---\n", - "2023-09-11 17:31:17,644 - INFO - > run_id: 'test'\n", - "2023-09-11 17:31:17,644 - INFO - > meta_file: './IntegrationBundle/configs/metadata.json'\n", - "2023-09-11 17:31:17,644 - INFO - > config_file: './IntegrationBundle/configs/test.yaml'\n", - "2023-09-11 17:31:17,644 - INFO - > bundle_root: './IntegrationBundle'\n", - "2023-09-11 17:31:17,644 - INFO - ---\n", + "2024-09-18 08:29:01,729 - INFO - --- input summary of monai.bundle.scripts.run ---\n", + "2024-09-18 08:29:01,729 - INFO - > config_file: './IntegrationBundle/configs/test.yaml'\n", + "2024-09-18 08:29:01,729 - INFO - > meta_file: './IntegrationBundle/configs/metadata.json'\n", + "2024-09-18 08:29:01,729 - INFO - > run_id: 'test'\n", + "2024-09-18 08:29:01,729 - INFO - > bundle_root: './IntegrationBundle'\n", + "2024-09-18 08:29:01,729 - INFO - ---\n", "\n", "\n" ] @@ -625,7 +672,23 @@ "name": "stderr", "output_type": "stream", "text": [ - "Default logging file in 'configs/logging.conf' does not exist, skipping logging.\n" + "WARNING:py.warnings:The 'warn' method is deprecated, use 'warning' instead\n", + "\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "2024-09-18 08:29:01,730 - WARNING - Default logging file in IntegrationBundle/configs/logging.conf does not exist, skipping logging.\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "WARNING:py.warnings:You are using `torch.load` with `weights_only=False` (the current default value), which uses the default pickle module implicitly. It is possible to construct malicious pickle data which will execute arbitrary code during unpickling (See https://github.com/pytorch/pytorch/blob/main/SECURITY.md#untrusted-models for more details). In a future release, the default value for `weights_only` will be flipped to `True`. This limits the functions that could be executed during unpickling. Arbitrary objects will no longer be allowed to be loaded via this mode unless they are explicitly allowlisted by the user via `torch.serialization.add_safe_globals`. We recommend you start setting `weights_only=True` for any use case where you don't have full control of the loaded file. Please open an issue on GitHub for any issues related to this experimental feature.\n", + "\n" ] }, { @@ -662,7 +725,7 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 14, "id": "1f510a23-aa3a-4e34-81e2-b4c719d87939", "metadata": { "tags": [] @@ -672,7 +735,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "Overwriting IntegrationBundle/scripts/inference.py\n" + "Writing IntegrationBundle/scripts/inference.py\n" ] } ], @@ -693,7 +756,7 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 15, "id": "7f1251be-f0dd-4cbf-8903-3f3769c8049c", "metadata": { "tags": [] @@ -703,7 +766,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "Overwriting IntegrationBundle/configs/inference.yaml\n" + "Writing IntegrationBundle/configs/inference.yaml\n" ] } ], @@ -742,7 +805,7 @@ }, { "cell_type": "code", - "execution_count": 23, + "execution_count": 16, "id": "cc2f063b-43f4-403e-b963-cf42b7e08637", "metadata": { "tags": [] @@ -791,7 +854,7 @@ }, { "cell_type": "code", - "execution_count": 24, + "execution_count": 17, "id": "28d1230e-1d3a-4929-a266-e5f763dfde7f", "metadata": { "tags": [] @@ -801,12 +864,12 @@ "name": "stdout", "output_type": "stream", "text": [ - "2023-09-11 17:54:11,793 - INFO - --- input summary of monai.bundle.scripts.run ---\n", - "2023-09-11 17:54:11,793 - INFO - > run_id: 'inference'\n", - "2023-09-11 17:54:11,793 - INFO - > meta_file: './IntegrationBundle/configs/metadata.json'\n", - "2023-09-11 17:54:11,793 - INFO - > config_file: './IntegrationBundle/configs/inference.yaml'\n", - "2023-09-11 17:54:11,793 - INFO - > bundle_root: './IntegrationBundle'\n", - "2023-09-11 17:54:11,793 - INFO - ---\n", + "2024-09-18 08:29:15,429 - INFO - --- input summary of monai.bundle.scripts.run ---\n", + "2024-09-18 08:29:15,429 - INFO - > config_file: './IntegrationBundle/configs/inference.yaml'\n", + "2024-09-18 08:29:15,430 - INFO - > meta_file: './IntegrationBundle/configs/metadata.json'\n", + "2024-09-18 08:29:15,430 - INFO - > run_id: 'inference'\n", + "2024-09-18 08:29:15,430 - INFO - > bundle_root: './IntegrationBundle'\n", + "2024-09-18 08:29:15,430 - INFO - ---\n", "\n", "\n" ] @@ -815,7 +878,23 @@ "name": "stderr", "output_type": "stream", "text": [ - "Default logging file in 'configs/logging.conf' does not exist, skipping logging.\n" + "WARNING:py.warnings:The 'warn' method is deprecated, use 'warning' instead\n", + "\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "2024-09-18 08:29:15,430 - WARNING - Default logging file in IntegrationBundle/configs/logging.conf does not exist, skipping logging.\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "WARNING:py.warnings:You are using `torch.load` with `weights_only=False` (the current default value), which uses the default pickle module implicitly. It is possible to construct malicious pickle data which will execute arbitrary code during unpickling (See https://github.com/pytorch/pytorch/blob/main/SECURITY.md#untrusted-models for more details). In a future release, the default value for `weights_only` will be flipped to `True`. This limits the functions that could be executed during unpickling. Arbitrary objects will no longer be allowed to be loaded via this mode unless they are explicitly allowlisted by the user via `torch.serialization.add_safe_globals`. We recommend you start setting `weights_only=True` for any use case where you don't have full control of the loaded file. Please open an issue on GitHub for any issues related to this experimental feature.\n", + "\n" ] }, { @@ -826,22 +905,22 @@ "test_cifar10/img01.png 8\n", "test_cifar10/img02.png 8\n", "test_cifar10/img03.png 0\n", - "test_cifar10/img04.png 6\n", - "test_cifar10/img05.png 6\n", + "test_cifar10/img04.png 4\n", + "test_cifar10/img05.png 3\n", "test_cifar10/img06.png 1\n", "test_cifar10/img07.png 4\n", - "test_cifar10/img08.png 3\n", + "test_cifar10/img08.png 5\n", "test_cifar10/img09.png 1\n", - "test_cifar10/img10.png 0\n", + "test_cifar10/img10.png 8\n", "test_cifar10/img11.png 9\n", - "test_cifar10/img12.png 6\n", + "test_cifar10/img12.png 4\n", "test_cifar10/img13.png 7\n", - "test_cifar10/img14.png 9\n", - "test_cifar10/img15.png 1\n", + "test_cifar10/img14.png 1\n", + "test_cifar10/img15.png 0\n", "test_cifar10/img16.png 5\n", "test_cifar10/img17.png 3\n", "test_cifar10/img18.png 8\n", - "test_cifar10/img19.png 4\n" + "test_cifar10/img19.png 6\n" ] } ], @@ -906,9 +985,9 @@ ], "metadata": { "kernelspec": { - "display_name": "Python [conda env:monai1]", + "display_name": "Python 3", "language": "python", - "name": "conda-env-monai1-py" + "name": "python3" }, "language_info": { "codemirror_mode": { @@ -920,7 +999,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.18" + "version": "3.10.12" } }, "nbformat": 4, diff --git a/bundle/05_spleen_segmentation_lightning.ipynb b/bundle/05_spleen_segmentation_lightning.ipynb index d9355142b7..80263435d0 100644 --- a/bundle/05_spleen_segmentation_lightning.ipynb +++ b/bundle/05_spleen_segmentation_lightning.ipynb @@ -65,36 +65,44 @@ } }, "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/usr/local/lib/python3.10/dist-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n", + " from .autonotebook import tqdm as notebook_tqdm\n" + ] + }, { "name": "stdout", "output_type": "stream", "text": [ - "MONAI version: 1.3.dev2340\n", - "Numpy version: 1.26.0\n", - "Pytorch version: 2.0.1+cu117\n", + "MONAI version: 1.4.0rc8+1.gab3ee18ba\n", + "Numpy version: 1.24.4\n", + "Pytorch version: 2.5.0a0+872d972e41.nv24.08\n", "MONAI flags: HAS_EXT = False, USE_COMPILED = False, USE_META_DICT = False\n", - "MONAI rev id: 8d89083eeb8005babd7b5f76df83c1c80276cc10\n", - "MONAI __file__: /home//miniconda3/envs/monai_tutorial/lib/python3.9/site-packages/monai/__init__.py\n", + "MONAI rev id: ab3ee18ba32bb9bd67cd3a55717684bbd343c94c\n", + "MONAI __file__: /workspace/Code/MONAI/monai/__init__.py\n", "\n", "Optional dependencies:\n", "Pytorch Ignite version: 0.4.11\n", - "ITK version: 5.3.0\n", - "Nibabel version: 5.1.0\n", - "scikit-image version: 0.21.0\n", - "scipy version: 1.11.3\n", - "Pillow version: 10.0.1\n", - "Tensorboard version: 2.14.1\n", - "gdown version: 4.7.1\n", - "TorchVision version: 0.15.2+cu117\n", - "tqdm version: 4.66.1\n", - "lmdb version: 1.4.1\n", - "psutil version: 5.9.0\n", - "pandas version: 2.1.1\n", - "einops version: 0.7.0\n", - "transformers version: 4.21.3\n", - "mlflow version: 2.7.1\n", + "ITK version: 5.4.0\n", + "Nibabel version: 5.2.1\n", + "scikit-image version: 0.23.2\n", + "scipy version: 1.14.0\n", + "Pillow version: 10.4.0\n", + "Tensorboard version: 2.16.2\n", + "gdown version: 5.2.0\n", + "TorchVision version: 0.20.0a0\n", + "tqdm version: 4.66.5\n", + "lmdb version: 1.5.1\n", + "psutil version: 6.0.0\n", + "pandas version: 2.2.2\n", + "einops version: 0.8.0\n", + "transformers version: 4.40.2\n", + "mlflow version: 2.16.0\n", "pynrrd version: 1.0.0\n", - "clearml version: 1.13.1\n", + "clearml version: 1.16.4\n", "\n", "For details about installing the optional dependencies, please visit:\n", " https://docs.monai.io/en/latest/installation.html#installing-the-recommended-dependencies\n", @@ -215,14 +223,14 @@ "name": "stderr", "output_type": "stream", "text": [ - "Task09_Spleen.tar: 1.50GB [06:23, 4.19MB/s] " + "Task09_Spleen.tar: 1.50GB [02:12, 12.2MB/s] " ] }, { "name": "stdout", "output_type": "stream", "text": [ - "2023-10-20 02:06:52,471 - INFO - Downloaded: /tmp/tmphygfp0cy/Task09_Spleen.tar\n" + "2024-09-18 08:32:51,645 - INFO - Downloaded: /tmp/tmphbjnt0zm/Task09_Spleen.tar\n" ] }, { @@ -236,8 +244,8 @@ "name": "stdout", "output_type": "stream", "text": [ - "2023-10-20 02:06:54,888 - INFO - Verified 'Task09_Spleen.tar', md5: 410d4a301da4e5b2f6f86ec3ddba524e.\n", - "2023-10-20 02:06:54,889 - INFO - Writing into directory: /tmp/tmphygfp0cy.\n" + "2024-09-18 08:32:53,738 - INFO - Verified 'Task09_Spleen.tar', md5: 410d4a301da4e5b2f6f86ec3ddba524e.\n", + "2024-09-18 08:32:53,739 - INFO - Writing into directory: /tmp/tmphbjnt0zm.\n" ] } ], @@ -298,7 +306,7 @@ " \"monai_version\": \"1.2.0\",\n", " \"pytorch_version\": \"2.0.0\",\n", " \"numpy_version\": \"1.23.5\",\n", - " \"optional_packages_version\": {},\n", + " \"required_packages_version\": {},\n", " \"name\": \"SpleenSegLightning\",\n", " \"task\": \"3D Spleen segmentation network using MONAI and Pytorch Lightning\",\n", " \"description\": \"This is a demo network for segmentation of the spleen from 3D MRI images.\",\n", @@ -779,26 +787,15 @@ "name": "stdout", "output_type": "stream", "text": [ - "workflow_name None\n", - "config_file ['./SpleenSegLightning/configs/common.yaml', './SpleenSegLightning/configs/train.yaml']\n", - "meta_file ./SpleenSegLightning/configs/metadata.json\n", - "logging_file None\n", - "init_id None\n", - "run_id train\n", - "final_id None\n", - "tracking None\n", - "bundle_dir ./SpleenSegLightning\n", - "data_dir /tmp/tmphygfp0cy/Task09_Spleen\n", - "max_epochs 1\n", - "2023-10-20 02:07:03,286 - INFO - --- input summary of monai.bundle.scripts.run ---\n", - "2023-10-20 02:07:03,286 - INFO - > config_file: ['./SpleenSegLightning/configs/common.yaml',\n", + "2024-09-18 08:33:02,488 - INFO - --- input summary of monai.bundle.scripts.run ---\n", + "2024-09-18 08:33:02,488 - INFO - > config_file: ['./SpleenSegLightning/configs/common.yaml',\n", " './SpleenSegLightning/configs/train.yaml']\n", - "2023-10-20 02:07:03,286 - INFO - > meta_file: './SpleenSegLightning/configs/metadata.json'\n", - "2023-10-20 02:07:03,286 - INFO - > run_id: 'train'\n", - "2023-10-20 02:07:03,286 - INFO - > bundle_dir: './SpleenSegLightning'\n", - "2023-10-20 02:07:03,286 - INFO - > data_dir: '/tmp/tmphygfp0cy/Task09_Spleen'\n", - "2023-10-20 02:07:03,286 - INFO - > max_epochs: 1\n", - "2023-10-20 02:07:03,286 - INFO - ---\n", + "2024-09-18 08:33:02,488 - INFO - > meta_file: './SpleenSegLightning/configs/metadata.json'\n", + "2024-09-18 08:33:02,488 - INFO - > run_id: 'train'\n", + "2024-09-18 08:33:02,488 - INFO - > bundle_dir: './SpleenSegLightning'\n", + "2024-09-18 08:33:02,488 - INFO - > data_dir: '/tmp/tmphbjnt0zm/Task09_Spleen'\n", + "2024-09-18 08:33:02,488 - INFO - > max_epochs: 1\n", + "2024-09-18 08:33:02,488 - INFO - ---\n", "\n", "\n" ] @@ -807,17 +804,45 @@ "name": "stderr", "output_type": "stream", "text": [ - "monai.bundle.workflows ConfigWorkflow.__init__:workflow_type: Current default value of argument `workflow_type=None` has been deprecated since version 1.2. It will be changed to `workflow_type=train` in version 1.4.\n", - "Default logging file in SpleenSegLightning/configs/logging.conf does not exist, skipping logging.\n", - "Loading dataset: 100%|██████████| 32/32 [00:38<00:00, 1.22s/it]\n", - "Loading dataset: 100%|██████████| 9/9 [00:08<00:00, 1.03it/s]\n", - "GPU available: True (cuda), used: True\n", - "TPU available: False, using: 0 TPU cores\n", - "IPU available: False, using: 0 IPUs\n", - "HPU available: False, using: 0 HPUs\n", - "Missing logger folder: SpleenSegLightning/logs/lightning_logs\n", - "LOCAL_RANK: 0 - CUDA_VISIBLE_DEVICES: [0,1]\n", + "WARNING:py.warnings:The 'warn' method is deprecated, use 'warning' instead\n", + "\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "2024-09-18 08:33:02,489 - WARNING - Default logging file in SpleenSegLightning/configs/logging.conf does not exist, skipping logging.\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "WARNING:py.warnings:`ModuleAvailableCache` is a special case of `RequirementCache`. Please use `RequirementCache(module=...)` instead.\n", "\n", + "Loading dataset: 100%|██████████| 32/32 [00:34<00:00, 1.07s/it]\n", + "Loading dataset: 100%|██████████| 9/9 [00:07<00:00, 1.25it/s]\n", + "INFO:pytorch_lightning.utilities.rank_zero:GPU available: True (cuda), used: True\n", + "INFO:pytorch_lightning.utilities.rank_zero:TPU available: False, using: 0 TPU cores\n", + "INFO:pytorch_lightning.utilities.rank_zero:IPU available: False, using: 0 IPUs\n", + "INFO:pytorch_lightning.utilities.rank_zero:HPU available: False, using: 0 HPUs\n", + "WARNING:pytorch_lightning.loggers.tensorboard:Missing logger folder: ./SpleenSegLightning/logs/lightning_logs\n", + "INFO:pytorch_lightning.accelerators.cuda:LOCAL_RANK: 0 - CUDA_VISIBLE_DEVICES: [0,1]\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "configure_optimizers 0.0001\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "INFO:pytorch_lightning.callbacks.model_summary:\n", " | Name | Type | Params\n", "-------------------------------------------\n", "0 | _model | UNet | 4.8 M \n", @@ -833,21 +858,20 @@ "name": "stdout", "output_type": "stream", "text": [ - "configure_optimizers 0.0001\n", - "Epoch 0: 100%|██████████| 32/32 [00:04<00:00, 6.54it/s, v_num=0]\n", + "Epoch 0: 100%|██████████| 32/32 [00:03<00:00, 10.30it/s, v_num=0]\n", "Validation: 0it [00:00, ?it/s]\u001b[A\n", "Validation: 0%| | 0/9 [00:00 config_file: ['./SpleenSegLightning/configs/common.yaml',\n", + "2024-09-18 08:34:06,379 - INFO - --- input summary of monai.bundle.scripts.run ---\n", + "2024-09-18 08:34:06,379 - INFO - > config_file: ['./SpleenSegLightning/configs/common.yaml',\n", " './SpleenSegLightning/configs/evaluate.yaml']\n", - "2023-10-20 02:08:21,419 - INFO - > meta_file: './SpleenSegLightning/configs/metadata.json'\n", - "2023-10-20 02:08:21,419 - INFO - > run_id: 'evaluate'\n", - "2023-10-20 02:08:21,420 - INFO - > bundle_dir: './SpleenSegLightning'\n", - "2023-10-20 02:08:21,420 - INFO - > data_dir: '/tmp/tmphygfp0cy/Task09_Spleen'\n", - "2023-10-20 02:08:21,420 - INFO - > ckpt_file: './SpleenSegLightning/logs/lightning_logs/version_0/checkpoints/epoch=0-step=32.ckpt'\n", - "2023-10-20 02:08:21,420 - INFO - ---\n", + "2024-09-18 08:34:06,379 - INFO - > meta_file: './SpleenSegLightning/configs/metadata.json'\n", + "2024-09-18 08:34:06,379 - INFO - > run_id: 'evaluate'\n", + "2024-09-18 08:34:06,380 - INFO - > bundle_dir: './SpleenSegLightning'\n", + "2024-09-18 08:34:06,380 - INFO - > data_dir: '/tmp/tmphbjnt0zm/Task09_Spleen'\n", + "2024-09-18 08:34:06,380 - INFO - > ckpt_file: './SpleenSegLightning/logs/lightning_logs/version_0/checkpoints/epoch=0-step=32.ckpt'\n", + "2024-09-18 08:34:06,380 - INFO - ---\n", "\n", - "\n" + "\n", + "2024-09-18 08:34:06,381 - WARNING - Default logging file in SpleenSegLightning/configs/logging.conf does not exist, skipping logging.\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ - "monai.bundle.workflows ConfigWorkflow.__init__:workflow_type: Current default value of argument `workflow_type=None` has been deprecated since version 1.2. It will be changed to `workflow_type=train` in version 1.4.\n", - "Default logging file in SpleenSegLightning/configs/logging.conf does not exist, skipping logging.\n", - "Loading dataset: 100%|██████████| 9/9 [00:08<00:00, 1.01it/s]\n", - "GPU available: True (cuda), used: True\n", - "TPU available: False, using: 0 TPU cores\n", - "IPU available: False, using: 0 IPUs\n", - "HPU available: False, using: 0 HPUs\n", - "Restoring states from the checkpoint path at ./SpleenSegLightning/logs/lightning_logs/version_0/checkpoints/epoch=0-step=32.ckpt\n", - "LOCAL_RANK: 0 - CUDA_VISIBLE_DEVICES: [0,1]\n", - "Loaded model weights from the checkpoint at ./SpleenSegLightning/logs/lightning_logs/version_0/checkpoints/epoch=0-step=32.ckpt\n" + "WARNING:py.warnings:The 'warn' method is deprecated, use 'warning' instead\n", + "\n", + "WARNING:py.warnings:`ModuleAvailableCache` is a special case of `RequirementCache`. Please use `RequirementCache(module=...)` instead.\n", + "\n", + "Loading dataset: 100%|██████████| 9/9 [00:07<00:00, 1.28it/s]\n", + "INFO:pytorch_lightning.utilities.rank_zero:GPU available: True (cuda), used: True\n", + "INFO:pytorch_lightning.utilities.rank_zero:TPU available: False, using: 0 TPU cores\n", + "INFO:pytorch_lightning.utilities.rank_zero:IPU available: False, using: 0 IPUs\n", + "INFO:pytorch_lightning.utilities.rank_zero:HPU available: False, using: 0 HPUs\n", + "INFO:pytorch_lightning.utilities.rank_zero:Restoring states from the checkpoint path at ./SpleenSegLightning/logs/lightning_logs/version_0/checkpoints/epoch=0-step=32.ckpt\n", + "WARNING:py.warnings:You are using `torch.load` with `weights_only=False` (the current default value), which uses the default pickle module implicitly. It is possible to construct malicious pickle data which will execute arbitrary code during unpickling (See https://github.com/pytorch/pytorch/blob/main/SECURITY.md#untrusted-models for more details). In a future release, the default value for `weights_only` will be flipped to `True`. This limits the functions that could be executed during unpickling. Arbitrary objects will no longer be allowed to be loaded via this mode unless they are explicitly allowlisted by the user via `torch.serialization.add_safe_globals`. We recommend you start setting `weights_only=True` for any use case where you don't have full control of the loaded file. Please open an issue on GitHub for any issues related to this experimental feature.\n", + "\n", + "INFO:pytorch_lightning.accelerators.cuda:LOCAL_RANK: 0 - CUDA_VISIBLE_DEVICES: [0,1]\n", + "INFO:pytorch_lightning.utilities.rank_zero:Loaded model weights from the checkpoint at ./SpleenSegLightning/logs/lightning_logs/version_0/checkpoints/epoch=0-step=32.ckpt\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ - "Validation DataLoader 0: 100%|██████████| 9/9 [00:14<00:00, 1.66s/it]current epoch: 0 current mean dice: 0.0184\n", - "best mean dice: 0.0184 at epoch: 0\n", - "Validation DataLoader 0: 100%|██████████| 9/9 [00:14<00:00, 1.66s/it]\n" + "Validation DataLoader 0: 100%|██████████| 9/9 [00:07<00:00, 1.13it/s]current epoch: 0 current mean dice: 0.0307\n", + "best mean dice: 0.0307 at epoch: 0\n", + "Validation DataLoader 0: 100%|██████████| 9/9 [00:07<00:00, 1.13it/s]\n" ] } ], diff --git a/runner.sh b/runner.sh index 61cb0288c9..e547e859d3 100755 --- a/runner.sh +++ b/runner.sh @@ -120,10 +120,6 @@ skip_run_papermill=("${skip_run_papermill[@]}" .*mednist_classifier_ray*) # htt skip_run_papermill=("${skip_run_papermill[@]}" .*TorchIO_MONAI_PyTorch_Lightning*) # https://github.com/Project-MONAI/tutorials/issues/1324 skip_run_papermill=("${skip_run_papermill[@]}" .*GDS_dataset*) # https://github.com/Project-MONAI/tutorials/issues/1324 skip_run_papermill=("${skip_run_papermill[@]}" .*learn2reg_nlst_paired_lung_ct.ipynb*) # slow test -skip_run_papermill=("${skip_run_papermill[@]}" .*01_bundle_intro.ipynb*) -skip_run_papermill=("${skip_run_papermill[@]}" .*02_mednist_classification.ipynb*) -skip_run_papermill=("${skip_run_papermill[@]}" .*03_mednist_classification_v2.ipynb*) -skip_run_papermill=("${skip_run_papermill[@]}" .*04_integrating_code.ipynb*) skip_run_papermill=("${skip_run_papermill[@]}" .*hovernet_torch.ipynb*) # https://github.com/Project-MONAI/tutorials/issues/1542 skip_run_papermill=("${skip_run_papermill[@]}" .*nuclei_classification_training_notebook.ipynb*) # https://github.com/Project-MONAI/tutorials/issues/1542 skip_run_papermill=("${skip_run_papermill[@]}" .*nuclick_training_notebook.ipynb*) # https://github.com/Project-MONAI/tutorials/issues/1542