question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TypeError in transforms notebook

See original GitHub issue

Hi all,

I’m trying to run the integrate_3rd_party_transforms notebook on Google Colab, but it’s not working. First, there’s no line to install MONAI. Second, once installed, I get this error when trying to run the last cell:

TypeError                                 Traceback (most recent call last)
<ipython-input-15-dfd10a517436> in <module>()
      2 check_loader = monai.data.DataLoader(check_ds, batch_size=1)
      3 check_data = monai.utils.misc.first(check_loader)
----> 4 image, label = (check_data['image'][0][0], check_data['label'][0][0])
      5 print(f"image shape: {image.shape}, label shape: {label.shape}")
      6 # plot the slice [:, :, 80]

TypeError: 'NoneType' object is not subscriptable

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
Nic-Macommented, Aug 6, 2020

Hi @fepegar ,

We may try to move all notebooks to Colab later, and update to use DecathlonDataset. Because we want to do a new refactoring iteration for datasets to support cross-validation soon, so I haven’t changed notebooks.

Thanks.

0reactions
fepegarcommented, Aug 6, 2020

Hi @Nic-Ma,

We didn’t test this notebook in Colab so far. Could you please help double confirm whether the Decathlon dataset was loaded correctly?

Oh, sorry. I see now that the path to the data was local. I thought the notebook would be self-contained. I think it would be nice that

  1. It was indeed self-contained and one can just press “Run all”. MONAI can download the needed decathlon dataset, is that right?
  2. A warning was raised if the input of a transform was empty. Have you considered this?

And whether version of TorchIO can support dict now? I can update the notebook for this part later.

It does, it was added in https://github.com/fepegar/torchio/commit/19ff6e7568ab2c62e579fd0728571760d3e381c4 and it’s available in v0.17.21 (you can try running the code I shared in https://github.com/Project-MONAI/MONAI/issues/851#issuecomment-669139528). I haven’t added support in the transforms mentioned in the commit, message, but it should be fine for most of them.

If the input is a dict, a keys kwarg must be passed. The values of those keys are expected to be 4D tensors with shape (C, D, H, W). I can adapt them further if that would be helpful.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Torchvision transforms.toPILImage() TypeError: function takes ...
The error comes when transform RandomRotation is invoked and a new instance of Image class is created. Particularly, function core.fill() at ...
Read more >
v0.6.5 TypeError: apply_transform() got an unexpected ...
Hi, I'm using a Colab notebook and since today I was unable to start the code, even though nothing changed. The logged message...
Read more >
Simple Example - | notebook.community
Image Preprocessing transform = transforms. ... RandomHorizontalFlip(), transforms. ... TypeError: 'NoneType' object cannot be interpreted as an integer ...
Read more >
ImageDataBunch.from_df throws when adding transforms tfms ...
In two words, when I add transforms to ImageDataBunch it throws. Same code without transforms works just fine TypeError Traceback (most ...
Read more >
Bug on torchvision.transforms.functional.resize?
'''TypeError: img should be PIL Image. Got <class 'torch.Tensor'>'''. Both notebook running the same version of torchvision 0.7.0.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found