Amshaker / unetr_plus_plus

[IEEE TMI-2024] UNETR++: Delving into Efficient and Accurate 3D Medical Image Segmentation
Apache License 2.0
368 stars 36 forks source link

unetr_pp_acdc #14

Closed Yffy123456 closed 1 year ago

Yffy123456 commented 1 year ago

if name == 'main':

img = torch.rand((2, 1, 128, 128, 128))
U_PP = UNETR_PP(in_channels=1 ,out_channels=16)
model =U_PP(img)
out = U_PP(img)
print(out.shape)
print(U_PP)

/home/wf/anaconda3/envs/tr/bin/python /home/wf/yf/unetr_plus_plus-main/unetr_pp/network_architecture/acdc/unetr_pp_acdc.py Traceback (most recent call last): File "/home/wf/yf/unetr_plus_plus-main/unetr_pp/network_architecture/acdc/unetr_pp_acdc.py", line 149, in U_PP = UNETR_PP(in_channels=1 ,out_channels=16) File "/home/wf/yf/unetr_plus_plus-main/unetr_pp/network_architecture/acdc/unetr_pp_acdc.py", line 61, in init self.unetr_pp_encoder = UnetrPPEncoder(dims=dims, depths=depths, num_heads=num_heads) File "/home/wf/yf/unetr_plus_plus-main/unetr_pp/network_architecture/acdc/model_components.py", line 21, in init get_conv_layer(spatial_dims, in_channels, dims[0], kernel_size=(1, 4, 4), stride=(1, 4, 4), TypeError: 'NoneType' object is not subscriptable

Need some answers,Thanks

Amshaker commented 1 year ago

To create an instance of UnetrPPEncoder, you have to pass (dims=dims, depths=depths, num_heads=num_heads). Please pass all the required arguments.

To create an instance from the whole network, you have to do it in way similar to this one:

self.network = UNETR_PP(in_channels=self.input_channels, out_channels=self.num_classes, feature_size=16, num_heads=4, depths=[3, 3, 3, 3], dims=[32, 64, 128, 256], do_ds=True, )