While I learn TorchVision Object Detection Finetuning Tutorial , I download the full source. After running, I got error like this:
Traceback (most recent call last):
File "C:/Users/Sandwich/source/repos/pytorch/Image_and_Video/tv-training-code.py", line 165, in <module>
main()
File "C:/Users/Sandwich/source/repos/pytorch/Image_and_Video/tv-training-code.py", line 156, in main
train_one_epoch(model, optimizer, data_loader, device, epoch, print_freq=10)
File "C:\Users\Sandwich\source\repos\pytorch\Image_and_Video\engine.py", line 28, in train_one_epoch
for images, targets in metric_logger.log_every(data_loader, print_freq, header):
File "C:\Users\Sandwich\source\repos\pytorch\Image_and_Video\utils.py", line 171, in log_every
for obj in iterable:
File "C:\Python38\lib\site-packages\torch\utils\data\dataloader.py", line 521, in __next__
data = self._next_data()
File "C:\Python38\lib\site-packages\torch\utils\data\dataloader.py", line 1203, in _next_data
return self._process_data(data)
File "C:\Python38\lib\site-packages\torch\utils\data\dataloader.py", line 1229, in _process_data
data.reraise()
File "C:\Python38\lib\site-packages\torch\_utils.py", line 425, in reraise
raise self.exc_type(msg)
AttributeError: Caught AttributeError in DataLoader worker process 0.
Original Traceback (most recent call last):
File "C:\Python38\lib\site-packages\torch\utils\data\_utils\worker.py", line 287, in _worker_loop
data = fetcher.fetch(index)
File "C:\Python38\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:\Python38\lib\site-packages\torch\utils\data\_utils\fetch.py", line 44, in <listcomp>
data = [self.dataset[idx] for idx in possibly_batched_index]
File "C:\Python38\lib\site-packages\torch\utils\data\dataset.py", line 311, in __getitem__
return self.dataset[self.indices[idx]]
File "C:\Users\Sandwich\source\repos\pytorch\Image_and_Video\tv-training-code.py", line 77, in __getitem__
img, target = self.transforms(img, target)
File "C:\Users\Sandwich\source\repos\pytorch\Image_and_Video\transforms.py", line 26, in __call__
image, target = t(image, target)
File "C:\Python38\lib\site-packages\torch\nn\modules\module.py", line 1051, in _call_impl
return forward_call(*input, **kwargs)
File "C:\Users\Sandwich\source\repos\pytorch\Image_and_Video\transforms.py", line 37, in forward
width, _ = F.get_image_size(image)
AttributeError: module 'torchvision.transforms.functional' has no attribute 'get_image_size'
I find that the module has a attribute named ‘_get_image_size’, so I amend it. Than I got error like this:
Traceback (most recent call last):
File "C:/Users/Sandwich/source/repos/pytorch/Image_and_Video/tv-training-code.py", line 165, in <module>
main()
File "C:/Users/Sandwich/source/repos/pytorch/Image_and_Video/tv-training-code.py", line 156, in main
train_one_epoch(model, optimizer, data_loader, device, epoch, print_freq=10)
File "C:\Users\Sandwich\source\repos\pytorch\Image_and_Video\engine.py", line 34, in train_one_epoch
loss_dict = model(images, targets)
File "C:\Python38\lib\site-packages\torch\nn\modules\module.py", line 1051, in _call_impl
return forward_call(*input, **kwargs)
File "C:\Python38\lib\site-packages\torchvision\models\detection\generalized_rcnn.py", line 77, in forward
images, targets = self.transform(images, targets)
File "C:\Python38\lib\site-packages\torch\nn\modules\module.py", line 1051, in _call_impl
return forward_call(*input, **kwargs)
File "C:\Python38\lib\site-packages\torchvision\models\detection\transform.py", line 108, in forward
target_index = targets[i] if targets is not None else None
IndexError: list index out of range
Well, I have no idea about how to deal with it.