faustomilletari / VNet

GNU General Public License v3.0
286 stars 122 forks source link

Implement Vnet with 8 slices in 3d instead of 16 slices #52

Open AmitAilianiSDC opened 6 years ago

AmitAilianiSDC commented 6 years ago

I would appreciate if you can help how to use this code by considering only 8 slices for 3d dataset. As per my understanding I have made changes to following initialization code. I have made changes in InputTransition to split data into 8 channels. I am getting following error. Please let me know how to address this issue.

Code Changes

    self.in_tr = InputTransition(8, elu)
    self.down_tr32 = DownTransition(8, 1, elu)
    self.down_tr64 = DownTransition(16, 2, elu)
    self.down_tr128 = DownTransition(32, 3, elu, dropout=True)
    self.down_tr256 = DownTransition(64, 2, elu, dropout=True)
    self.up_tr256 = UpTransition(128, 128, 2, elu, dropout=True)
    self.up_tr128 = UpTransition(128, 64, 2, elu, dropout=True)
    self.up_tr64 = UpTransition(64, 32, 1, elu)
    self.up_tr32 = UpTransition(32, 16, 1, elu)
    self.out_tr = OutputTransition(16, elu, nll)

Error:

output = model(data) File "C:\Program Files\Python36\lib\site-packages\torch\nn\modules\module.py", line 224, in call result = self.forward(*input, kwargs) File "C:\Program Files\Python36\lib\site-packages\torch\nn\parallel\data_parallel.py", line 60, in forward outputs = self.parallel_apply(replicas, inputs, kwargs) File "C:\Program Files\Python36\lib\site-packages\torch\nn\parallel\data_parallel.py", line 70, in parallel_apply return parallel_apply(replicas, inputs, kwargs, self.device_ids[:len(replicas)]) File "C:\Program Files\Python36\lib\site-packages\torch\nn\parallel\parallel_apply.py", line 67, in parallel_apply raise output File "C:\Program Files\Python36\lib\site-packages\torch\nn\parallel\parallel_apply.py", line 42, in _worker output = module(*input, *kwargs) File "C:\Program Files\Python36\lib\site-packages\torch\nn\modules\module.py", line 224, in call result = self.forward(input, kwargs) File "e:\winPyTorch\vnet.FullLung_nodule_segmentation\vnet.py", line 188, in forward out256 = self.down_tr256(out128) File "C:\Program Files\Python36\lib\site-packages\torch\nn\modules\module.py", line 224, in call result = self.forward(*input, **kwargs) File "e:\winPyTorch\vnet.FullLung_nodule_segmentation\vnet.py", line 81, in forward down = self.relu1(self.bn1(self.down_conv(x)))

faustomilletari commented 6 years ago

I think you are loosing a dimension because of downsampling.

You divide your 8 slices by 2 a total of 4 times. One of your dimensions is collapsingg because of that. Kill one DownTransition and relative UpTransition.

V-Net is designed to run with resolutions up to 256^3 voxels on the newest hardware.

Fausto

On Jun 7, 2018, at 2:17 PM, amitailiani notifications@github.com wrote:

I would appreciate if you can help how to use this code by considering only 8 slices for 3d dataset. As per my understanding I have made changes to following initialization code. I have made changes in InputTransition to split data into 8 channels. I am getting following error. Please let me know how to address this issue.

Code Changes

self.in_tr = InputTransition(8, elu)
self.down_tr32 = DownTransition(8, 1, elu)
self.down_tr64 = DownTransition(16, 2, elu)
self.down_tr128 = DownTransition(32, 3, elu, dropout=True)
self.down_tr256 = DownTransition(64, 2, elu, dropout=True)
self.up_tr256 = UpTransition(128, 128, 2, elu, dropout=True)
self.up_tr128 = UpTransition(128, 64, 2, elu, dropout=True)
self.up_tr64 = UpTransition(64, 32, 1, elu)
self.up_tr32 = UpTransition(32, 16, 1, elu)
self.out_tr = OutputTransition(16, elu, nll)

Error:

