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

【原创】nnUnet V1在win11下的安装与配置

安装之前可以先了解一下论文的主要内容,便于之后网络训练与推理,调试程序。

论文地址:nnU-Net: a self-configuring method for deep learning-based biomedical image segmentation | Nature Methods

也可以从其他博客快速浏览:论文解读- nnU-Net: Self-adapting Framework for U-Net-Based Medical Image Segmentation(附实现教程)_nnunet self adaptinng-CSDN博客

如果想跟官网github一样在ubuntu下安装参考:nnUNet保姆级使用教程!从环境配置到训练与推理(新手必看)-CSDN博客


1.本博客是在win11安装,前期Anaconda的虚拟环境自己配置好,然后下载好nnUnet v1的安装包,然后解压在该目中运行:

pip install -e .

如果需要观察模型的网络结构图可以安装hiddenlayer:

nnUNet给出的指令:

pip install --upgrade git+https://github.com/FabianIsensee/hiddenlayer.git@more_plotted_details#egg=hiddenlayer

 上面指令自己运行报错:

× git clone --filter=blob:none --quiet https://github.com/FabianIsensee/hiddenlayer.git 'C:\Users\Administrator\AppData\Local\Temp\pip-install-dh84s7ac\hiddenlayer_be2e7545caf44fbeae10f5b0cfd81e30' did not run successfully,可能是网络原因。干脆直接从hiddenlayer官网的指令进行安装(顺利安装):

pip install git+https://github.com/waleedka/hiddenlayer.git

 2.开始准备推理的数据,注意它的格式要求,开始体验一下如何用官网模型进行infer使用:

查看nnUNet提供的预训练好的模型:

