Skip to content

Commit e4cf547

Browse files
authored
Fix deprecated issue for IgniteInfo (#1849)
Set `weights_only=True` because this 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 [pytorch/SECURITY.md at main · pytorch/pytorch · GitHub 2](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. ``` ### Checks <!--- Put an `x` in all the boxes that apply, and remove the not applicable items --> - [x] Avoid including large-size files in the PR. - [x] Clean up long text outputs from code cells in the notebook. - [x] For security purposes, please check the contents and remove any sensitive info such as user names and private key. - [x] Ensure (1) hyperlinks and markdown anchors are working (2) use relative paths for tutorial repo files (3) put figure and graphs in the `./figure` folder - [x] Notebook runs automatically `./runner.sh -t <path to .ipynb file>` --------- Signed-off-by: YunLiu <[email protected]>
1 parent 1ad4540 commit e4cf547

File tree

4 files changed

+40
-37
lines changed

4 files changed

+40
-37
lines changed

active_learning/tool_tracking_al/active_learning.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -469,10 +469,10 @@ def main():
469469
variance = np.sum(np.nanvar(vol_input, axis=0), axis=0)
470470

471471
score_list.append(np.nanmean(variance))
472-
name_list.append(unl_data["image_meta_dict"]["filename_or_obj"][0])
472+
name_list.append(unl_data["image"].meta["filename_or_obj"][0])
473473
print(
474474
"Variance for image: {} is: {}".format(
475-
unl_data["image_meta_dict"]["filename_or_obj"][0], np.nanmean(variance)
475+
unl_data["image"].meta["filename_or_obj"][0], np.nanmean(variance)
476476
)
477477
)
478478

active_learning/tool_tracking_al/results_uncertainty_analysis.ipynb

Lines changed: 34 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
},
3636
{
3737
"cell_type": "code",
38-
"execution_count": 2,
38+
"execution_count": 1,
3939
"id": "d5b36e92",
4040
"metadata": {},
4141
"outputs": [],
@@ -56,37 +56,40 @@
5656
},
5757
{
5858
"cell_type": "code",
59-
"execution_count": 3,
59+
"execution_count": 2,
6060
"id": "57ef4a1b",
6161
"metadata": {},
6262
"outputs": [
6363
{
6464
"name": "stdout",
6565
"output_type": "stream",
6666
"text": [
67-
"MONAI version: 1.0.1\n",
68-
"Numpy version: 1.23.4\n",
69-
"Pytorch version: 1.13.0+cu117\n",
67+
"MONAI version: 1.4.0rc10\n",
68+
"Numpy version: 1.24.4\n",
69+
"Pytorch version: 2.5.0a0+872d972e41.nv24.08.01\n",
7070
"MONAI flags: HAS_EXT = False, USE_COMPILED = False, USE_META_DICT = False\n",
71-
"MONAI rev id: 8271a193229fe4437026185e218d5b06f7c8ce69\n",
72-
"MONAI __file__: /home/vishwesh/anaconda3/envs/mtk_py38/lib/python3.8/site-packages/monai/__init__.py\n",
71+
"MONAI rev id: cac21f6936a2e8d6e4e57e4e958f8e32aae1585e\n",
72+
"MONAI __file__: /usr/local/lib/python3.10/dist-packages/monai/__init__.py\n",
7373
"\n",
7474
"Optional dependencies:\n",
75-
"Pytorch Ignite version: 0.4.10\n",
76-
"Nibabel version: 4.0.2\n",
77-
"scikit-image version: 0.19.3\n",
78-
"Pillow version: 9.3.0\n",
79-
"Tensorboard version: 2.11.0\n",
80-
"gdown version: 4.5.3\n",
81-
"TorchVision version: 0.14.0+cu117\n",
82-
"tqdm version: 4.64.1\n",
83-
"lmdb version: 1.3.0\n",
84-
"psutil version: 5.9.0\n",
85-
"pandas version: 1.5.1\n",
86-
"einops version: 0.6.0\n",
87-
"transformers version: 4.21.3\n",
88-
"mlflow version: 2.0.1\n",
89-
"pynrrd version: 0.4.3\n",
75+
"Pytorch Ignite version: 0.4.11\n",
76+
"ITK version: 5.4.0\n",
77+
"Nibabel version: 5.2.1\n",
78+
"scikit-image version: 0.23.2\n",
79+
"scipy version: 1.13.1\n",
80+
"Pillow version: 10.4.0\n",
81+
"Tensorboard version: 2.17.0\n",
82+
"gdown version: 5.2.0\n",
83+
"TorchVision version: 0.20.0a0\n",
84+
"tqdm version: 4.66.4\n",
85+
"lmdb version: 1.5.1\n",
86+
"psutil version: 5.9.8\n",
87+
"pandas version: 2.2.2\n",
88+
"einops version: 0.7.0\n",
89+
"transformers version: 4.40.2\n",
90+
"mlflow version: 2.16.0\n",
91+
"pynrrd version: 1.0.0\n",
92+
"clearml version: 1.16.3\n",
9093
"\n",
9194
"For details about installing the optional dependencies, please visit:\n",
9295
" https://docs.monai.io/en/latest/installation.html#installing-the-recommended-dependencies\n",
@@ -136,7 +139,7 @@
136139
},
137140
{
138141
"cell_type": "code",
139-
"execution_count": 4,
142+
"execution_count": 3,
140143
"id": "1d14c99c",
141144
"metadata": {},
142145
"outputs": [
@@ -188,7 +191,7 @@
188191
").cuda()\n",
189192
"\n",
190193
"# Load Model Weights\n",
191-
"model.load_state_dict(torch.load(model_ckpt))\n",
194+
"model.load_state_dict(torch.load(model_ckpt, weights_only=True))\n",
192195
"\n",
193196
"# Please note that the model is being put to 'train' mode explicitly for Monte-Carlo simulations\n",
194197
"model.train()\n",
@@ -197,16 +200,16 @@
197200
},
198201
{
199202
"cell_type": "code",
200-
"execution_count": 5,
203+
"execution_count": 4,
201204
"id": "22b9db61",
202205
"metadata": {},
203206
"outputs": [
204207
{
205208
"name": "stdout",
206209
"output_type": "stream",
207210
"text": [
208-
"/scratch_2/robo_tool_dataset_2023/robo_tool/dv13_00098.png\n",
209-
"Variance for image: /scratch_2/robo_tool_dataset_2023/robo_tool/dv13_00098.png is: 0.0021140489261597395\n"
211+
"/workspace/Data/robo_tool/dv13_00098.png\n",
212+
"Variance for image: /workspace/Data/robo_tool/dv13_00098.png is: 0.005063239950686693\n"
210213
]
211214
},
212215
{
@@ -286,7 +289,7 @@
286289
},
287290
{
288291
"cell_type": "code",
289-
"execution_count": null,
292+
"execution_count": 5,
290293
"id": "cc913015",
291294
"metadata": {},
292295
"outputs": [],
@@ -344,9 +347,9 @@
344347
],
345348
"metadata": {
346349
"kernelspec": {
347-
"display_name": "mtk_py38",
350+
"display_name": "Python 3",
348351
"language": "python",
349-
"name": "mtk_py38"
352+
"name": "python3"
350353
},
351354
"language_info": {
352355
"codemirror_mode": {
@@ -358,7 +361,7 @@
358361
"name": "python",
359362
"nbconvert_exporter": "python",
360363
"pygments_lexer": "ipython3",
361-
"version": "3.8.15"
364+
"version": "3.10.12"
362365
}
363366
},
364367
"nbformat": 4,

pathology/nuclick/nuclei_classification_training_notebook.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@
9292
"import torch.distributed\n",
9393
"from IPython.display import Image as IImage\n",
9494
"from monai.apps.nuclick.transforms import AddLabelAsGuidanced, SetLabelClassd, SplitLabeld\n",
95-
"from monai.config import IgniteInfo, print_config\n",
95+
"from monai.config import print_config\n",
9696
"from monai.data import CacheDataset, DataLoader\n",
9797
"from monai.engines import SupervisedEvaluator, SupervisedTrainer\n",
9898
"from monai.handlers import CheckpointSaver, ConfusionMatrix, StatsHandler, ValidationHandler, from_engine\n",
@@ -112,7 +112,7 @@
112112
" SelectItemsd,\n",
113113
" ToTensord,\n",
114114
")\n",
115-
"from monai.utils import min_version, optional_import\n",
115+
"from monai.utils import min_version, optional_import, IgniteInfo\n",
116116
"from PIL import Image, ImageDraw\n",
117117
"from scipy.io import loadmat\n",
118118
"from sklearn.metrics import classification_report\n",

pathology/nuclick/nuclick_training_notebook.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@
9494
"import torch.distributed\n",
9595
"from IPython.display import Image as IImage\n",
9696
"from monai.apps.nuclick.transforms import AddPointGuidanceSignald, SplitLabeld\n",
97-
"from monai.config import IgniteInfo, print_config\n",
97+
"from monai.config import print_config\n",
9898
"from monai.data import CacheDataset, DataLoader\n",
9999
"from monai.engines import SupervisedEvaluator, SupervisedTrainer\n",
100100
"from monai.handlers import CheckpointSaver, MeanDice, StatsHandler, ValidationHandler, from_engine\n",
@@ -114,7 +114,7 @@
114114
" ScaleIntensityRangeD,\n",
115115
" SelectItemsd,\n",
116116
")\n",
117-
"from monai.utils import min_version, optional_import\n",
117+
"from monai.utils import min_version, optional_import, IgniteInfo\n",
118118
"from PIL import Image\n",
119119
"from scipy.io import loadmat\n",
120120
"from tqdm import tqdm\n",

0 commit comments

Comments
 (0)