How to get the scores from torchvision fasterRCNN based on an image and bounding box coordinates


I am using torchvision.models.detection.fasterrcnn_resnet50_fpn(pretrained=True) for object detection. Now this method gives me the scores as one of the outputs. Now i have the co-ordinates of the bounding box, so i want to get the scores based on that image and the bounding box.
For example, i want to do something like this =>
num_classes = 2

in_features = model.roi_heads.box_predictor.cls_score.in_features

model.roi_heads.box_predictor = FastRCNNPredictor(in_features, num_classes)
chkpt_path = "/chkpt_path"
images, target = iter(val_data_loaders).next()
images = list(, dtype=torch.float) for image in images)
[outputs = model(images)] # replace this with the following
outputs = model(images, precomputed_bbox)

Please suggest me how to do this? I want the score from this

I’m not sure that I clearly understand your problem.

You want to get the scores of your custom bboxes from the image, right?
I think it is hard to get because inside the model, there are several modules that generate anchors and cutout the boxes which has a score under threshold and NMS…

So, i have an image and a bbox, all i want a score of the image inside the bbox from the model taking the input and bbox