nnUNet_print_available_pretrained_models
Task001_BrainTumour
Brain Tumor Segmentation.
Segmentation targets are edema, enhancing tumor and necrosis,
Input modalities are 0: FLAIR, 1: T1, 2: T1 with contrast agent, 3: T2.
Also see Medical Segmentation Decathlon, http://medicaldecathlon.com/Task002_Heart
Left Atrium Segmentation.
Segmentation target is the left atrium,
Input modalities are 0: MRI.
Also see Medical Segmentation Decathlon, http://medicaldecathlon.com/Task003_Liver
Liver and Liver Tumor Segmentation.
Segmentation targets are liver and tumors,
Input modalities are 0: abdominal CT scan.
Also see Medical Segmentation Decathlon, http://medicaldecathlon.com/Task004_Hippocampus
Hippocampus Segmentation.
Segmentation targets posterior and anterior parts of the hippocampus,
Input modalities are 0: MRI.
Also see Medical Segmentation Decathlon, http://medicaldecathlon.com/Task005_Prostate
Prostate Segmentation.
Segmentation targets are peripheral and central zone,
Input modalities are 0: T2, 1: ADC.
Also see Medical Segmentation Decathlon, http://medicaldecathlon.com/Task006_Lung
Lung Nodule Segmentation.
Segmentation target are lung nodules,
Input modalities are 0: abdominal CT scan.
Also see Medical Segmentation Decathlon, http://medicaldecathlon.com/Task007_Pancreas
Pancreas Segmentation.
Segmentation targets are pancras and pancreas tumor,
Input modalities are 0: abdominal CT scan.
Also see Medical Segmentation Decathlon, http://medicaldecathlon.com/Task008_HepaticVessel
Hepatic Vessel Segmentation.
Segmentation targets are hepatic vesels and liver tumors,
Input modalities are 0: abdominal CT scan.
Also see Medical Segmentation Decathlon, http://medicaldecathlon.com/Task009_Spleen
Spleen Segmentation.
Segmentation target is the spleen,
Input modalities are 0: abdominal CT scan.
Also see Medical Segmentation Decathlon, http://medicaldecathlon.com/Task010_Colon
Colon Cancer Segmentation.
Segmentation target are colon caner primaries,
Input modalities are 0: CT scan.
Also see Medical Segmentation Decathlon, http://medicaldecathlon.com/Task017_AbdominalOrganSegmentation
Multi-Atlas Labeling Beyond the Cranial Vault - Abdomen.
Segmentation targets are thirteen different abdominal organs,
Input modalities are 0: abdominal CT scan.
Also see https://www.synapse.org/#!Synapse:syn3193805/wiki/217754Task024_Promise
Prostate MR Image Segmentation 2012.
Segmentation target is the prostate,
Input modalities are 0: T2.
Also see https://promise12.grand-challenge.org/Task027_ACDC
Automatic Cardiac Diagnosis Challenge.
Segmentation targets are right ventricle, left ventricular cavity and left myocardium,
Input modalities are 0: cine MRI.
Also see https://acdc.creatis.insa-lyon.fr/Task029_LiTS
Liver and Liver Tumor Segmentation Challenge.
Segmentation targets are liver and liver tumors,
Input modalities are 0: abdominal CT scan.
Also see https://competitions.codalab.org/competitions/17094Task035_ISBILesionSegmentation
Longitudinal multiple sclerosis lesion segmentation Challenge.
Segmentation target is MS lesions,
input modalities are 0: FLAIR, 1: MPRAGE, 2: proton density, 3: T2.
Also see https://smart-stats-tools.org/lesion-challengeTask038_CHAOS_Task_3_5_Variant2
CHAOS - Combined (CT-MR) Healthy Abdominal Organ Segmentation Challenge (Task 3 & 5).
Segmentation targets are left and right kidney, liver, spleen,
Input modalities are 0: T1 in-phase, T1 out-phase, T2 (can be any of those)
Also see https://chaos.grand-challenge.org/Task048_KiTS_clean
Kidney and Kidney Tumor Segmentation Challenge. Segmentation targets kidney and kidney tumors, Input modalities are 0: abdominal CT scan. Also see https://kits19.grand-challenge.org/Task055_SegTHOR
SegTHOR: Segmentation of THoracic Organs at Risk in CT images.
Segmentation targets are aorta, esophagus, heart and trachea,
Input modalities are 0: CT scan.
Also see https://competitions.codalab.org/competitions/21145Task061_CREMI
MICCAI Challenge on Circuit Reconstruction from Electron Microscopy Images (Synaptic Cleft segmentation task).
Segmentation target is synaptic clefts,
Input modalities are 0: serial section transmission electron microscopy of neural tissue.
Also see https://cremi.org/Task075_Fluo_C3DH_A549_ManAndSim
Fluo-C3DH-A549-SIM and Fluo-C3DH-A549 datasets of the cell tracking challenge. Segmentation target are C3DH cells in fluorescence microscopy images.
Input modalities are 0: fluorescence_microscopy
Also see http://celltrackingchallenge.net/Task076_Fluo_N3DH_SIM
Fluo-N3DH-SIM dataset of the cell tracking challenge. Segmentation target are N3DH cells and cell borders in fluorescence microscopy images.
Input modalities are 0: fluorescence_microscopy
Also see http://celltrackingchallenge.net/
Note that the segmentation output of the models are cell center and cell border. These outputs mus tbe converted to an instance segmentation for the challenge.
See https://github.com/MIC-DKFZ/nnUNet/blob/master/nnunet/dataset_conversion/Task076_Fluo_N3DH_SIM.pyTask082_BraTS2020
Brain tumor segmentation challenge 2020 (BraTS)
Segmentation targets are 0: background, 1: edema, 2: necrosis, 3: enhancing tumor
Input modalities are 0: T1, 1: T1ce, 2: T2, 3: FLAIR (MRI images)
Also see https://www.med.upenn.edu/cbica/brats2020/Task089_Fluo-N2DH-SIM_thickborder_time
Fluo-N2DH-SIM dataset of the cell tracking challenge. Segmentation target are nuclei of N2DH cells and cell borders in fluorescence microscopy images.
Input modalities are 0: t minus 4, 0: t minus 3, 0: t minus 2, 0: t minus 1, 0: frame of interest
Note that the input channels are different time steps from a time series acquisition
Note that the segmentation output of the models are cell center and cell border. These outputs mus tbe converted to an instance segmentation for the challenge.
See https://github.com/MIC-DKFZ/nnUNet/blob/master/nnunet/dataset_conversion/Task089_Fluo-N2DH-SIM.py
Also see http://celltrackingchallenge.net/Task114_heart_MNMs
Cardiac MRI short axis images from the M&Ms challenge 2020.
Input modalities are 0: MRI
See also https://www.ub.edu/mnms/
Note: Labels of the M&Ms Challenge are not in the same order as for the ACDC challenge.
See https://github.com/MIC-DKFZ/nnUNet/blob/master/nnunet/dataset_conversion/Task114_heart_mnms.pyTask115_COVIDSegChallenge
Covid lesion segmentation in CT images. Data originates from COVID-19-20 challenge.
Predicted labels are 0: background, 1: covid lesion
Input modalities are 0: CT
See also https://covid-segmentation.grand-challenge.org/Task135_KiTS2021
Kidney and kidney tumor segmentation in CT images. Data originates from KiTS2021 challenge.
Predicted labels are 0: background, 1: kidney, 2: tumor, 3: cyst
Input modalities are 0: CT
See also https://kits21.kits-challenge.org/Task169_BrainTumorPET
Brain tumor segmentation in FET PET images. Data originates from the Research Center Jülich, Germany.
Predicted labels are 0: background, 1: tumor
Input modalities are 0: FET PET
See also (NOT YET AVAILABLE)

 需要类似于ubuntu系统下一样,设置环境临时变量:

set RESULTS_FOLDER=自己的硬盘根目录\nnUNet-nnunetv1\dataset\nnUNet_trained_models
set nnUNet_raw_data_base=自己的硬盘根目录\nnUNet-nnunetv1\dataset\nnUNet_raw
set nnUNet_preprocessed=自己的硬盘根目录\nnUNet-nnunetv1\dataset\nnUNet_preprocessed是否设置成功,可以通过
echo %RESULTS_FOLDER%
echo %nnUNet_raw_data_base%
echo %nnUNet_preprocessed%

3. 推理之前需要将数据按照nnUNet要求进行格式转换:

由于ubuntu跟win11系统路径格式不一样(不懂可以看下区别),需要提前修改相应的程序:

1)nnUNet_convert_decathlon_task.py中22行的“folder.split('/')[-1]”改成“folder.split('\\')[-1]”。

2)utils.py中40行的input_folder.split("/")[-1]改成input_folder.split("\\")[-1]

3) common_utils.py中26行的filename.split("/")[-1]改成filename.split("\\")[-1]

然后,根据数据格式转换说明:

nnUNet_convert_decathlon_task -i FOLDER_TO_TASK_AS_DOWNLOADED_FROM_MSD -p NUM_PROCESSES

具体指令:

nnUNet_convert_decathlon_task -i 自己存放数据集的路径\Task05_Prostate

运行结果目录如下:

以imagesTs为例:

按照官网进行数据预处理:

nnUNet_plan_and_preprocess -t XXX --verify_dataset_integrity

 XXX表示任务号;

nnUNet_plan_and_preprocess -t 005 --verify_dataset_integrity

4. 运行推理程序:

范例:
nnUNet_predict -i INPUT_FOLDER -o OUTPUT_FOLDER -t TASK_NAME_OR_ID 
-m CONFIGURATION --save_npz

 这里需要注意一定要修改cropping.py中123行的i.split("/")[-1][:-4],将其修改为i.split("\\")[-1][:-4]。否则会报错误(这个错误很隐蔽,网上查了很多资料没有解决,一句句打断点找到的问题所在,debug不易,趟掉很多坑):

“return _nx.concatenate(arrs, 0, dtype=dtype, casting=casting)
ValueError: need at least one array to concatenate”

