当前位置: 首页 > news >正文

中文网站 可以做谷歌推广吗用墨刀做视频网站

中文网站 可以做谷歌推广吗,用墨刀做视频网站,html5网站代码,四合一网站建设一、说明 了解最先进的nnU-Net以及如何将其应用于您自己的数据集所需的一切。使用nnU-Net#xff0c;这是语义图像分割中非常强大的基线。在本指南中#xff0c;您将#xff1a; 对nnU-Net的主要贡献进行简要概述。了解如何将 nnU-Net 应用于您自己的数据集。 但是#xff… 一、说明         了解最先进的nnU-Net以及如何将其应用于您自己的数据集所需的一切。使用nnU-Net这是语义图像分割中非常强大的基线。在本指南中您将 对nnU-Net的主要贡献进行简要概述。了解如何将 nnU-Net 应用于您自己的数据集。         但是我有点努力才能完全理解模型以及如何训练它并且在互联网上找不到太多帮助。现在我已经熟悉了我创建了本教程来帮助您更好地理解此模型背后的内容或者如何在您自己的数据集中使用它。 二、nnU-Net简史         nnU-Net被公认为图像分割领域最先进的模型在2D和3D图像处理方面都是一股不屈不挠的力量。它的性能非常强大可以作为对新的计算机视觉架构进行基准测试的强大基准。从本质上讲如果您正在冒险开发新颖的计算机视觉模型请将nnU-Net视为您的“超越目标”。         这个强大的工具基于U-Net模型你可以在这里找到我的教程之一烹饪你的第一个U-Net该模型于2015年首次亮相。名称“nnU-Net”代表“没有新的U-Net”这是对其设计没有引入革命性建筑改动这一事实的认可。相反它采用现有的U-Net结构并使用一组巧妙的优化策略来充分发挥其潜力。         与许多现代神经网络相反nnU-Net不依赖于残差连接密集连接或注意力机制。它的优势在于其细致的优化策略其中包括重采样、归一化、明智地选择损失函数、优化器设置、数据增强、基于补丁的推理和跨模型集成等技术。这种整体方法使nnU-Net能够突破原始U-Net架构可实现的界限。 三、探索 nnU-Net 中的各种架构 虽然它看起来像一个单一的实体但nnU-Net实际上是三种不同类型的U-Net的总称 2D、3D 和级联图片来自 nnU-Net 文章 2D U-Net 可以说是最著名的变体它直接在2D图像上运行。3D U-Net这是2D U-Net的扩展能够通过3D卷积的应用直接处理3D图像。U-Net 级联该模型生成低分辨率分割并随后对其进行优化。 这些架构中的每一个都有其独特的优势并且不可避免地具有一定的局限性。 例如使用2D U-Net进行3D图像分割似乎违反直觉但在实践中它仍然非常有效。这是通过将 3D 体积切成 2D 平面来实现的。 虽然3D U-Net可能看起来更复杂但鉴于其更高的参数数量它并不总是最有效的解决方案。特别是3D U-Net经常与各向异性作斗争当空间分辨率沿不同轴不同时例如沿x轴为1mm沿z轴为1.2mm时就会发生这种情况。 U-Net Cascade变体在处理大图像尺寸时变得特别方便。它采用初步模型来压缩图像然后是输出低分辨率分割的标准3D U-Net。然后对生成的预测进行放大从而产生精细、全面的输出。 图片来自nnU-Net文章 通常该方法涉及在nnU-Net框架内训练所有三个模型变体。接下来的步骤可能是选择三者中最好的表演者或采用合奏技术。其中一种技术可能涉及整合2D和3D U-Net的预测。 但是值得注意的是此过程可能非常耗时而且需要金钱因为您需要 GPU 积分。如果您的约束只允许训练单个模型请不要担心。您可以选择只训练一个模型因为集成模型只带来非常微不足道的收益。 下表说明了与特定数据集相关的性能最佳的模型变体 图片来自nnU-Net文章 3.1 网络拓扑的动态适应         鉴于图像大小的显着差异考虑肝脏图像的中位数形状为482×512×512而海马图像的中位数形状为36×50×35nnU-Net智能地调整输入补丁大小和每个轴的池化操作次数。这实质上意味着自动调整每个数据集的卷积层数从而促进空间信息的有效聚合。除了适应不同的图像几何形状外该模型还考虑了技术限制例如可用内存。         需要注意的是该模型不会直接对整个图像执行分割而是对具有重叠区域的精心提取的补丁执行分割。随后对这些补丁的预测进行平均从而得出最终的分割输出。         但是拥有较大的补丁意味着更多的内存使用并且批大小也会消耗内存。采取的权衡是始终优先考虑补丁大小模型的容量而不是批量大小仅对优化有用。         以下是用于计算最佳补丁大小和批大小的启发式算法         批次和补丁大小的启发式规则图片来自nnU-Net文章         这是不同数据集和输入维度的样子 输入图像分辨率函数中的体系结构图片来自nnU-Net文章 伟大现在让我们快速回顾一下nnU-Net中使用的所有技术 3.2 训练 所有模型都是从头开始训练的并在训练集上使用五重交叉验证进行评估这意味着原始训练数据集被随机分成五个相等的部分或“折叠”。在此交叉验证过程中其中四个折叠用于模型的训练其余一个折叠用于评估或测试。然后重复此过程五次五个折叠中的每一个都恰好用作评估集一次。 对于损失我们使用骰子和交叉熵损失的组合。这是图像分割中非常常见的损失。有关V-Net中骰子损失的更多详细信息U-Net大人物的兄弟 3.3 数据增强技术 nnU-Net有一个非常强大的数据增强管道。作者使用随机旋转、随机缩放、随机弹性变形、伽马校正和镜像。 注意您可以通过修改源代码来添加自己的转换 弹性变形来自本文 图片来自 OpenCV 库 3.4 基于补丁的推理 因此正如我们所说该模型不会直接在全分辨率图像上进行预测而是在提取的补丁上进行预测然后聚合预测。 这是它的样子 基于补丁的推理图片来源作者 注意图片中心的补丁比侧面的补丁具有更大的权重因为它们包含更多信息并且模型在其上表现更好 3.5 成对模型集成 模型组合图片由作者提供 因此如果您记得不错我们最多可以训练 3 种不同的模型2D、3D 和级联。但是当我们进行推理时我们一次只能使用一个模型对吗 事实证明不不同的模型有不同的优点和缺点。因此我们实际上可以组合几个模型的预测这样如果一个模型非常自信我们就会优先考虑它的预测。 nnU-Net 测试了 2 个可用模型中 3 个模型的每个组合并选择了最好的模型。 在实践中有两种方法可以做到这一点 硬投票 对于每个像素我们查看 2 个模型输出的所有概率并选取概率最高的类。 软投票对于每个像素我们平均模型的概率然后我们以最大概率取类。 四、实际实施 在我们开始之前您可以在此处下载数据集并关注Google Collab笔记本。 如果你对第一部分一无所知不用担心这是实际的部分你只需要跟着我你还是会得到最好的结果。 您需要一个 GPU 来训练模型否则它不起作用。您可以在本地或在Google Collab上进行不要忘记更改GPU运行时 因此首先您需要准备好一个包含输入图像及其相应分割的数据集。您可以按照我的教程下载这个用于 3D 大脑分割的现成数据集然后您可以将其替换为您自己的数据集。 4.1 下载数据 首先您应该下载数据并将其放置在数据文件夹中方法是将包含分段的两个文件夹命名为“input”和“ground_truth”。 在本教程的其余部分我将使用 MindBoggle 数据集进行图像分割。您可以在此Google云端硬盘上下载它 我们得到了大脑的3D MRI扫描我们希望分割白质和灰质 图片来源作者 它应该看起来像这样 树图片由作者提供 4.2 设置主目录 如果您在 Google Colab 上运行此操作请将 collab True否则设置 collab False collab Trueimport os import shutil #libraries from collections import OrderedDict import json import numpy as np#visualization of the dataset import matplotlib.pyplot as plt import nibabel as nibif collab:from google.colab import drivedrive.flush_and_unmount()drive.mount(/content/drive, force_remountTrue)# Change neurosciences-segmentation to the name of your project folderroot_dir /content/drive/MyDrive/neurosciences-segmentationelse:# get the dir of the parent dirroot_dir os.getcwd()input_dir os.path.join(root_dir, data/input) segmentation_dir os.path.join(root_dir, data/ground_truth)my_nnunet_dir os.path.join(root_dir,my_nnunet) print(my_nnunet_dir) 现在我们将定义一个为我们创建文件夹的函数 def make_if_dont_exist(folder_path,overwriteFalse):creates a folder if it does not existsinput:folder_path : relative path of the folder which needs to be createdover_write :(default: False) if True overwrite the existing folderif os.path.exists(folder_path):if not overwrite:print(f{folder_path} exists.)else:print(f{folder_path} overwritten)shutil.rmtree(folder_path)os.makedirs(folder_path)else:os.makedirs(folder_path)print(f{folder_path} created!) 我们使用此功能来创建我们的“my_nnunet”文件夹其中将保存所有内容 os.chdir(root_dir) make_if_dont_exist(my_nnunet, overwriteFalse) os.chdir(my_nnunet) print(fCurrent working directory: {os.getcwd()}) 4.3 库安装 ·        现在我们将安装所有要求。首先让我们安装 nnunet 库。如果您在笔记本中请在单元格中运行以下命令 !pip install nnunet 否则您可以直接从终端安装 nnunet pip install nnunet 现在我们要克隆nnUnet git存储库和NVIDIA apex。它包含训练脚本以及 GPU 加速器。 !git clone https://github.com/MIC-DKFZ/nnUNet.git !git clone https://github.com/NVIDIA/apex# repository dir is the path of the github folder respository_dir os.path.join(my_nnunet_dir,nnUNet) os.chdir(respository_dir) !pip install -e !pip install --upgrade githttps://github.com/nanohanno/hiddenlayer.gitbugfix/get_trace_graph#egghiddenlayer 4.4 文件夹的创建         nnUnet 需要文件夹的非常具体的结构。 task_name Task001 #change here for different task name# We define all the necessary paths nnunet_dir nnUNet/nnunet/nnUNet_raw_data_base/nnUNet_raw_data task_folder_name os.path.join(nnunet_dir,task_name) train_image_dir os.path.join(task_folder_name,imagesTr) # path to training images train_label_dir os.path.join(task_folder_name,labelsTr) # path to training labels test_dir os.path.join(task_folder_name,imagesTs) # path to test images main_dir os.path.join(my_nnunet_dir,nnUNet/nnunet) # path to main directory trained_model_dir os.path.join(main_dir, nnUNet_trained_models) # path to trained models 最初nnU-Net是为具有不同任务的十项全能挑战而设计的。如果您有不同的任务只需为所有任务运行此单元格。 # Creation of all the folders overwrite False # Set this to True if you want to overwrite the folders make_if_dont_exist(task_folder_name,overwrite overwrite) make_if_dont_exist(train_image_dir, overwrite overwrite) make_if_dont_exist(train_label_dir, overwrite overwrite) make_if_dont_exist(test_dir,overwrite overwrite) make_if_dont_exist(trained_model_dir, overwriteoverwrite) 你现在应该有一个这样的结构 图片来源作者 4.5 设置环境变量 脚本需要知道您raw_data放在哪里在哪里可以找到预处理的数据以及必须保存结果的位置。 os.environ[nnUNet_raw_data_base] os.path.join(main_dir,nnUNet_raw_data_base) os.environ[nnUNet_preprocessed] os.path.join(main_dir,preprocessed) os.environ[RESULTS_FOLDER] trained_model_dir 4.6 将文件移动到正确的存储库中 我们定义了一个函数它将我们的图像移动到 nnunet 文件夹中的正确存储库 def copy_and_rename(old_location,old_file_name,new_location,new_filename,delete_original False):shutil.copy(os.path.join(old_location,old_file_name),new_location)os.rename(os.path.join(new_location,old_file_name),os.path.join(new_location,new_filename))if delete_original:os.remove(os.path.join(old_location,old_file_name)) 现在让我们对输入和真实图像运行此函数 list_of_all_files os.listdir(segmentation_dir) list_of_all_files [file_name for file_name in list_of_all_files if file_name.endswith(.nii.gz)]for file_name in list_of_all_files:copy_and_rename(input_dir,file_name,train_image_dir,file_name)copy_and_rename(segmentation_dir,file_name,train_label_dir,file_name)         现在我们必须重命名文件以接受nnUnet格式例如subject.nii.gz将成为subject_0000.nii.gz def check_modality(filename):check for the existence of modalityreturn False if modality is not found else Trueend filename.find(.nii.gz)modality filename[end-4:end]for mod in modality:if not(ord(mod)48 and ord(mod)57): #if not in 0 to 9 digitsreturn Falsereturn Truedef rename_for_single_modality(directory):for file in os.listdir(directory):if check_modality(file)False:new_name file[:file.find(.nii.gz)]_0000.nii.gzos.rename(os.path.join(directory,file),os.path.join(directory,new_name))print(fRenamed to {new_name})else:print(fModality present: {file})rename_for_single_modality(train_image_dir) # rename_for_single_modality(test_dir) 4.7 设置 JSON 文件 我们快完成了您主要需要修改两件事 模态如果是 CT 或 MRI这会改变标准化标签输入您自己的类别 overwrite_json_file True #make it True if you want to overwrite the dataset.json file in Task_folder json_file_exist Falseif os.path.exists(os.path.join(task_folder_name,dataset.json)):print(dataset.json already exist!)json_file_exist Trueif json_file_existFalse or overwrite_json_file:json_dict OrderedDict()json_dict[name] task_namejson_dict[description] Segmentation of T1 Scans from MindBogglejson_dict[tensorImageSize] 3Djson_dict[reference] see challenge websitejson_dict[licence] see challenge websitejson_dict[release] 0.0######################## MODIFY THIS #########################you may mention more than one modalityjson_dict[modality] {0: MRI}#labels1 should be mentioned for all the labels in the datasetjson_dict[labels] {0: Non Brain,1: Cortical gray matter,2: Cortical White matter,3 : Cerebellum gray ,4 : Cerebellum white}#############################################################train_ids os.listdir(train_label_dir)test_ids os.listdir(test_dir)json_dict[numTraining] len(train_ids)json_dict[numTest] len(test_ids)#no modality in train image and labels in dataset.jsonjson_dict[training] [{image: ./imagesTr/%s % i, label: ./labelsTr/%s % i} for i in train_ids]#removing the modality from test image name to be saved in dataset.jsonjson_dict[test] [./imagesTs/%s % (i[:i.find(_0000)].nii.gz) for i in test_ids]with open(os.path.join(task_folder_name,dataset.json), w) as f:json.dump(json_dict, f, indent4, sort_keysTrue)if os.path.exists(os.path.join(task_folder_name,dataset.json)):if json_file_existFalse:print(dataset.json created!)else:print(dataset.json overwritten!) 4.8 预处理 nnU-Net 格式的数据 这将为 nnU-Net 格式创建数据集 # -t 1 means Task001, if you have a different task change it !nnUNet_plan_and_preprocess -t 1 --verify_dataset_integrity 4.9 训练模型 我们现在已准备好训练模型 要训练 3D U-Net请执行以下操作 #train 3D full resolution U net !nnUNet_train 3d_fullres nnUNetTrainerV2 1 0 --npz 要训练 2D U-Net请执行以下操作 # train 2D U net !nnUNet_train 2d nnUNetTrainerV2 1 0 --npz 训练级联模型 # train 3D U-net cascade !nnUNet_train 3d_lowres nnUNetTrainerV2CascadeFullRes 1 0 --npz !nnUNet_train 3d_fullres nnUNetTrainerV2CascadeFullRes 1 0 --npz 注意如果您暂停编辑并想要恢复它请在末尾添加“-c”以表示“继续”。 例如 #train 3D full resolution U net !nnUNet_train 3d_fullres nnUNetTrainerV2 1 0 --npz 4.10 推理 现在我们可以运行推理 result_dir os.path.join(task_folder_name, nnUNet_Prediction_Results) make_if_dont_exist(result_dir, overwriteTrue)# -i is the input folder # -o is where you want to save the predictions # -t 1 means task 1, change it if you have a different task number # Use -m 2d, or -m 3d_fullres, or -m 3d_cascade_fullres !nnUNet_predict -i /content/drive/MyDrive/neurosciences-segmentation/my_nnunet/nnUNet/nnunet/nnUNet_raw_data_base/nnUNet_raw_data/Task001/imagesTs -o /content/drive/MyDrive/neurosciences-segmentation/my_nnunet/nnUNet/nnunet/nnUNet_raw_data_base/nnUNet_raw_data/Task001/nnUNet_Prediction_Results -t 1 -tr nnUNetTrainerV2 -m 2d -f 0 --num_threads_preprocessing 1 五、预测的可视化         首先让我们检查一下训练损失。这看起来非常健康我们的骰子分数 0.9绿色曲线。 这对于如此少的工作和3D神经影像分割任务来说确实非常出色。 训练损失、测试损失、验证骰子、作者图片 让我们看一个示例 对MindBoggle数据集的预测图片由作者提供 结果确实令人印象深刻很明显该模型已经有效地学会了如何高精度地分割大脑图像。虽然可能存在一些小瑕疵但重要的是要记住图像分割领域正在迅速发展我们正在朝着完美迈出重大步伐。 将来还有进一步优化nnU-Net性能的空间但这将是另一篇文章。 如果你觉得这篇文章很有见地和好处请考虑关注我对深度学习的世界进行更深入的探索。您的支持帮助我继续制作有助于我们集体理解的内容。 无论您是有反馈想法要分享想与我合作还是只是想打个招呼请填写下面的表格让我们开始对话。 打招呼 不要犹豫留下鼓掌或关注我更多 六、引用 RonnebergerO.FischerP.和BroxT.2015。U-net用于生物医学图像分割的卷积网络。医学图像计算和计算机辅助干预国际会议第234-241页。斯普林格湛。Isensee F. Jaeger P. F. Kohl S. A. Petersen J. Maier-Hein K. H. 2021.nnU-Net一种基于深度学习的生物医学图像分割的自配置方法。自然方法182203-211。Ioffe S. Szegedy C. 2015.批量规范化通过减少内部协变量偏移来加速深度网络训练。arXiv预印本arXiv1502.03167。UlyanovD.VedaldiA.和LempitskyV.2016。实例规范化快速风格化的缺失要素。arXiv预印本arXiv1607.08022。MindBoggle 数据集 弗朗索瓦·波彻
http://www.dnsts.com.cn/news/259691.html

