Project-MONAI / Project-MONAI/MONAI

`Lazy=True` ignored when using nested `Compose`

Open
#7,146 6 comments 0 reactions 1 assignee View on GitHub

@atbenmurray is already working on this.

Since Jan 19, 2024.

bug
Dominant language
Python
Stars
8.7k
Forks
1.6k
Avg merge
5d 1h
Merged PRs (30d)
20

Description

Describe the bug
Lazy=True ignored when using nested Compose

To Reproduce

import monai.transforms as mt
from monai.data import Dataset

d = {"image": "/workspace/Code/MONAI/tests/testing_data/ref_avg152T1_LR.nii.gz"}

trans = mt.Compose(
        [
            mt.Flipd(keys="image", spatial_axis=1),
            mt.NormalizeIntensityd(keys=["image"]),
            mt.CenterSpatialCropd(keys=["image"], roi_size=(30, 30, 20)),
        ],
        lazy=True,
        log_stats=True
    )
xform = mt.Compose(
    [
        mt.LoadImaged(keys="image", ensure_channel_first=True),
        trans,
        mt.RandAffined(keys="image", prob=1.0, rotate_range=45.0, translate_range=10.0, scale_range=0.15),
    ],
    log_stats=True,
)
out_1 = xform(d)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.