I have implemented a FasterRCNN and I want to use it on COCO dataset but there is a problem inside the implementation of the PyTorch module. Whenever I pass to the model an image without objects (bboxes is an empy list) the model crashes when it tries to unpack the boxes coordinates.
The model I have used:
model = torchvision.models.detection.fasterrcnn_resnet50_fpn(pretrained=True)
in_features = model.roi_heads.box_predictor.cls_score.in_features
model.roi_heads.box_predictor = FastRCNNPredictor(in_features, num_classes)
The lines of code with the error in torchvision/models/detection/transform.py line 220:
xmin, ymin, xmax, ymax = boxes.unbind(1)
xmin = xmin * ratio_width
xmax = xmax * ratio_width
ymin = ymin * ratio_height
ymax = ymax * ratio_height
return torch.stack((xmin, ymin, xmax, ymax), dim=1)
here boxes is an empty list and so the unbind() fails to unpack. Someone can help me? For what I can see it seems to be a bad implementation of the module