MIC-DKFZ / MedNeXt

[MICCAI 2023] MedNeXt is a fully ConvNeXt architecture for 3D medical image segmentation.
https://arxiv.org/pdf/2303.09975
Apache License 2.0
348 stars 26 forks source link

About the "self.stem = nn.Conv3d(in_channels, n_channels, kernel_size=1)" #9

Closed islandLZ closed 1 year ago

islandLZ commented 1 year ago

The data format read by my data loader is torch.Size([1, 3, 512, 512]). image

I encountered an error here。 image

So how should I set the initial parameters of the entire network? image

When I put in_ A new error occurred when in_channels were set to 1: image

islandLZ commented 1 year ago

When I change n_channels = 3 , I meet an other erro!

saikat-roy commented 1 year ago

Hi @islandLZ. The problem seems to be the last version of the architecture was strictly designed to be 3d while your inputs are 2d. I've just committed a version of the architecture with a 'dim' argument with '2d' or '3d' inputs. Give that a try and see if it works for you.

islandLZ commented 1 year ago

I set this:

class MedNeXt(nn.Module):

def __init__(self, 
    in_channels: int = 3, 
    n_channels: int = 32,
    n_classes: int = 3, 
    exp_r: list = [3,4,8,8,8,8,8,4,3],         # Expansion ratio as in Swin Transformers
    kernel_size: int = 5,                      # Ofcourse can test kernel_size
    enc_kernel_size: int = None,
    dec_kernel_size: int = None,
    deep_supervision: bool = False,             # Can be used to test deep supervision
    do_res: bool = True,                       # Can be used to individually test residual connection
    do_res_up_down: bool = True,             # Additional 'res' connection on up and down convs
    checkpoint_style: str = 'outside_block',  # Either inside block or outside block
    block_counts: list = [3,4,8,8,8,8,8,4,3], # Can be used to test staging ratio:# [3,3,9,3] in Swin as opposed to [2,2,2,2,2] in nnUNet
    norm_type = 'group',
):

....... then I have made modifications to my data format: [1,3,512,512] -> [1,3,64,64,64]

So that the network can operate normally.

But I am still testing whether this method is feasible。

islandLZ commented 1 year ago

Hi @islandLZ. The problem seems to be the last version of the architecture was strictly designed to be 3d while your inputs are 2d. I've just committed a version of the architecture with a 'dim' argument with '2d' or '3d' inputs. Give that a try and see if it works for you.

Thank you for your work. I will try the 'dim' you just set up now。

islandLZ commented 1 year ago

I success

Hi @islandLZ. The problem seems to be the last version of the architecture was strictly designed to be 3d while your inputs are 2d. I've just committed a version of the architecture with a 'dim' argument with '2d' or '3d' inputs. Give that a try and see if it works for you.

Your work has been successful. image image

saikat-roy commented 1 year ago

I'm glad to hear that it helped!