Skip to content

inverse lazily applied cropforeground with k_divisible>1 #6404

@wyli

Description

@wyli

Describe the bug

import torch
import monai.transforms as t
from monai.transforms.lazy.functional import apply_transforms

img = torch.tensor([[[0, 0, 0, 0, 0], [0, 1, 2, 1, 0], [0, 2, 3, 2, 0], [0, 1, 2, 1, 0], [0, 0, 0, 0, 0]]])

kwargs = {"select_fn": lambda x: x > 0, "channel_indices": None, "margin": 0, "k_divisible": 10}
xform = t.CropForeground(**kwargs)
xform.lazy_evaluation = True
pending_result = xform(img)
result = apply_transforms(pending_result, mode="nearest")[0]
print(xform.inverse(result))

error:

monai/transforms/inverse.py", line 258, in check_transforms_match
    raise RuntimeError(
RuntimeError: Error CropForeground getting the most recently applied invertible transform Pad 140360605105696 != 140360605208640.

cc @KumoLiu

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions