#๐Ÿ”’ Monai error in loading tif images

5 messages ยท Page 1 of 1 (latest)

nova vessel
#
path = '/content/drive/MyDrive/Data/dataset'
train_images = sorted(glob.glob(os.path.join(path, "images", "*.tif")))
train_labels = sorted(glob.glob(os.path.join(path, "masks", "*.tif")))
data_dicts = [{"image": image_name, "label": label_name} for image_name, label_name in zip(train_images, train_labels)]
train_data_dicts, val_data_dicts = data_dicts[:-9], data_dicts[-9:]

from torch.utils.data import DataLoader

data_loader = DataLoader(train_data_dicts)
for training_sample in data_loader:
    # run the deep learning training with training_sample
    image = training_sample['image']
    label = training_sample['label']

    print(image)
    print(label)
    break

loader = LoadImaged(keys=("image", "label"), image_only=False)


data_dict = loader(train_data_dicts[0])
# print(f"input:, {train_data_dicts[0]}")
print(f"image shape: {data_dict['image'].shape}")
print(f"label shape: {data_dict['label'].shape}")

I'm following a Monai tutorial for 3D data augmentation for segmentation which I have 3D greyscale images and masks in TIFF format

Monai tutorial i'm following:
https://github.com/Project-MONAI/tutorials/blob/main/modules/3d_image_transforms.ipynb

GitHub

MONAI Tutorials. Contribute to Project-MONAI/tutorials development by creating an account on GitHub.

obsidian currentBOT
#

@nova vessel

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

nova vessel
#

i've tried doing pip install 'monai[tifffile]' from the error link but that doesnt work

obsidian currentBOT
#

@nova vessel

Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.