大佬GitHub:https://github.com/MIC-DKFZ/nnUNet上面写得也很清楚,英文看着嫌麻烦,然后找的很棒的使用教程,最开始的入门教程看的是另一位大佬的
(四:2020.07.28)nnUNet最舒服的训练教程(让我的奶奶也会用nnUNet(上))(21.04.20更新)_花卷汤圆的博客-CSDN博客_nnunetpp简单总结一下就是:
1.默认为Ubuntu,cuda, pythorch已安装好 2.从github下载nnunet
git clone https://github.com/MIC-DKFZ/nnUNet.git
cd nnUNet
pip install -e .
pip install --upgrade git+https://github.com/FabianIsensee/hiddenlayer.git@more_plotted_details#egg=hiddenlayer
3.创建数据文件夹
主要是创建DATASET那部分的文件,然后设置路径,在home目录中找到.bashrc(ctrl+h),在文件最后输入以下,然后保存退出,并在终端输入source .bashrc更新文档。
export nnUNet_raw_data_base="/home/xx/nnUNetFrame/DATASET/nnUNet_raw"
export nnUNet_preprocessed="/home/xx/nnUNetFrame/DATASET/nnUNet_preprocessed"
export RESULTS_FOLDER="/home/xx/nnUNetFrame/DATASET/nnUNet_trained_models"
4.处理数据
1)思维导图中的小红旗可以通过以下代码生成:
from batchgenerators.utilities.file_and_folder_operations import *
import shutil
import nibabel as nib
import numpy as np
from nnunet.paths import nnUNet_raw_data
from nnunet.dataset_conversion.utils import generate_dataset_json
if __name__ == '__main__':
# this is the data folder from the kits21 github repository, see https://github.com/neheller/kits21
base = '/home/hannah/code/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task10_GJA'
# Arbitrary task id. This is just to ensure each dataset ha a unique number. Set this to whatever ([0-999]) you
# want
task_id = 10
task_name = "GJA"
resampled_path = join(base, "labelsTr")
nii_all = nib.load(os.path.join(resampled_path, "gja_001.nii.gz"))
arr_all = np.array(nii_all.dataobj)
numb = np.unique(arr_all)
label = {}
for i in range(len(numb)):
label[i] = int(numb[i])
print(label)
generate_dataset_json(output_file=join(base, 'dataset.json'),
imagesTr_dir=join(base, 'imagesTr'),
imagesTs_dir=join(base, 'imagesTs'),
modalities=('mri',),
labels=label,
dataset_name=task_name,
license='nope',
dataset_release='0')
print("done!")
2)思维导图中红圈1转换数据,在终端中输入(-i 后面为转换前的路径)
nnUNet_convert_decathlon_task -i /home/xx/nnUNetFrame/DATASET/nnUNet_raw/nnUNet_raw_data/Task01_brain
3)思维导图中黄圈2预处理数据,在终端中输入(-t 后面为任务编号)
nnUNet_plan_and_preprocess -t 1
4)思维导图中蓝圈3训练,在终端中输入(2d可换,1为任务编号,4为5折交叉验证)
nnUNet_train 2d nnUNetTrainerV2 1 4
5)思维导图中紫圈4测试,在终端中输入(分别是输入、输出路径,任务编号,模型,交叉验证)
nnUNet_prodict -i /home/XX/Task001_brain/imagesTs -o /home/XX/Task001_brain/infersTs -t 1 -m 2d -f 4
后面在跑对比实验的时候,发现好多都是在nnunet上改的,包括unet++,所以如果用惯了,在这上面跑自己的模型跟数据,会很舒服
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)