欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 文旅 > 八卦 > 复现nnunetv1和nnunetv2过程的区别

复现nnunetv1和nnunetv2过程的区别

2025/2/25 8:54:10 来源:https://blog.csdn.net/m0_55776553/article/details/144544600  浏览:    关键词:复现nnunetv1和nnunetv2过程的区别

1. 存放数据集的文件夹data内文件命名及内容不同

 nnunetv1参考:nnUNetv1在linux平台上训练自己的数据集-CSDN博客

2. data.json文件内代码不同

# nnunetv2
# import setuptools
#
# if __name__ == "__main__":
#     setuptools.setup()
#
#
# import json
#
# nnUNet_dir = '/home/chengj/student/lhh/nnU-Net/1/DATASET/'
# # 此路径根据自己实际修改
#
# def sts_json():
#     info = {
#         "channel_names": {
#             "0": "CBCT"
#         },
#         "labels": {
#             "background": 0,
#             "pore": 1
#         },
#         # "training": 194,
#         "numTraining": 194,
#         "file_ending": ".nii.gz"
#     }
#     with open(nnUNet_dir + 'nnUNet_raw/nnUNet_raw_data/Task02_pore/dataset.json',
#               'w') as f:
#         json.dump(info, f, indent=4)
#
# sts_json()# -*- coding: utf-8 -*-
"""
Created on 2023/9/26 10:02
@author: zhengjie
"""
# nnunetv1"""
创建数据集的json
""""""
创建数据集的json
"""import os
import json
from collections import OrderedDictpath_originalData = r"/home/chengj/student/lhh/nnU-Net/1/DATASET/nnUNet_raw/nnUNet_raw_data/Task02_pore"train_real_image = os.listdir((path_originalData + "/imagesTr"))
train_real_label = os.listdir((path_originalData + "/labelsTr"))
test_real_image = os.listdir((path_originalData + "/imagesTs"))# 对文件列表进行排序,以确保image和label一一对应
train_real_image = sorted(train_real_image)
train_real_label = sorted(train_real_label)
test_real_image = sorted(test_real_image)# 打印检查
print(train_real_image)
for idx in range(len(train_real_image)):print({'image': "./imagesTr/%s" % train_real_image[idx],"label": "./labelsTr/%s" % train_real_label[idx]})# 创建json文件内容
json_dict = OrderedDict()
json_dict['name'] = "pore"
json_dict['description'] = "Segmentation"
json_dict['tensorImageSize'] = "3D"
json_dict['reference'] = "see challenge website"
json_dict['licence'] = "see challenge website"
json_dict['release'] = "0.0"
json_dict['modality'] = {"0": "MRI"}# labels键在nnU-Net中应为整数键,值为字符串名称
json_dict['labels'] = {"0": "Background", "1": "pore"}json_dict['numTraining'] = len(train_real_image)
json_dict['numTest'] = len(test_real_image)
json_dict['file_ending'] = '.nii.gz'json_dict['training'] = []
for idx in range(len(train_real_image)):json_dict['training'].append({'image': "./imagesTr/%s" % train_real_image[idx],"label": "./labelsTr/%s" % train_real_label[idx]})json_dict['test'] = ["./imagesTs/%s" % i for i in test_real_image]with open(os.path.join(path_originalData, "dataset.json"), 'w') as f:json.dump(json_dict, f, indent=4, sort_keys=True)

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

热搜词