相关文章:

  • 网站设计建设 公司湘潭网站建设 水平磐石网络
  • 做网站一天忙吗域名icp备案查询
  • 绵阳网站建设开发哪做网站便宜
  • 保险网站建设WordPress主题怎么保存
  • 租号网站怎么做的icp备案网站更名
  • 贵州省城乡住房建设厅网站关于建设网站的情况说明
  • 360免费创建个人网站耳机 东莞网站建设
  • 宿迁网站市场调研报告的基本框架
  • 四川住房和城乡建设厅网站不能进入wordpress显示作者信息
  • 免费域名注册微信下载海南seo排名优化公司
  • 房地产网站源码jsp与网站开发期末试题
  • 用scala做网站百度投放广告流程
  • 罗湖商城网站设计制作东莞常平天气
  • 重庆网站制作技术dede旅游网站源码 多城市
  • 坪山企业网站建设自适应网站建设
  • 如何批量建站去年做哪些网站能致富
  • 桂林做手机网站wordpress 主题 破解
  • 做it行业招标网站有哪些seo诊断工具有哪些
  • 建设网站平台的章程无锡企业网站建设报价
  • 广州天与地网站建设上海线上引流推广
  • 多种东莞微信网站建设房地产市场现状
  • 如何搭建网站赚钱需要推广的app在哪里找
  • 怎么去掉网站首页尾缀微信如何制作一个网页
  • 开发app和做网站小城镇建设的网站中的主要观点
  • 做设计需要知道的几个网站吗北京工商注册信息查询
  • 摄影做网站号卡分销系统
  • 佛山网站建设专业交互设计网站案例
  • 公司支付网站建设费进什么费用德州网站建设 绮畅
  • 怎么提升网站的流量新公司名字大全参考
  • 怎么在网站上投放广告工业园区网站建设