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

Restormer Implementation #8312

Open
wants to merge 59 commits into
base: dev
Choose a base branch
from
Open

Restormer Implementation #8312

wants to merge 59 commits into from

Conversation

phisanti
Copy link

Fixes # .

Description

This PR implements the Restormer architecture for high-resolution image restoration in MONAI following the discussion in issue #8261. The implementation supports both 2D and 3D images using MONAI's convolution as the base. Key additions include:

  • Downsample class for efficient downsampling operations
  • pixel_unshuffle operation complementing existing pixel_shuffle
  • Channel Attention Block (CABlock) with FeedForward layer
  • Multi-DConv Head Transposed Self-Attention (MDTA)
  • OverlapPatchEmbed class
  • Comprehensive unit tests for all new components

The implementation follows MONAI's coding patterns and includes performance validations against native PyTorch operations where applicable.

Types of changes

  • Non-breaking change (fix or new feature that would not break existing functionality).
  • Breaking change (fix or new feature that would cause existing functionality to change).
  • New tests added to cover the changes.
  • Integration tests passed locally by running ./runtests.sh -f -u --net --coverage.
  • Quick tests passed locally by running ./runtests.sh --quick --unittests --disttests.
  • In-line docstrings updated.
  • Documentation updated, tested make html command in the docs/ folder.

Copy link
Member

@ericspod ericspod left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good overall but I had a few inline comments, and we should have full docstrings everywhere appropriate. For any classes meant for general purpose use (ie. not just by Restormer) please ensure they have docstring descriptions for the arguments (at the very least for constructor args). Thanks!

phisanti and others added 22 commits February 7, 2025 13:44
…ns and simplify ValueError message in pixelunshuffle
…n Restormer model and update assert in forward layer to support 3D images
…ument descriptions and error handling details.
Signed-off-by: tisalon <[email protected]>
Signed-off-by: tisalon <[email protected]>
@ericspod
Copy link
Member

Hi @phisanti thanks for bearing with us here but we've updated the tests directory so there's a conflict you'll need to resolve. We've introduced a subdirectory structure within tests so please move your test files to somewhere appropriate within that. Also it appears that a number of changes you've made to address comments have been reverted back, I think somewhere in your commits there's been some mixup of versions.

@phisanti
Copy link
Author

Hi @ericspod, no probs. Thanks for the feedback. I will move the test to the appropriate new folder this Friday. Also, I would like to ask for a bit of help if possible. It seems some of the tests cannot be running due to the optional import lineups. For example, it happens in premerge-min/min-dep-py3 (3.12) but not in premerge/quick-py3 (ubuntu-latest). I tried to place the skip test on top, but maybe you can give me some indication of where it should go.

Regarding the mixup on the changes, I think it happened when I did a merge back on Feb 7th as the branch got behind, I will try to look on it.

@ericspod
Copy link
Member

Hi @phisanti We can look at the issues with the tests, no problem. I think I should let you figure out the mixup with branches and update your tests first then we can have a look at what the issue is. We should avoid just ignoring tests as much as possible, but if you need einops for example you can use @skipUnless(has_einops, "Requires einops") as a test method decorator. If that isn't working for you we can figure it out together.

@phisanti phisanti requested a review from aylward March 1, 2025 10:05
@phisanti
Copy link
Author

phisanti commented Mar 1, 2025

Hi @phisanti We can look at the issues with the tests, no problem. I think I should let you figure out the mixup with branches and update your tests first then we can have a look at what the issue is. We should avoid just ignoring tests as much as possible, but if you need einops for example you can use @skipUnless(has_einops, "Requires einops") as a test method decorator. If that isn't working for you we can figure it out together.

Hi @ericspod, I finally manage to find some time to do the merge and be up-to-date with main. Now, in regards with the unit test, I placed them all in their appropriate folders mirroring the structure within source:

/tests/networks/utils/text_pixelshuffle.py
/tests/networks/blocks/text_CABlock.py
/tests/networks/blocks/text_downsample.py
/tests/networks/nets/text_restormer.py

I also noticed that I have to move the import of SkipIfBeforePyTorchVersion in test_CABlock.py from tests.utils to tests.test_utils. I have placed the statement einops, has_einops = optional_import("einops") plus @skipUnless(has_einops, "Requires einops"), however, it seems some of the checks still fail. Thus, any help will be welcome, I believe the required changes are quite minimal.

… <[email protected]>,

I, Cano-Muniz, Santiago <[email protected]>, hereby add my Signed-off-by to this commit: 55da640
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants