TCP icon indicating copy to clipboard operation
TCP copied to clipboard

AssertionError: Expected image to have shape (height, width, [channels]), got shape ().

Open donkehuang opened this issue 1 year ago • 1 comments

When i run the training progress with python TCP/train.py, it works util the "Saving latest checkpoint". When Saving latest checkpoint, it occurs the error that AssertionError: Caught AssertionError in DataLoader worker process 7. Original Traceback (most recent call last): File "/home/donke/anaconda3/envs/TCP/lib/python3.7/site-packages/torch/utils/data/_utils/worker.py", line 287, in _worker_loop data = fetcher.fetch(index) File "/home/donke/anaconda3/envs/TCP/lib/python3.7/site-packages/torch/utils/data/_utils/fetch.py", line 49, in fetch data = [self.dataset[idx] for idx in possibly_batched_index] File "/home/donke/anaconda3/envs/TCP/lib/python3.7/site-packages/torch/utils/data/_utils/fetch.py", line 49, in <listcomp> data = [self.dataset[idx] for idx in possibly_batched_index] File "/home/donke/TCP/TCP/data.py", line 90, in __getitem__ Image.open(self.root+self.front_img[index][0])))) File "/home/donke/anaconda3/envs/TCP/lib/python3.7/site-packages/imgaug/augmenters/meta.py", line 769, in augment_image "got shape %s." % (image.shape,)) AssertionError: Expected image to have shape (height, width, [channels]), got shape (). what should i do, thanks

donkehuang avatar Jan 04 '24 09:01 donkehuang

Hello, I have encountered the same problem,have you resolved it?

qqcole2000 avatar May 11 '24 02:05 qqcole2000

Hello, I have encountered the same problem,have you resolved it?

I have solve this problem which is caused by an image with incorrect format. To solve this bug, you can skip the image with incorrect format or just delete the image in dataset. The specific index of the image is hard for me to remember, but i hope the code for skipping the image may help you. In data.py:88,correct the code like this: if self.img_aug: try: temp = np.array(Image.open(self.root+self.front_img[index][0])) data['front_img'] = self._im_transform(augmenter(self._batch_read_number).augment_image(temp)) except: temp = np.array(Image.open(self.root+self.front_img[0][0])) data['front_img'] = self._im_transform(augmenter(self._batch_read_number).augment_image(temp)) else: try: temp = np.array(Image.open(self.root+self.front_img[index][0])) data['front_img'] = self._im_transform(temp) except: temp = np.array(Image.open(self.root+self.front_img[0][0])) data['front_img'] = self._im_transform(temp)

donkehuang avatar May 12 '24 07:05 donkehuang

Thanks for your reply, it helps me a lot.

qqcole2000 avatar May 13 '24 01:05 qqcole2000