Description
🐛 Bug
Before I report my issue, I'd like to say that the TorchVision Object Detection Finetuning tutorial is excellent! I've found the code to be easy to work with, but the tutorial made it even more accessible -- it got me training on my custom dataset in just a few hours (including making my own Docker image with GPU support).
The CocoDetection dataset appears to be incompatible with the Faster R-CNN model. The TorchVision Object Detection Finetuning tutorial specifies the format of datasets to be compatible with the Mask R-CNN model: datasets' getitem method should output an image and a target with fields boxes, labels, area, etc. The CocoDetection dataset returns the COCO annotations as the target, which does not match the dataset specification.
The evaluation code included with the tutorial (engine.evaluate
) also appears to be incompatible with the built-in CocoDetection dataset format.
To Reproduce
Steps to reproduce the behavior:
Follow the steps in the TorchVision Object Detection Finetuning tutorial substituting a dataset with COCO annotations and using torchvision.datasets.CocoDetection as the dataset class instead of the custom dataset class defined in the tutorial. I hit an error within the train_one_epoch
function in engine.py.
The error message is below.
File "references/detection/engine.py", line 28, in
targets = [{k: v.to(device) for k, v in t.items()} for t in targets]
AttributeError: 'list' object has no attribute 'items'
Expected behavior
I expected training and evaluation to run successfully when using torchvision.datasets.CocoDetection
. I was able to run training and evaluation by making my own custom COCO dataset class and manipulating the target output to match the specified format.
Environment
Collecting environment information...
PyTorch version: 1.6.0+cu101
Is debug build: False
CUDA used to build PyTorch: 10.1
ROCM used to build PyTorch: N/A
OS: Ubuntu 18.04.5 LTS (x86_64)
GCC version: (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0
Clang version: Could not collect
CMake version: Could not collect
Python version: 3.7 (64-bit runtime)
Is CUDA available: True
CUDA runtime version: Could not collect
GPU models and configuration: GPU 0: Quadro T2000
Nvidia driver version: 430.64
cuDNN version: Could not collect
HIP runtime version: N/A
MIOpen runtime version: N/A
Versions of relevant libraries:
[pip3] numpy==1.19.2
[pip3] torch==1.6.0+cu101
[pip3] torchvision==0.7.0+cu101
[conda] Could not collect
Additional context
None
cc @pmeier