检测一下nnUNet_cropped_data是否生成了预处理的文件(*.npz和*.pkl): 

 

nnUNet_predict -i 自己的路径\nnUNet_raw\nnUNet_raw_data\Task005_Prostate\imagesTs -o 自己的路径\nnUNet_raw\nnUNet_raw_data\Task005_Prostate\inferTs -t 5 -m 3d_fullres -f 0

运行结果:

推理后得到标注结果:

现在已基本掌握了如何利用nnUNet以后模型进行推理,先会用再学如何利用自己的数据进行训练,之后重点讲如何自定义训练。这篇博客主要是为了解决nnUNet如何在win11环境中解决数据转换和数据预处理,以及如何模型推理。目前国内win11环境安装配置为此独一份,原创来之不易,点赞收藏,后期更精彩。

相关文章:

【原创】nnUnet V1在win11下的安装与配置

安装之前可以先了解一下论文的主要内容,便于之后网络训练与推理,调试程序。 论文地址:nnU-Net: a self-configuring method for deep learning-based biomedical image segmentation | Nature Methods 也可以从其他博客快速浏览&#xff1a…...

C语言之指针初阶

目录 前言 一、内存与地址的关系 二、指针变量 三、野指针 四、const 五、传值调用与传址调用 总结 前言 本文主要介绍C语言指针的一些基础知识,为后面深入理解指针打下基础,因此本文内容主要包括内存与地址的关系,指针的基本语法&…...

异常检测的学习和实战

1.应用: 1.在工业上的应用 当检测设备是否处于异常工作状态时,可以由上图分析得到:那些零散的点对应的数据是异常数据。因为设备大多数时候都是处于正常工作状态的,所以数据点应该比较密集地集中在一个范围内,而那些明…...

RabbitMQ 面试题(一)

1. 简述为什么要使用 RabbitMQ ? 使用 RabbitMQ 的主要原因包括以下几点: 解耦:在复杂的系统中,不同的服务或组件之间往往需要通信和协作。RabbitMQ 作为消息队列,允许这些组件或服务通过发送和接收消息来交互,而无…...

org.postgresql.util.PSQLException: 错误: 关系 “dual“ 不存在

springboot 项目连接 postgreps,启动时报错 org.postgresql.util.PSQLException: 错误: 关系 "dual" 不存在。 查阅资料后发现这是由配置文件中的配置 datasource-dynamic-druid-validationQuery 导致的 spring:datasource:druid:stat-view-servlet:ena…...

mysql权限分类

USAGE --无权限,只有登录数据库,只可以使用test或test_*数据库 ALL --所有权限 select/update/delete/super/slave/reload --指定的权限 with grant option --允许把自己的权限授予其它用户(此用户拥有建立账号的权限) 权限级别: 1、. --全…...

【C++11】列表初始化、右值引用的详细讲解(上)

前言 在一开始学C之前我们就简单的了解了一下C的发展历史。 相比较而言,C11能更好地用于系统开发和库开发、语法更加泛华和简单化、更加稳定和安全,不仅功能更强大,而且能提升程序员的开发效率加了许多特性,约140个新特性。使得C…...

【JAVA进阶篇教学】第十三篇:Java中volatile关键字讲解

博主打算从0-1讲解下java进阶篇教学,今天教学第十三篇:volatile关键字讲解。 在 Java 中,volatile关键字是一种轻量级的同步机制,用于确保变量的可见性和禁止指令重排序。本文将详细解释volatile关键字的工作原理、可见性保证以及…...

蓝桥杯-地宫取宝

X 国王有一个地宫宝库,是 nm 个格子的矩阵,每个格子放一件宝贝,每个宝贝贴着价值标签。 地宫的入口在左上角,出口在右下角。 小明被带到地宫的入口,国王要求他只能向右或向下行走。 走过某个格子时,如果那个…...

带头单链表 C++实现

节点定义 带头单链表&#xff1a;我们只需要一个结点指针指向整个链表的第一个节点&#xff0c;这样我们就可以通过next指针访问整个链表内的所有节点 template<class T> struct ListNode {T _val;ListNode* _next;ListNode(const T &val):_val(val),_next(nullptr){…...

学习c#第24天 枚举类型

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace enumType { //定义枚举 public enum Week { 星期一, 星期二, 星期三, 星期四, 星期…...

TensorFlow运行bug汇总

1、ImportError: urllib3 v2.0 only supports OpenSSL 1.1.1 解决方案 pip install urllib31.26.15 -i https://pypi.tuna.tsinghua.edu.cn/simple 升级或者降级 (TF2.1) C:\Users\Administrator>pip install urllib31.26.15 -i https://pypi.tuna.tsinghua.edu.cn/sim…...

docker部署调度程序

Dockerfile(构建初始镜像) # python:3.8-slim-buster为精简版的python FROM python:3.8-slim-buster # 1059为组的id,newgroup为组名,1088为用户的id,newuser为新用户 RUN groupadd -g 1059 newgroup && \useradd -g -u 1088 -g newgroup -m newuser USER newuser RUN…...

websocket和http协议的区别

ws(websocket)协议和http协议是两种不同的协议。 http&#xff1a;http是一种用于传输超文本的应用层协议&#xff0c;通常用于web端浏览器和web端服务器之间传输数据。http也是基于tcp的&#xff0c;但是HTTP只能在同一时刻单向发送消息&#xff0c;是一种半双工通信。&#…...

CSS之定位

目录 CSS定位为什么需要定位定位组成定位的叠放顺序拓展 CSS定位 为什么需要定位 浮动可以让多个块级盒子一行没有缝隙排列显示&#xff0c;经常用于横向排列盒子定位则是可以让盒子自由的在某个盒子内移动位置或者固定屏幕中的某个位置&#xff0c;并且可以压住其他盒子 定…...

[IM002][Microsoft][ODBC 驱动程序管理器] 未发现数据源名称并且未指定默认驱动程序

解决办法&#xff1a; 安装驱动 下载 ODBC Driver for SQL Server - ODBC Driver for SQL Server | Microsoft Learn...

神经网络复习--神经网络算法模型及BP算法

文章目录 神经网络模型的构成BP神经网络 神经网络模型的构成 三种表示方式&#xff1a; 神经网络的三要素&#xff1a; 具有突触或连接&#xff0c;用权重表示神经元的连接强度具有时空整合功能的输入信号累加器激励函数用于限制神经网络的输出 感知神经网络 BP神经网络 …...

【Java】/*方法的使用-快速总结*/

目录 一、什么是方法 二、方法的定义 三、实参和形参的关系 四、方法重载 五、方法签名 一、什么是方法 Java中的方法可以理解为C语言中的函数&#xff0c;只是换了个名称而已。 二、方法的定义 1. 语法格式&#xff1a; public static 返回类型 方法名 (形参列表) { //方…...

kotlin中协程相关

协程 用同步的方式写出异步的效果协程最重要的是通过非阻塞挂起和恢复实现了异步代码的同步编写方式挂起函数(suspend)不一定就是在子线程中执行的&#xff0c;但是通常在定义挂起函数时都会为它指定其他线程&#xff0c;这样挂起才有意义解决多层嵌套回调 协程不是线程&…...

(自适应手机端)物流运输快递仓储网站模板 - 带三级栏目

(自适应手机端)物流运输快递仓储网站模板 - 带三级栏目PbootCMS内核开发的网站模板&#xff0c;该模板适用于物流运输网站、仓储货运网站等企业&#xff0c;当然其他行业也可以做&#xff0c;只需要把文字图片换成其他行业的即可&#xff1b;自适应手机端&#xff0c;同一个后台…...

AI-调查研究-01-正念冥想有用吗?对健康的影响及科学指南

点一下关注吧&#xff01;&#xff01;&#xff01;非常感谢&#xff01;&#xff01;持续更新&#xff01;&#xff01;&#xff01; &#x1f680; AI篇持续更新中&#xff01;&#xff08;长期更新&#xff09; 目前2025年06月05日更新到&#xff1a; AI炼丹日志-28 - Aud…...

逻辑回归:给不确定性划界的分类大师

想象你是一名医生。面对患者的检查报告&#xff08;肿瘤大小、血液指标&#xff09;&#xff0c;你需要做出一个**决定性判断**&#xff1a;恶性还是良性&#xff1f;这种“非黑即白”的抉择&#xff0c;正是**逻辑回归&#xff08;Logistic Regression&#xff09;** 的战场&a…...

FastAPI 教程:从入门到实践

FastAPI 是一个现代、快速&#xff08;高性能&#xff09;的 Web 框架&#xff0c;用于构建 API&#xff0c;支持 Python 3.6。它基于标准 Python 类型提示&#xff0c;易于学习且功能强大。以下是一个完整的 FastAPI 入门教程&#xff0c;涵盖从环境搭建到创建并运行一个简单的…...

2021-03-15 iview一些问题

1.iview 在使用tree组件时&#xff0c;发现没有set类的方法&#xff0c;只有get&#xff0c;那么要改变tree值&#xff0c;只能遍历treeData&#xff0c;递归修改treeData的checked&#xff0c;发现无法更改&#xff0c;原因在于check模式下&#xff0c;子元素的勾选状态跟父节…...

第25节 Node.js 断言测试

Node.js的assert模块主要用于编写程序的单元测试时使用&#xff0c;通过断言可以提早发现和排查出错误。 稳定性: 5 - 锁定 这个模块可用于应用的单元测试&#xff0c;通过 require(assert) 可以使用这个模块。 assert.fail(actual, expected, message, operator) 使用参数…...

Java面试专项一-准备篇

一、企业简历筛选规则 一般企业的简历筛选流程&#xff1a;首先由HR先筛选一部分简历后&#xff0c;在将简历给到对应的项目负责人后再进行下一步的操作。 HR如何筛选简历 例如&#xff1a;Boss直聘&#xff08;招聘方平台&#xff09; 直接按照条件进行筛选 例如&#xff1a…...

有限自动机到正规文法转换器v1.0

1 项目简介 这是一个功能强大的有限自动机&#xff08;Finite Automaton, FA&#xff09;到正规文法&#xff08;Regular Grammar&#xff09;转换器&#xff0c;它配备了一个直观且完整的图形用户界面&#xff0c;使用户能够轻松地进行操作和观察。该程序基于编译原理中的经典…...

ip子接口配置及删除

配置永久生效的子接口&#xff0c;2个IP 都可以登录你这一台服务器。重启不失效。 永久的 [应用] vi /etc/sysconfig/network-scripts/ifcfg-eth0修改文件内内容 TYPE"Ethernet" BOOTPROTO"none" NAME"eth0" DEVICE"eth0" ONBOOT&q…...

Redis的发布订阅模式与专业的 MQ(如 Kafka, RabbitMQ)相比,优缺点是什么?适用于哪些场景?

Redis 的发布订阅&#xff08;Pub/Sub&#xff09;模式与专业的 MQ&#xff08;Message Queue&#xff09;如 Kafka、RabbitMQ 进行比较&#xff0c;核心的权衡点在于&#xff1a;简单与速度 vs. 可靠与功能。 下面我们详细展开对比。 Redis Pub/Sub 的核心特点 它是一个发后…...

解读《网络安全法》最新修订,把握网络安全新趋势

《网络安全法》自2017年施行以来&#xff0c;在维护网络空间安全方面发挥了重要作用。但随着网络环境的日益复杂&#xff0c;网络攻击、数据泄露等事件频发&#xff0c;现行法律已难以完全适应新的风险挑战。 2025年3月28日&#xff0c;国家网信办会同相关部门起草了《网络安全…...