Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation of spatial shape constraints for the networks #6771

Open
wyli opened this issue Jul 25, 2023 · 9 comments
Open

Documentation of spatial shape constraints for the networks #6771

wyli opened this issue Jul 25, 2023 · 9 comments
Assignees
Labels
CookBook documentation Improvements or additions to documentation Feature request good first issue Good for newcomers

Comments

@wyli
Copy link
Contributor

wyli commented Jul 25, 2023

Is your feature request related to a problem? Please describe.
follow up of discussion #6641

would be great to add input spatial size vs model configuration analysis for all the networks such as
swinunetr and dints.

the form of analysis could be detailed tutorials (example https://github.com/Project-MONAI/tutorials/blob/main/modules/UNet_input_size_constrains.ipynb) and/or actual code logic to check the compatibility of the input shape and model configuration.

@wyli wyli added documentation Improvements or additions to documentation good first issue Good for newcomers Feature request labels Jul 25, 2023
@nhhung1810
Copy link

Hi @wyli , I'd like to work on this issue, can you suggest me some related resources that you think is helpful?

@wyli
Copy link
Contributor Author

wyli commented Jul 26, 2023

sure, that's great @nhhung1810, please see:

  • how to prepare a pull request https://github.com/Project-MONAI/MONAI/blob/dev/CONTRIBUTING.md
  • would be great to revise the related docstring with a bit more details, following this example
    Enhanced version of UNet which has residual units implemented with the ResidualUnit class.
    The residual part uses a convolution to change the input dimensions to match the output dimensions
    if this is necessary but will use nn.Identity if not.
    Refer to: https://link.springer.com/chapter/10.1007/978-3-030-12029-0_40.
    Each layer of the network has a encode and decode path with a skip connection between them. Data in the encode path
    is downsampled using strided convolutions (if `strides` is given values greater than 1) and in the decode path
    upsampled using strided transpose convolutions. These down or up sampling operations occur at the beginning of each
    block rather than afterwards as is typical in UNet implementations.
    To further explain this consider the first example network given below. This network has 3 layers with strides
    of 2 for each of the middle layers (the last layer is the bottom connection which does not down/up sample). Input
    data to this network is immediately reduced in the spatial dimensions by a factor of 2 by the first convolution of
    the residual unit defining the first layer of the encode part. The last layer of the decode part will upsample its
    input (data from the previous layer concatenated with data from the skip connection) in the first convolution. this
    ensures the final output of the network has the same shape as the input.
    Padding values for the convolutions are chosen to ensure output sizes are even divisors/multiples of the input
    sizes if the `strides` value for a layer is a factor of the input sizes. A typical case is to use `strides` values
    of 2 and inputs that are multiples of powers of 2. An input can thus be downsampled evenly however many times its
    dimensions can be divided by 2, so for the example network inputs would have to have dimensions that are multiples
    of 4. In the second example network given below the input to the bottom layer will have shape (1, 64, 15, 15) for
    an input of shape (1, 1, 240, 240) demonstrating the input being reduced in size spatially by 2**4.
  • the docstring format https://www.sphinx-doc.org/en/master/usage/restructuredtext/basics.html
  • the docstring style https://google.github.io/styleguide/pyguide.html#38-comments-and-docstrings

@nhhung1810
Copy link

nhhung1810 commented Jul 27, 2023

all the networks such as swinunetr and dints

Hi @wyli , I think that you refer to all networks under monai/networks/nets? If such, can you suggest some high priority networks first?

Also, if the number of networks need to be done is a lot, I'll split up into small PRs for each networks, do you fine with that?

@wyli
Copy link
Contributor Author

wyli commented Jul 27, 2023

Yes @nhhung1810, separate PRs would be great, high priority ones are

please feel free to start with simple PRs.. we can use this ticket to track the progress (cc @vikashg for any further comments)

@nhhung1810
Copy link

Sure, I will start with UNET++ first

@nhhung1810
Copy link

nhhung1810 commented Aug 2, 2023

Hi @wyli I have create a PR here Project-MONAI/tutorials#1476, mentioned in the above Issue Project-MONAI/tutorials#1475.

It's not completed, I'm definitely need more advise on this

@vikashg vikashg self-assigned this Dec 20, 2023
@vikashg
Copy link

vikashg commented Dec 20, 2023

Good job @nhhung1810

@vikashg
Copy link

vikashg commented Jan 4, 2024

@nhhung1810 is it completed?

@nhhung1810
Copy link

Oh it's complete @vikashg, it's in the PR above, for 1 model (UNET++) only. I haven't worked on this since then @vikashg

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CookBook documentation Improvements or additions to documentation Feature request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

3 participants