MONAI学习

Posted on Aug 27, 2024

概述

发现 MONAI 有包含 3d 语义分割的全套件,还支持 3d-slicer 等工具,值得研究一下。

数据问题

初步试了一下,数据大部分下载都非常麻烦,需要给数据方递交申请表等审核等等。国外对这些病历照片还是比较重视的,大部分类似的数据都不容易获取。

基础流程了

运行测试实例

需要运行一个测试的实例,目的是为了在测试实例的基础上,通过修改数据的格式,可以将我们自己的模型训练 run 起来,参考这个测试实例 Task09_Spleen。解决了数据问题之后,一开始在容器里测试了很久,最后发现是内存的配置导致在容器里没法把训练跑起来。

cd /tf/oral/3d/tutorials/auto3dseg/tasks/msd/Task09_Spleen
python -m monai.apps.auto3dseg AutoRunner run --input='./input.yaml'

显卡是比较一般了,运行可以想象会非常慢,可能开始要用公司资源做测试了。

  warn_deprecated(argname, msg, warning_category)
<string>:1: FutureWarning: 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.
/tf/oral/3d/tutorials/auto3dseg/tasks/msd/Task09_Spleen/work_dir/dints_0/scripts/train.py:499: FutureWarning: `torch.cuda.amp.GradScaler(args...)` is deprecated. Please use `torch.amp.GradScaler('cuda', args...)` instead.
  scaler = GradScaler()
dints_0 - training ...:   0%|                                                                                                                                                                                                                                                                | 0/57 [00:00<?, ?round/s]dints_0 - training ...:   2%|████▎                                                                                                                                                                                                                                              | 1/57 [54:51<51:12:06, 3291.54s/round]

3200s/round,一共60 round 左右,这样算下来这个测试得跑 52 个小时,看来数据量上来了,算力是不够了,未来可能要在算力上投入一些成本了。

参考资料

  1. monai.io
  2. MONAI Label安装流程及使用攻略
  3. MONAI Label–使用AI加速你的分割标注
  4. MONAI label自动化标注工具