nnunetv2系列: 导出模型参数文件和配置文件成zip压缩包
根据nnUNetv2_export_model_to_zip
命令在pyproject.toml
文件中查找到nnUNetv2_export_model_to_zip = "nnunetv2.model_sharing.entry_points:export_pretrained_model_entry"
信息,那么在nnunetv2.model_sharing.entry_points.py
文件中可以看到export_pretrained_model_entry
定义的相关的参数和默认值。
我们也可以通过命令nnUNetv2_export_model_to_zip -h
直接获取相关的参数信息。
这里仅提供五折中的一折的模型参数文件和配置文件,如果需要全部的模型参数文件和配置文件,需要修改nnUNetv2_export_model_to_zip
命令中的-f
参数,默认是五折。
查看参数和说明
nnUNetv2_export_model_to_zip -h
# 运行结果:
# usage: nnUNetv2_export_model_to_zip [-h] -d D -o O [-c C [C ...]] [-tr TR] [-p P] [-f F [F ...]] [-chk CHK [CHK ...]] [--not_strict]
# [--exp_cv_preds]
# Use this to export a trained model as a zip file.
# options:
# -h, --help show this help message and exit
# -d D Dataset name or id
# -o O Output file name
# -c C [C ...] List of configuration names
# -tr TR Trainer class
# -p P plans identifier
# -f F [F ...] list of fold ids
# -chk CHK [CHK ...] Lis tof checkpoint names to export. Default: checkpoint_final.pth
# --not_strict Set this to allow missing folds and/or configurations
# --exp_cv_preds Set this to export the cross-validation predictions as well
终端执行命令示例
nnUNetv2_export_model_to_zip \
-d 500 \
-c 2d \
-tr nnUNetTrainer \
-p nnUNetPlans \
-f 0 \
-chk checkpoint_best.pth \
-o /home/xxx/nnUNet/nnUNet_results/xxx/export_model.zip
# 提示信息
# Configuration 2d
# Exporting fold_0
# No ensemble directory found for task xxx
export_model.zip目录结构
xxx/
├── nnUNetTrainer__nnUNetPlans__2d/
│ ├── fold_0/
│ ├── checkpoint_best.pth
│ ├── debug.json
│ ├── progress.png
| ├── validation/
│ │ ├── summary.json
│ ├── dataset_fingerprint.json
│ ├── dataset.json
│ ├── plans.json