output = model(data) File "C:\Program Files\Python36\lib\site-packages\torch\nn\modules\module.py", line 224, in call result = self.forward(*input, kwargs) File "C:\Program Files\Python36\lib\site-packages\torch\nn\parallel\data_parallel.py", line 60, in forward outputs = self.parallel_apply(replicas, inputs, kwargs) File "C:\Program Files\Python36\lib\site-packages\torch\nn\parallel\data_parallel.py", line 70, in parallel_apply return parallel_apply(replicas, inputs, kwargs, self.device_ids[:len(replicas)]) File "C:\Program Files\Python36\lib\site-packages\torch\nn\parallel\parallel_apply.py", line 67, in parallel_apply raise output File "C:\Program Files\Python36\lib\site-packages\torch\nn\parallel\parallel_apply.py", line 42, in _worker output = module(*input, *kwargs) File "C:\Program Files\Python36\lib\site-packages\torch\nn\modules\module.py", line 224, in call result = self.forward(input, kwargs) File "e:\winPyTorch\vnet.FullLung_nodule_segmentation\vnet.py", line 188, in forward out256 = self.down_tr256(out128) File "C:\Program Files\Python36\lib\site-packages\torch\nn\modules\module.py", line 224, in call result = self.forward(*input, **kwargs) File "e:\winPyTorch\vnet.FullLung_nodule_segmentation\vnet.py", line 81, in forward down = self.relu1(self.bn1(self.down_conv(x)))

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/faustomilletari/VNet/issues/52, or mute the thread https://github.com/notifications/unsubscribe-auth/AMtsvvkYeQxhfo1JTvQMpHSpEZX7tjlRks5t6ZiBgaJpZM4UfIxK.

AmitAilianiSDC commented 6 years ago

thank you for your prompt response. I am new to semantic segmentation. Can you suggest which layer would be appropriate to remove?

faustomilletari commented 6 years ago

The last downsampling layer, and the following one.

On Jun 7, 2018, at 2:23 PM, amitailiani notifications@github.com wrote:

thank you for your prompt response. I am new to semantic segmentation. Can you suggest which layer would be appropriate to remove?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/faustomilletari/VNet/issues/52#issuecomment-395569706, or mute the thread https://github.com/notifications/unsubscribe-auth/AMtsvo0sugu0LagXWKIgfNUPj8sAUZ30ks5t6ZnegaJpZM4UfIxK.

AmitAilianiSDC commented 6 years ago

Hi:

There is a specific reason I am restricting my data to 8 slices. I am working on tumor segmentation and tumors are are of certain size.

I am still getting errors after removing last layer. Can you please look into this? See below for your reference.

Thanks again for your help.

AmsAlien

Error: File "e:\winPyTorch\vnet.FullLung_nodule_segmentation\vnet.py", line 190, in forward out = self.up_tr128(out128, out64) File "C:\Program Files\Python36\lib\site-packages\torch\nn\modules\module.py", line 224, in call result = self.forward(*input, *kwargs) File "e:\winPyTorch\vnet.FullLung_nodule_segmentation\vnet.py", line 104, in forward out = self.relu1(self.bn1(self.up_conv(out))) File "C:\Program Files\Python36\lib\site-packages\torch\nn\modules\module.py", line 224, in call result = self.forward(input, **kwargs) File "C:\Program Files\Python36\lib\site-packages\torch\nn\modules\conv.py", line 663, in forward output_padding, self.groups, self.dilation) File "C:\Program Files\Python36\lib\site-packages\torch\nn\functional.py", line 203, in conv_transpose3d return f(input, weight, bias) RuntimeError: CUDNN_STATUS_BAD_PARAM

Code Changes not sure how the second parameter which is number of convolutions is set:

def init(self, elu=True, nll=False): super(VNet, self).init() self.in_tr = InputTransition(8, elu) self.down_tr32 = DownTransition(8, 1, elu) self.down_tr64 = DownTransition(16, 2, elu) self.down_tr128 = DownTransition(32, 3, elu, dropout=True) self.up_tr128 = UpTransition(128, 128, 2, elu, dropout=True) self.up_tr64 = UpTransition(128, 64, 1, elu) self.up_tr32 = UpTransition(64, 32, 1, elu) self.out_tr = OutputTransition(32, elu, nll)

def forward(self, x): out16 = self.in_tr(x) out32 = self.down_tr32(out16) out64 = self.down_tr64(out32) out128 = self.down_tr128(out64) out = self.up_tr128(out128, out64) out = self.up_tr64(out, out32) out = self.up_tr32(out, out16) out = self.out_tr(out) return out

On Thu, Jun 7, 2018 at 2:25 PM, Fausto Milletari notifications@github.com wrote:

The last downsampling layer, and the following one.

On Jun 7, 2018, at 2:23 PM, amitailiani notifications@github.com wrote:

thank you for your prompt response. I am new to semantic segmentation. Can you suggest which layer would be appropriate to remove?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/ faustomilletari/VNet/issues/52#issuecomment-395569706, or mute the thread https://github.com/notifications/unsubscribe-auth/ AMtsvo0sugu0LagXWKIgfNUPj8sAUZ30ks5t6ZnegaJpZM4UfIxK.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/faustomilletari/VNet/issues/52#issuecomment-395570127, or mute the thread https://github.com/notifications/unsubscribe-auth/AQ5KvgfL3i0aqE4I7OvwAkt08wWmWww6ks5t6Zo-gaJpZM4UfIxK .