size miss match in 'target' when transforming
YHaJung opened this issue · 5 comments
When I do sh run.sh, the below error is occured.
How can I fix it?
Traceback (most recent call last):
File "main_open_world.py", line 365, in
main(args)
File "main_open_world.py", line 289, in main
model, criterion, data_loader_train, optimizer, device, epoch, args.nc_epoch, args.clip_max_norm)
File "(mypath)/workspace/OW-DETR/engine.py", line 83, in train_one_epoch
samples, targets = prefetcher.next()
File "(mypath)/workspace/OW-DETR/datasets/data_prefetcher.py", line 62, in next
self.preload()
File "(mypath)/workspace/OW-DETR/datasets/data_prefetcher.py", line 25, in preload
self.next_samples, self.next_targets = next(self.loader)
File "(mypath)/anaconda3/envs/owdetr/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 517, in next
data = self._next_data()
File "(mypath)/anaconda3/envs/owdetr/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 1199, in _next_data
return self._process_data(data)
File "(mypath)/anaconda3/envs/owdetr/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 1225, in _process_data
data.reraise()
File "(mypath)/anaconda3/envs/owdetr/lib/python3.7/site-packages/torch/_utils.py", line 429, in reraise
raise self.exc_type(msg)
RuntimeError: Caught RuntimeError in DataLoader worker process 0.
Original Traceback (most recent call last):
File "(mypath)/anaconda3/envs/owdetr/lib/python3.7/site-packages/torch/utils/data/_utils/worker.py", line 202, in _worker_loop
data = fetcher.fetch(index)
File "(mypath)/anaconda3/envs/owdetr/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 "(mypath)/anaconda3/envs/owdetr/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 "(mypath)/workspace/OW-DETR/datasets/torchvision_datasets/open_world.py", line 252, in getitem
img, target = self.transforms[-1](img, target)
File "(mypath)/workspace/OW-DETR/datasets/transforms.py", line 275, in call
image, target = t(image, target)
File "(mypath)/workspace/OW-DETR/datasets/transforms.py", line 232, in call
return self.transforms1(img, target)
File "(mypath)/workspace/OW-DETR/datasets/transforms.py", line 207, in call
return resize(img, target, size, self.max_size)
File "(mypath)/workspace/OW-DETR/datasets/transforms.py", line 125, in resize
scaled_boxes = boxes * torch.as_tensor([ratio_width, ratio_height, ratio_width, ratio_height])
RuntimeError: The size of tensor a (0) must match the size of tensor b (4) at non-singleton dimension 0
hi,I have the same problem, have you solved it?
Hello, I'm encountering the same issue. Have you found a solution for it?
hi, have you solved it?have the same problem.
same error!
Traceback (most recent call last):
File "main_open_world.py", line 366, in
main(args)
File "main_open_world.py", line 290, in main
model, criterion, data_loader_train, optimizer, device, epoch, args.nc_epoch, args.clip_max_norm)
File "/home/dgp/code/OW-DETR/engine.py", line 41, in train_one_epoch
samples, targets = prefetcher.next()
File "/home/dgp/code/OW-DETR/datasets/data_prefetcher.py", line 65, in next
self.preload()
File "/home/dgp/code/OW-DETR/datasets/data_prefetcher.py", line 25, in preload
self.next_samples, self.next_targets = next(self.loader)
File "/home/dgp/anaconda3/envs/owdetr/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 517, in next
data = self._next_data()
File "/home/dgp/anaconda3/envs/owdetr/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 557, in _next_data
data = self._dataset_fetcher.fetch(index) # may raise StopIteration
File "/home/dgp/anaconda3/envs/owdetr/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/dgp/anaconda3/envs/owdetr/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/dgp/code/OW-DETR/datasets/torchvision_datasets/open_world.py", line 245, in getitem
img, target = self.transforms[-1](img, target)
File "/home/dgp/code/OW-DETR/datasets/transforms.py", line 276, in call
image, target = t(image, target)
File "/home/dgp/code/OW-DETR/datasets/transforms.py", line 234, in call
return self.transforms2(img, target)
File "/home/dgp/code/OW-DETR/datasets/transforms.py", line 276, in call
image, target = t(image, target)
File "/home/dgp/code/OW-DETR/datasets/transforms.py", line 208, in call
return resize(img, target, size, self.max_size)
File "/home/dgp/code/OW-DETR/datasets/transforms.py", line 126, in resize
scaled_boxes = boxes * torch.as_tensor([ratio_width, ratio_height, ratio_width, ratio_height])
RuntimeError: The size of tensor a (0) must match the size of tensor b (4) at non-singleton dimension 0
Has anyone solved it?
hi anyone who solved this problem??