【nnunet】个人数据训练心得

安装:

pip install nnunetv2
## 或者是把他下载下来,自行安装
git clone https://github.com/MIC-DKFZ/nnUNet.git
cd nnUNet
pip install -e .

GitHub代码:

GitHub - MIC-DKFZ/nnUNet 

十项医学分割数据集:

Medical Segmentation Decathlon 

注意:安装时一定不能使用魔法,否则会被伏地魔(False)

配置:

这里有几个铁汁,可以一起参考,以他们的为主,我的为辅,一起食用

(四:2020.07.28)nnUNet最舒服的训练教程(让我的奶奶也会用nnUNet(上))(21.04.20更新)_nnuet_花卷汤圆的博客-CSDN博客

nnUNet实战一使用预训练nnUNet模型进行推理_Tina姐的博客-CSDN博客

nnUNet 使用不完全指南(上) - No Visitor Website(这里有自定义生成json的代码)

我引用一下吧:

from collections import OrderedDict
from batchgenerators.utilities.file_and_folder_operations import save_json
   
   
def main():
    foldername = "Task128_LungLobe"
    numTraining = 80
    numTest = 6
    numClass = 6
    json_dict = OrderedDict()
    json_dict['name'] = foldername
    json_dict['description'] = foldername
    json_dict['tensorImageSize'] = "4D"
    json_dict['reference'] = "see challenge website"
    json_dict['licence'] = "see challenge website"
    json_dict['release'] = "0.0"
    json_dict['modality'] = {
        "0": "CT",
    }
    json_dict['labels'] = {i: str(i) for i in range(numClass)}
   
    json_dict['numTraining'] = numTraining
    json_dict['numTest'] = numTest
    json_dict['training'] = [{'image': "./imagesTr/LungLobe_{:0>3d}.nii.gz".format(i),
                              "label": "./labelsTr/LungLobe_{:0>3d}.nii.gz".format(i)}
                             for i in range(numTraining)]
   
    json_dict['test'] = ["./imagesTs/LungLobe_{:0>3d}.nii.gz".format(i)
                         for i in range(numTraining, numTraining+numTest)]
   
    save_json(json_dict, "./dataset.json")
   
   
if __name__ == "__main__":
    main()
   

nnUNet保姆级使用教程!从环境配置到训练与推理(新手必看) | AI技术聚合

数据文件夹:

其实就是需要自己自行手动建立几个文件夹,

【nnunet】个人数据训练心得_第1张图片

 进入红色文件夹:

【nnunet】个人数据训练心得_第2张图片

在红色文件夹,里丢如数据文件夹Task14_Vessel,这是固定的命名形式Task数字_名字

数字的话,建议是10以上,但是不能三位数,就说如果你是13的话,不要013,如果你里面的数据格式是正确的话,就是训练数据后面是_0000,nii.gz后缀的话,可以忽略这个规则,可直接跳到 --然后

因为的我的数据是这样的

 肯定是不符合格式的,所以得改,可以利用nnunet自带的代码进行更改:

nnUNet_convert_decathlon_task -i F:/data/data_1100/nnUNet_raw_data_base/nnUNet_raw/nnUNet_raw_dat
a/Task14_Vessel

这时,他会再次生成一个文件夹,这个文件夹叫Task014_Vessel,原来的叫Task14_Vessel,所以你应该懂了吧!!!

 其中这个过程中你是回遇到错误的,如果你的是Windows环境的话,解决方案,如下:

nnUNet windows 遇到的 bug_nnunet windows_*小呆的博客-CSDN博客

还有个最重的是,image和label的名字得一样

 【nnunet】个人数据训练心得_第3张图片

然后

运行指令,数字是自己任务的代号:

nnUNet_plan_and_preprocess -t 14 --verify_dataset_integrity
## 或者是
nnUNet_plan_and_preprocess -t 14 

然后又遇到报错了,

 File "D:\Python\anaconda3\envs\pytorch\lib\site-packages\nnunet\preprocessing\sanity_checks.py", line 129, in verify_dataset_integrity
    assert isfile(expected_label_file), "could not find label file for case %s. Expected file: \n%s" % (
AssertionError: could not find label file for case img_001. Expected file:

你可能感兴趣的:(python,git,github)