I am trying to use video classifcation from torchvision models. The official code uses kinetics
dataset however when I try to use UCF-101 dataset I am getting these runtime errors. Link to the train code:
Thanks in advace
torch 1.12.0+cu113
torchaudio 0.12.0+cu113
torchvision 0.13.0+cu113
Error:
Traceback (most recent call last):
File "/home/pyler/PycharmProjects/res-ufc101/train.py", line 388, in <module>
main(args)
File "/home/pyler/PycharmProjects/res-ufc101/train.py", line 287, in main
train_one_epoch(model, criterion, optimizer, lr_scheduler, data_loader, device, epoch, args.print_freq, scaler)
File "/home/pyler/PycharmProjects/res-ufc101/train.py", line 24, in train_one_epoch
for video, target in metric_logger.log_every(data_loader, print_freq, header):
File "/home/pyler/PycharmProjects/res-ufc101/utils.py", line 127, in log_every
for obj in iterable:
File "/home/pyler/Python/envs/torch/lib/python3.8/site-packages/torch/utils/data/dataloader.py", line 652, in __next__
data = self._next_data()
File "/home/pyler/Python/envs/torch/lib/python3.8/site-packages/torch/utils/data/dataloader.py", line 1347, in _next_data
return self._process_data(data)
File "/home/pyler/Python/envs/torch/lib/python3.8/site-packages/torch/utils/data/dataloader.py", line 1373, in _process_data
data.reraise()
File "/home/pyler/Python/envs/torch/lib/python3.8/site-packages/torch/_utils.py", line 461, in reraise
raise exception
RuntimeError: Caught RuntimeError in DataLoader worker process 0.
Original Traceback (most recent call last):
File "/home/pyler/Python/envs/torch/lib/python3.8/site-packages/torch/utils/data/_utils/worker.py", line 302, in _worker_loop
data = fetcher.fetch(index)
File "/home/pyler/Python/envs/torch/lib/python3.8/site-packages/torch/utils/data/_utils/fetch.py", line 49, in fetch
data = [self.dataset[idx] for idx in possibly_batched_index]
File "/home/pyler/Python/envs/torch/lib/python3.8/site-packages/torch/utils/data/_utils/fetch.py", line 49, in <listcomp>
data = [self.dataset[idx] for idx in possibly_batched_index]
File "/home/pyler/Python/envs/torch/lib/python3.8/site-packages/torchvision/datasets/ucf101.py", line 128, in __getitem__
video = self.transform(video)
File "/home/pyler/PycharmProjects/res-ufc101/presets.py", line 26, in __call__
return self.transforms(x)
File "/home/pyler/Python/envs/torch/lib/python3.8/site-packages/torchvision/transforms/transforms.py", line 94, in __call__
img = t(img)
File "/home/pyler/Python/envs/torch/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1130, in _call_impl
return forward_call(*input, **kwargs)
File "/home/pyler/Python/envs/torch/lib/python3.8/site-packages/torchvision/transforms/transforms.py", line 269, in forward
return F.normalize(tensor, self.mean, self.std, self.inplace)
File "/home/pyler/Python/envs/torch/lib/python3.8/site-packages/torchvision/transforms/functional.py", line 360, in normalize
return F_t.normalize(tensor, mean=mean, std=std, inplace=inplace)
File "/home/pyler/Python/envs/torch/lib/python3.8/site-packages/torchvision/transforms/functional_tensor.py", line 959, in normalize
tensor.sub_(mean).div_(std)
RuntimeError: The size of tensor a (240) must match the size of tensor b (3) at non-singleton dimension 1