数据训练
1、下载相关数据(Task02_Heart)
得到这样结构的数据:
与教程中的Lung数据相符:
2、使用命令进行数据训练
python train.py --config **configs/nnunet/msd_lung/nnunet_3d_fullres_msd_lung_fold0.yml**这里放置本机的文件路径 --log_iters 20 --precision fp16 --nnunet --save_dir **output/3d_unet/fold0**这里放置训练好的文件的存放路径 --save_interval 1000 --use_vdl
3、验证
先进行单折验证,然后进行总体验证(记得更改路径):
python nnunet/single_fold_eval.py --config configs/nnunet/msd_lung/nnunet_3d_fullres_msd_lung_fold0.yml --model_path output/3d_unet/fold0/iter_30000/model.pdparams --val_save_folder output/3dfullres_val --precision fp16
python nnunet/single_fold_eval.py --config configs/nnunet/msd_lung/nnunet_3d_fullres_msd_lung_fold1.yml --model_path output/3d_unet/fold1/iter_30000/model.pdparams --val_save_folder output/3dfullres_val --precision fp16
python nnunet/single_fold_eval.py --config configs/nnunet/msd_lung/nnunet_3d_fullres_msd_lung_fold2.yml --model_path output/3d_unet/fold2/iter_30000/model.pdparams --val_save_folder output/3dfullres_val --precision fp16
python nnunet/single_fold_eval.py --config configs/nnunet/msd_lung/nnunet_3d_fullres_msd_lung_fold3.yml --model_path output/3d_unet/fold3/iter_30000/model.pdparams --val_save_folder output/3dfullres_val --precision fp16
python nnunet/single_fold_eval.py --config configs/nnunet/msd_lung/nnunet_3d_fullres_msd_lung_fold4.yml --model_path output/3d_unet/fold4/iter_30000/model.pdparams --val_save_folder output/3dfullres_val --precision fp16
python nnunet/all_folds_eval.py --gt_dir output/3dfullres_val/gt_niftis --val_pred_dir output/3dfullres_val
4、模型的集成
python nnunet/ensemble.py --ensemble_folds output/3dfullres_val output/cascade_lowres_val output/2d_val --gt_dir output/cascade_lowres_val/gt_niftis --plan_path msd_lung/preprocessed/Task006_Lung/nnUNetPlansv2.1_plans_2D.pkl --output_folder output/ensemble
5、模型的预测
预测命令:
python nnunet/predict.py --image_folder {image folder} --output_folder {output folder} --plan_path {plan path} --model_paths {model path0} {model path1} {...} --postprocessing_json_path {postprocessing.json path} --model_type 3d --disable_postprocessing --save_npz
3d预测命令:
python nnunet/predict.py --image_folder msd_lung/Task006_Lung/imagesTs --output_folder output/nnunet_predict/3d_unet --plan_path msd_lung/preprocessed/Task006_Lung/nnUNetPlansv2.1_plans_3D.pkl --model_paths output/3d_unet/fold0/iter_30000/model.pdparams output/3d_unet/fold1/iter_30000/model.pdparams output/3d_unet/fold2/iter_30000/model.pdparams output/3d_unet/fold3/iter_30000/model.pdparams output/3d_unet/fold4/iter_30000/model.pdparams --postprocessing_json_path output/3d_unet/postprocessing.json --model_type 3d --save_npz
6、模型的导出
导出命令:
python nnunet/export.py --config {config path} --save_dir {output dir} --model_path {path to pdparams}
3d导出命令:
python nnunet/export.py --config configs/nnunet/msd_lung/nnunet_3d_fullres_msd_lung_fold0.yml --save_dir output/static/3d_unet/fold0 --model_path output/3d_unet/fold0/iter_30000/model.pdparams
python nnunet/export.py --config configs/nnunet/msd_lung/nnunet_3d_fullres_msd_lung_fold1.yml --save_dir output/static/3d_unet/fold1 --model_path output/3d_unet/fold1/iter_30000/model.pdparams
python nnunet/export.py --config configs/nnunet/msd_lung/nnunet_3d_fullres_msd_lung_fold2.yml --save_dir output/static/3d_unet/fold2 --model_path output/3d_unet/fold2/iter_30000/model.pdparams
python nnunet/export.py --config configs/nnunet/msd_lung/nnunet_3d_fullres_msd_lung_fold3.yml --save_dir output/static/3d_unet/fold3 --model_path output/3d_unet/fold3/iter_30000/model.pdparams
python nnunet/export.py --config configs/nnunet/msd_lung/nnunet_3d_fullres_msd_lung_fold4.yml --save_dir output/static/3d_unet/fold4 --model_path output/3d_unet/fold4/iter_30000/model.pdparams
标签:器官,心脏,为例,--,nnunet,lung,output,model,3d
From: https://www.cnblogs.com/liuzijin/p/17418931.html