Skip to content

2532 revert dynunet change for backward compatibility#2534

Merged
diazandr3s merged 1 commit intoProject-MONAI:devfrom
wyli:2532-backward-comp-dynunet
Jul 6, 2021
Merged

2532 revert dynunet change for backward compatibility#2534
diazandr3s merged 1 commit intoProject-MONAI:devfrom
wyli:2532-backward-comp-dynunet

Conversation

@wyli
Copy link
Copy Markdown
Contributor

@wyli wyli commented Jul 6, 2021

Signed-off-by: Wenqi Li [email protected]

Fixes #2532

Description

could import this module by from monai.networks.nets.dynunet_v1 import DynUNetV1 as DynUNet
(this version is from MONAI v0.5.3)

Status

Ready

Types of changes

  • Non-breaking change (fix or new feature that would not break existing functionality).
  • 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.
  • In-line docstrings updated.
  • Documentation updated, tested make html command in the docs/ folder.

Signed-off-by: Wenqi Li <[email protected]>
@wyli wyli marked this pull request as ready for review July 6, 2021 20:05
@wyli
Copy link
Copy Markdown
Contributor Author

wyli commented Jul 6, 2021

This PR resumes the previous module and test. It also passes this test:
@diazandr3s @yiheng-wang-nv @Nic-Ma

script adapted from https://github.com/Project-MONAI/MONAILabel/blob/main/sample-apps/deepedit_left_atrium/main.py

import os

import torch

from monai.networks.nets.dynunet_v1 import DynUNetV1 as DynUNet

net = DynUNet(
    spatial_dims=3,
    in_channels=3,
    out_channels=1,
    kernel_size=[
        [3, 3, 3],
        [3, 3, 3],
        [3, 3, 3],
        [3, 3, 3],
        [3, 3, 3],
        [3, 3, 3],
    ],
    strides=[
        [1, 1, 1],
        [2, 2, 2],
        [2, 2, 2],
        [2, 2, 2],
        [2, 2, 2],
        [2, 2, 1],
    ],
    upsample_kernel_size=[
        [2, 2, 2],
        [2, 2, 2],
        [2, 2, 2],
        [2, 2, 2],
        [2, 2, 1],
    ],
    norm_name="instance",
    deep_supervision=False,
    res_block=True,
)

pretrained_model = os.path.join("deepedit_left_atrium.pt")
ckpt = torch.load(pretrained_model, map_location="cpu")
net.load_state_dict(ckpt)
print(ckpt)

@diazandr3s
Copy link
Copy Markdown
Contributor

This PR resumes the previous module and test. It also passes this test:
@diazandr3s @yiheng-wang-nv @Nic-Ma

script adapted from https://github.com/Project-MONAI/MONAILabel/blob/main/sample-apps/deepedit_left_atrium/main.py

import os

import torch

from monai.networks.nets.dynunet_v1 import DynUNetV1 as DynUNet

net = DynUNet(
    spatial_dims=3,
    in_channels=3,
    out_channels=1,
    kernel_size=[
        [3, 3, 3],
        [3, 3, 3],
        [3, 3, 3],
        [3, 3, 3],
        [3, 3, 3],
        [3, 3, 3],
    ],
    strides=[
        [1, 1, 1],
        [2, 2, 2],
        [2, 2, 2],
        [2, 2, 2],
        [2, 2, 2],
        [2, 2, 1],
    ],
    upsample_kernel_size=[
        [2, 2, 2],
        [2, 2, 2],
        [2, 2, 2],
        [2, 2, 2],
        [2, 2, 1],
    ],
    norm_name="instance",
    deep_supervision=False,
    res_block=True,
)

pretrained_model = os.path.join("deepedit_left_atrium.pt")
ckpt = torch.load(pretrained_model, map_location="cpu")
net.load_state_dict(ckpt)
print(ckpt)

Many thanks for this @wyli This solved the incompatibility issue!

Copy link
Copy Markdown
Contributor

@diazandr3s diazandr3s left a comment

Choose a reason for hiding this comment

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

Solves the incompatibility issue

@diazandr3s diazandr3s merged commit 0711e04 into Project-MONAI:dev Jul 6, 2021
@wyli wyli deleted the 2532-backward-comp-dynunet branch July 6, 2021 23:43
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.

resume DynUnet in v0.5.3 for MONAILabel

2 participants