Hello all,
greetings! I would like to implement just FastRCNNPredictor part in the object detection finetuning tutorial. I made the change in __getitem__
as labels = torch.as_tensor(obj_ids, dtype=torch.int64)
as per Mask-RCNN tutorial one-line change suggestion · Issue #960 · pytorch/tutorials · GitHub
After I run the code initially I got error at train_one_epoch(model, optimizer, data_loader, device, epoch, print_freq=10)
as,
CUDA error: device-side assert triggered
… which I overcome by simply changing device from cuda to cpu.
Now I face error at the same line of code as, `
IndexError: Target 2 is out of bounds.
The changes I made in the tutorial code so far are, labels
(as I mentioned above), I removed mask part from get_model_instance_segmentation
and I also changed all batch_size=1
and num_workers=0
.
The traces of the error are as follows,
File "/../py.py", line **, in <module>
train_one_epoch(model, optimizer, data_loader, device, epoch, print_freq=10)
File "/../engine.py", line 31, in train_one_epoch
loss_dict = model(images, targets)
File "/../torch/nn/modules/module.py", line 1110, in _call_impl
return forward_call(*input, **kwargs)
File "/../torchvision/models/detection/generalized_rcnn.py", line 99, in forward
detections, detector_losses = self.roi_heads(features, proposals, images.image_sizes, targets)
File "/../torch/nn/modules/module.py", line 1110, in _call_impl
return forward_call(*input, **kwargs)
File "/../torchvision/models/detection/roi_heads.py", line 759, in forward
loss_classifier, loss_box_reg = fastrcnn_loss(class_logits, box_regression, labels, regression_targets)
File "/../torchvision/models/detection/roi_heads.py", line 32, in fastrcnn_loss
classification_loss = F.cross_entropy(class_logits, labels)
File "/../torch/nn/functional.py", line 2996, in cross_entropy
return torch._C._nn.cross_entropy_loss(input, target, weight, _Reduction.get_enum(reduction), ignore_index, label_smoothing)
IndexError: Target 2 is out of bounds.
I would like to know, did anyone also face the same problem while executing the tutorial. It would be very helpful if someone could direct me to overcome this problem in the same. thank you in advance…