How to get scores for every class in a prediction?
See original GitHub issue❓ How to get scores for every class in a prediction?
Hi,
This is my first time working with Detectron. I was able to successfully train Detectron2 with the YYMNIST dataset and perform object detection. https://github.com/YunYang1994/yymnist
I followed the code given in the colab notebook “Detectron2 Beginner’s Tutorial”
When predicting an image, an output in this form is given:
{'instances': Instances(num_instances=5, image_height=416, image_width=416, fields=[pred_boxes = Boxes(tensor([[245.0660, 358.4699, 296.7320, 410.1265], [ 20.2345, 102.6405, 47.9937, 130.1340], [ 21.0728, 21.5609, 75.9807, 76.8252], [139.2570, 246.3593, 245.1878, 362.6366], [ 4.7351, 189.9029, 83.4705, 273.8712]], device='cuda:0')), scores = tensor([0.9717, 0.9716, 0.9358, 0.8979, 0.7177], device='cuda:0'), pred_classes = tensor([7, 1, 1, 0, 2], device='cuda:0'), ])}
The detection scores, only give me a single score per predicted class. Is there a way for me to get the full softmax vector for each prediction?
For example, in this format:
Predicted digit: 8, Scores [0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.9, 0.02]
First element in scores being the prob for digit 0, last element 9. [0-9]
Where do I have to look? I was able to obtain these vectors in the matteport implementation of Mask R-CNN using their “step-by-step prediction”-example. Is it possible to do a step-by-step prediction in Detectron2 too?
Thank you! Let me know if more info is needed.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:6
Top GitHub Comments
Hi, Sebastian. I guess your code may not work since
score_all
has not been filtered asscores
, soresult
will not accept the faulty dimension. Below are my codes that keepscore_all
as a separate field inresult
which run successfully. By the way, I’m new to torch, so I’m not sure if the first round filtering using transformedfilter_mask
is the most efficient way.To get all the scores, replace the
def fast_rcnn_inference_single_image
function with this: