I’m kind of new to Pytorch so sorry if the question makes no sense.
I’m trying to build a simple Convnet for object detection on the PascalVOC dataset.
I run into the following error :
Traceback (most recent call last):
loss = criterion(labels, outputs)
File “C:\Users\Sofiane\anaconda3\lib\site-packages\torch\nn\modules\module.py”, line 727, in _call_impl
result = self.forward(*input, **kwargs)
File “C:\Users\Sofiane\anaconda3\lib\site-packages\torch\nn\modules\loss.py”, line 629, in forward
return F.binary_cross_entropy_with_logits(input, target,
File “C:\Users\Sofiane\anaconda3\lib\site-packages\torch\nn\functional.py”, line 2579, in binary_cross_entropy_with_logits
if not (target.size() == input.size()):
AttributeError: ‘dict’ object has no attribute ‘size’
When I try to run this snippet :
criterion = torch.nn.BCEWithLogitsLoss()

and later call :
    for i, data in enumerate(train_loader):

        images, labels = data

        images = images.to(device)

        outputs = model(images)
        loss = criterion(outputs, labels)

I tried printing out labels and I get the following
{‘annotation’: {‘filename’: [‘2009_000133.jpg’], ‘folder’: [‘VOC2012’], ‘object’: [{‘name’: [‘aeroplane’], ‘bndbox’: {‘xmax’: [‘383’], ‘xmin’: [‘111’], ‘ymax’: [‘234’], ‘ymin’: [‘144’]}, ‘difficult’: [‘0’], ‘occluded’: [‘0’], ‘pose’: [‘Unspecified’], ‘truncated’: [‘0’]}], ‘segmented’: [‘1’], ‘size’: {‘depth’: [‘3’], ‘height’: [‘273’], ‘width’: [‘500’]}, ‘source’: {‘annotation’: [‘PASCAL VOC2009’], ‘database’: [‘The VOC2009 Database’], ‘image’: [‘flickr’]}}}
So I’m wondering what I’m doing wrong.