-2

我运行(在 Google Cloud VM 实例中的 Ubuntu 16.04 上):

net_segment inference -c <path-to-config>

unet_2d对于使用softmax 和 (96,96,1) 空间窗口的二元分割问题。这是在我训练我的模型 10 个 epoch 并保存检查点之后。我不确定为什么它会从windows_aggregator_resize.py. 这个问题的原因是什么,我能做些什么来解决它?

以下是一些推理设置和相应的错误:

pixdim: (1.0, 1.0, 1.0)

[NETWORK]
batch_size: 1
cutoff: (0.01, 0.99)
name: unet_2d
normalisation: False
volume_padding_size: (96, 96, 0)
reg_type: L2
window_sampling: resize
multimod_foreground_type: and

[INFERENCE]
border = (96,96,0)
inference_iter = -1
output_interp_order = 0
spatial_window_size = (96,96,2)

INFO:niftynet: Accessing /home/xchaosfailx1/niftynet/models/MSD/heart_la_seg/models/model.ckpt-10 ...
INFO:niftynet: Restoring parameters from /home/xchaosfailx1/niftynet/models/MSD/heart_la_seg/models/model.ckpt-10
INFO:niftynet: Cleaning up...
WARNING:niftynet: stopped early, incomplete loops
INFO:niftynet: stopping sampling threads
INFO:niftynet: SegmentationApplication stopped (time in second 17.07).
Traceback (most recent call last):
  File "/home/xchaosfailx1/.local/bin/net_segment", line 11, in <module>
    sys.exit(main())
  File "/home/xchaosfailx1/.local/lib/python3.5/site-packages/niftynet/__init__.py", line 139, in main
    app_driver.run_application()
  File "/home/xchaosfailx1/.local/lib/python3.5/site-packages/niftynet/engine/application_driver.py", line 275, in run_application
    self._inference_loop(session, loop_status)
  File "/home/xchaosfailx1/.local/lib/python3.5/site-packages/niftynet/engine/application_driver.py", line 493, in _inference_loop
    self._loop(iter_generator(itertools.count(), INFER), sess, loop_status)
  File "/home/xchaosfailx1/.local/lib/python3.5/site-packages/niftynet/engine/application_driver.py", line 442, in _loop
    iter_msg.current_iter_output[NETWORK_OUTPUT])
  File "/home/xchaosfailx1/.local/lib/python3.5/site-packages/niftynet/application/segmentation_application.py", line 390, in interpret_output
    batch_output['window'], batch_output['location'])
  File "/home/xchaosfailx1/.local/lib/python3.5/site-packages/niftynet/engine/windows_aggregator_resize.py", line 55, in decode_batch
    self._save_current_image(window[batch_id, ...], resize_to_shape)
  File "/home/xchaosfailx1/.local/lib/python3.5/site-packages/niftynet/engine/windows_aggregator_resize.py", line 82, in _save_current_image
    [float(p) / float(d) for p, d in zip(window_shape, image_shape)]
  File "/home/xchaosfailx1/.local/lib/python3.5/site-packages/niftynet/engine/windows_aggregator_resize.py", line 82, in <listcomp>
    [float(p) / float(d) for p, d in zip(window_shape, image_shape)]
ZeroDivisionError: float division by zero

为了重现错误:

4

2 回答 2

0

没有检查推理数据,但我认为应该是你在训练中设置的spatial_window_size[INFERENCE]96, 96, 1

于 2018-08-10T23:37:24.063 回答
0

我犯的错误是我将边框(96,96,0)设置[Inference]为与我的空间窗口(96,96,1)相同的形状,因此当批量裁剪时decode_batch,裁剪后的图像具有图像形状里面有 0。因此,当在 中计算缩放比例时_save_current_image,会导致 ZeroDivsionError。临时修复是删除卷填充并更改border=(0,0,0).

于 2018-08-16T14:54:01.803 回答