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.

Cutout throws 'Image' object has no attribute 'shape'

See original GitHub issue

pytorch-lightning==0.7.6 torchtoolbox==0.1.4.1 torchvision==0.6.0a0+82fd1c8

Loading Images using: img = Image.open(str(IMAGE_DIR ))) # import PIL.Image as Image

Composing Transforms using:

self.transform_train = transforms.Compose([transforms.Resize((224, 224)), 
                                    transforms.RandomHorizontalFlip(0.5),
                                    transforms.RandomVerticalFlip(0.5),      
                                    transforms.ColorJitter(0.4, 0.4, 0.4),
                                    Cutout(),
                                    transforms.ToTensor(),
                                    transforms.Normalize(mean=[0.485, 0.456, 0.406],
                                                                   std=[0.229, 0.224, 0.225])])

Trace: AttributeError: Caught AttributeError in DataLoader worker process 0. Original Traceback (most recent call last): File “/opt/conda/lib/python3.7/site-packages/torch/utils/data/_utils/worker.py”, line 178, in _worker_loop data = fetcher.fetch(index) File “/opt/conda/lib/python3.7/site-packages/torch/utils/data/_utils/fetch.py”, line 44, in fetch data = [self.dataset[idx] for idx in possibly_batched_index] File “/opt/conda/lib/python3.7/site-packages/torch/utils/data/_utils/fetch.py”, line 44, in <listcomp> data = [self.dataset[idx] for idx in possibly_batched_index] File “<ipython-input-30-5eadc434e3d5>”, line 30, in getitem img = self.transform(img) File “/opt/conda/lib/python3.7/site-packages/torchvision/transforms/transforms.py”, line 61, in call img = t(img) File “/opt/conda/lib/python3.7/site-packages/torchtoolbox/transform/transforms.py”, line 1450, in call left, top, h, w, ch = self.get_params(img, self.scale, self.ratio) File “/opt/conda/lib/python3.7/site-packages/torchtoolbox/transform/transforms.py”, line 1433, in get_params img_h, img_w, img_c = img.shape AttributeError: ‘Image’ object has no attribute ‘shape’

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
PistonYcommented, Jun 16, 2020

If you have good idea please make a pr to me.

0reactions
ArthDhcommented, Jun 16, 2020

We could just do a type check and call the function as needed there would be no need to convert the image in that case. Integration with albumentations sounds good!

Read more comments on GitHub >

github_iconTop Results From Across the Web

AttributeError: 'Image' object has no attribute 'shape' #1220
Questions and Help. I'm training my own datasets for instance segmentation on win10 system. And the error information:
Read more >
AttributeError: 'PhotoImage' object has no attribute 'shape'
Converts image from NumPy array to PhotoImage object, and passes the object as argument to landmarks method (that passes it to mpDraw.
Read more >
'Image' object has no attribute 'shape' - vision - PyTorch Forums
So I am trying to build a data augmenter from the ImageFolder loader. But what I have is giving me the 'Image' object...
Read more >
'generator' object has no attribute 'shape' - You.com
I am using a custom data generator, when I try using fit_generator it throws an error saying "object has no attribute 'shape'".
Read more >
Attributeerror: 'nonetype' object has no attribute 'shape'
The error is a result of a function that should return the shape of an image returning None and hence resulting in the...
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