Replies: 1 comment
-
Hi @chrisiwu, we didn't support dynamically passing a value to a transform in a compose. For images with different resolutions maybe you could use |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Is it somehow possible to pass a value to a transform in a compose dynamically? In my case I want to set the parameter "num_samples" in "RandCropByPosNegLabeld" dynamically. If the resolution of the image is higher it should be higher and vice versa.
Here the relevant part of my code:
train_files = [{"img": img, "seg": seg, "samples": samples} for img, seg, samples in data_list[:number_train]]
train_transforms = Compose([LoadImaged(keys = ["img", "seg"]), EnsureChannelFirstd(keys = ["img", "seg"]), ScaleIntensityd(keys = ["img", "seg"]), SpatialPadd(keys = ["img", "seg"], spatial_size = [96, 96, 96]), RandCropByPosNegLabeld(keys = ["img", "seg"], label_key = "seg", spatial_size = [96, 96, 96], pos = 1, neg = 1, num_samples = 4)])
train_ds = Dataset(data = train_files, transform = train_transforms)
train_loader = DataLoader(train_ds, batch_size = 2, shuffle = True, num_workers = 4, collate_fn = list_data_collate, pin_memory = torch.cuda.is_available())
Beta Was this translation helpful? Give feedback.
All reactions