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

nnunetv2系列:使用默认的预测类推理2D数据

nnunetv2系列:使用默认的预测类推理2D数据

这里参考源代码nnUNet/nnunetv2/inference/predict_from_raw_data.py中给的示例进行调整和测试。

代码示例

from torch import device
from nnunetv2.inference.predict_from_raw_data import nnUNetPredictor# from nnunetv2.paths import (
#     nnUNet_results,
#     # nnUNet_raw
# )
# from batchgenerators.utilities.file_and_folder_operations import joinfrom time import timeif __name__ == "__main__":start = time()# instantiate the nnUNetPredictorpredictor = nnUNetPredictor(tile_step_size=0.5,use_gaussian=True,use_mirroring=True,perform_everything_on_device=True,device=device("cuda", 0),verbose=False,verbose_preprocessing=False,allow_tqdm=True,)# initializes the network architecture, loads the checkpointpredictor.initialize_from_trained_model_folder(# 直接使用绝对路径,替换join方法"/home/bio/family/segmenation/nnUNet/nnUNet_results/Dataset500_ScleraIrisSegmentation/nnUNetTrainer__nnUNetPlans__2d",# join(#     nnUNet_results,#     "Dataset500_ScleraIrisSegmentation/nnUNetTrainer__nnUNetPlans__2d"# ),use_folds=(0,),checkpoint_name="checkpoint_best.pth",)# variant 1: give input and output folders# 使用绝对路径,否则会报错# 推荐内部注释生成json文件的代码,否则默认会生成json文件predictor.predict_from_files(# 实际测试发现,必须先转成nnunet格式,再进行预测,数据名称应该为*_0000.png这类的"/home/bio/family/segmenation/nnUNet/afamily_test/inference/imagesTr","/home/bio/family/segmenation/nnUNet/afamily_test/inference/imagesTr_predict",save_probabilities=False,overwrite=False,num_processes_preprocessing=1,num_processes_segmentation_export=1,folder_with_segs_from_prev_stage=None,num_parts=1,part_id=0,)print(f"Time taken: {time() - start}")

http://www.mrgr.cn/news/23796.html

相关文章:

  • Java实现建造者模式和源码中的应用
  • MMO:道具系统
  • opencv图像透视处理
  • jupyter出错ImportError: cannot import name ‘np_utils‘ from ‘keras.utils‘ ,怎么解决?
  • 数据看板多端查看无压力,教你轻松设置响应式布局
  • 论文速读|信任 PRoC3S:利用大型语言模型和约束满足解决长时域机器人问题。
  • framebuffer帧缓存
  • 从学习到的因果网络中估计因果效应
  • 深度优先算法,广度优先算法,hill climbing,贪心搜索,A*算法,启发式搜索算法是什么,比起一般搜索法算法有什么区别
  • 深度盘点:行业领先的crm管理系统软件有哪些?
  • 排名再升2位 中国平安位列BrandZ最具价值中国品牌第9位
  • 激发消费潜力:优选购物模式的共赢策略
  • 前端程序员_职场生存法则
  • 54. Spiral Matrix
  • 六、TOGAF(架构能力框架Architecture Capability Framework)
  • PyQt---不同版本介绍说明及更新过程
  • 自用小问答
  • 《Python爬虫逆向实战》加密方法远程调用(RPC)
  • WinFrom项目结构
  • 怎么画实体关系图E-R?用这款在线绘图工具简单又好用!