for a pretrained object detection model in pytorch and for each bounding box predicted by the model how to get the confidence score for each of the 80 COCO classes for that bounding box?
I have put the code I am using for object detection using pretrained fasterRCNN Resnet-50 FPN model
img = Image.open(img_path) # Load the image
transform = transforms.Compose([transforms.ToTensor()]) # Defing PyTorch Transform
img = transform(img) # Apply the transform to the image
pred = model([img.cuda()]) # Pass the image to the model
pred_class = [COCO_INSTANCE_CATEGORY_NAMES[i] for i in list(pred[0]['labels'].cpu().numpy())] # Get the Prediction Score
pred_boxes = [[(i[0], i[1]), (i[2], i[3])] for i in list(pred[0]['boxes'].cpu().detach().numpy())] # Bounding boxes
pred_score = list(pred[0]['scores'].cpu().detach().numpy())
pred only provides all possible bounding boxes and the best possible class for the bounding box but how to get the confidence score for all possible classes for one bounding box?
Any help will be highly appreciated.