方法1: 使用pickle文件
import pickle
plan = pickle.load(open("./nnUNetPlansv2.1_plans_3D.pkl"))
如果加载中出现报错:
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x80 in position 0: invalid start byte
需要修改为:
import pickle
plan = pickle.load(open("./nnUNetPlansv2.1_plans_3D.pkl", "rb"))
方法2:使用 from batchgenerators.utilities.file_and_folder_operations import *
from batchgenerators.utilities.file_and_folder_operations import *
plans_files = "./nnUNetPlansv2.1_plans_3D.pkl"
plan = load_pickle(plans_file)
plan.keys()
# 如我们要修改bs,找到bs对应的key值
plan["plans_per_stage"][0]["batch_size"]=4
pickle.dump(plan, open("./nnUNetPlansv2.1_plans_3D_new.pkl", "wb")) # 此处wb对应读时候的rb