a-PyTorch-Tutorial-to-Object-Detection icon indicating copy to clipboard operation
a-PyTorch-Tutorial-to-Object-Detection copied to clipboard

eval.py bugs

Open AnhNguyenUK opened this issue 5 years ago • 4 comments

Hi, i am facing the problem with the evaluation step to get the mAP scores. The detail of error: File "C:\Users\ADMIN\anaconda3\envs\Pytorch\lib\site-packages\torch\utils\data\dataloader.py", line 345, in next data = self._next_data() File "C:\Users\ADMIN\anaconda3\envs\Pytorch\lib\site-packages\torch\utils\data\dataloader.py", line 856, in _next_data return self._process_data(data) File "C:\Users\ADMIN\anaconda3\envs\Pytorch\lib\site-packages\torch\utils\data\dataloader.py", line 881, in _process_data data.reraise() File "C:\Users\ADMIN\anaconda3\envs\Pytorch\lib\site-packages\torch_utils.py", line 395, in reraise raise self.exc_type(msg) RuntimeError: Caught RuntimeError in DataLoader worker process 0. Original Traceback (most recent call last): File "C:\Users\ADMIN\anaconda3\envs\Pytorch\lib\site-packages\torch\utils\data_utils\worker.py", line 178, in _worker_loop data = fetcher.fetch(index) File "C:\Users\ADMIN\anaconda3\envs\Pytorch\lib\site-packages\torch\utils\data_utils\fetch.py", line 44, in fetch data = [self.dataset[idx] for idx in possibly_batched_index] File "C:\Users\ADMIN\anaconda3\envs\Pytorch\lib\site-packages\torch\utils\data_utils\fetch.py", line 44, in data = [self.dataset[idx] for idx in possibly_batched_index] File ".\a-PyTorch-Tutorial-to-Object-Detection\datasets.py", line 56, in getitem image, boxes, labels, difficulties = transform(image, boxes, labels, difficulties, split=self.split) File ".\a-PyTorch-Tutorial-to-Object-Detection\utils.py", line 705, in transform new_image, new_boxes = resize(new_image, new_boxes, dims=(300, 300)) File ".\a-PyTorch-Tutorial-to-Object-Detection\utils.py", line 616, in resize new_boxes = boxes / old_dims # percent coordinates RuntimeError: The size of tensor a (0) must match the size of tensor b (4) at non-singleton dimension 1

Are there any idea? Someone said that this is the bug of torch library, but i am not sure. The training and detect work well.

AnhNguyenUK avatar Jun 04 '20 16:06 AnhNguyenUK

This is mean there is (at least) one img in your dataset doesn't contain any bbox.

NguyenVanThanhHust avatar Oct 02 '20 02:10 NguyenVanThanhHust

@NguyenVanThanhHust , @AnhNguyenUK , I face with same error, how can I fix it? thank you

home/faridbala/anaconda3/lib/python3.7/site-packages/torch/serialization.py:658: SourceChangeWarning: source code of class 'torch.nn.modules.conv.Conv2d' has changed. you can retrieve the original source code by accessing the object's source attribute or set torch.nn.Module.dump_patches = True and use the patch tool to revert the changes. warnings.warn(msg, SourceChangeWarning) /home/faridbala/anaconda3/lib/python3.7/site-packages/torch/serialization.py:658: SourceChangeWarning: source code of class 'torch.nn.modules.pooling.MaxPool2d' has changed. you can retrieve the original source code by accessing the object's source attribute or set torch.nn.Module.dump_patches = True and use the patch tool to revert the changes. warnings.warn(msg, SourceChangeWarning) Evaluating: 0%| | 0/78 [00:00<?, ?it/s] Traceback (most recent call last): File "eval.py", line 89, in evaluate(test_loader, model) File "eval.py", line 54, in evaluate for i, (images, boxes, labels, difficulties) in enumerate(tqdm(test_loader, desc='Evaluating')): File "/home/faridbala/anaconda3/lib/python3.7/site-packages/tqdm/std.py", line 1167, in iter for obj in iterable: File "/home/faridbala/anaconda3/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 435, in next data = self._next_data() File "/home/faridbala/anaconda3/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 1085, in _next_data return self._process_data(data) File "/home/faridbala/anaconda3/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 1111, in _process_data data.reraise() File "/home/faridbala/anaconda3/lib/python3.7/site-packages/torch/_utils.py", line 428, in reraise raise self.exc_type(msg) RuntimeError: Caught RuntimeError in DataLoader worker process 0. Original Traceback (most recent call last): File "/home/faridbala/anaconda3/lib/python3.7/site-packages/torch/utils/data/_utils/worker.py", line 198, in _worker_loop data = fetcher.fetch(index) File "/home/faridbala/anaconda3/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 "/home/faridbala/anaconda3/lib/python3.7/site-packages/torch/utils/data/_utils/fetch.py", line 44, in data = [self.dataset[idx] for idx in possibly_batched_index] File "/home/faridbala/Desktop/person/a-PyTorch-Tutorial-to-Object-Detection/datasets.py", line 53, in getitem image, boxes, labels, difficulties = transform(image, boxes, labels, difficulties, split=self.split) File "/home/faridbala/Desktop/person/a-PyTorch-Tutorial-to-Object-Detection/utils.py", line 636, in transform new_image, new_boxes = resize(new_image, new_boxes, dims=(300, 300)) File "/home/faridbala/Desktop/person/a-PyTorch-Tutorial-to-Object-Detection/utils.py", line 549, in resize new_boxes = boxes / old_dims # percent coordinates RuntimeError: The size of tensor a (0) must match the size of tensor b (4) at non-singleton dimension 1

rttariverdi67 avatar Dec 19 '20 11:12 rttariverdi67

@rttariverdi67 Did you check your dataset? Is the image creating this error readable? How many channel does it have?

NguyenVanThanhHust avatar Dec 19 '20 13:12 NguyenVanThanhHust

@NguyenVanThanhHust thank you for your help, It was exactly the problem, The image didn't contain any class! I deleted and it works.

rttariverdi67 avatar Dec 19 '20 19:12 rttariverdi67