Hi, I am trying to train rcnn model, but I have few problems when I am using batch_size>1.
My function which make dataset returns a single img tensor and a single target (dictionary):
return (
img,
target,
)
Later I am loading datasets to dataloader which loads data to the training process.
with tqdm(train_loader) as _tqdm:
for x, y in _tqdm:
x = x.to(device)
for key, value in y.items():
y[key] = torch.tensor(value).to(device)
outputs = model(x, y)
When batch_size is f.e. == 2, then x
is a list of two tensors of shape [D, H, W]
but y
is a dict
where every key
have two values. Then occurs error:
.../generalized_rcnn.py", line 64, in forward boxes = target["boxes"] TypeError: string indices must be integers
So I assumed that probably it can’t handle with dictionaries and I pass:
output(x, [y])
Then error changes to:
.../transform.py", line 99, in forward
target_index = targets[i] if targets is not None else None
IndexError: list index out of range
Any ideas how to make it run properly?