What difference bettween these two type of tensor?

I am confused about the #2 type of tensor, how can I get its list type? For example, I can get the list type of predictions by predictions.tolist(), what about #2?

print(predictions) #return #1
print(bboxes) #return #2
>>>tensor([0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 0, 0], device='cuda:0') #1
>>>Boxes(tensor([[ 56.6679, 568.2880, 297.5019, 697.3653],             #2
        [315.3174, 556.3110, 555.8267, 720.8016],
        [ 56.5737, 134.1078, 497.3640, 165.2118]], device='cuda:0'))

>Solution :

It seems like you are running an object detection model (e.g., YoLo, RCNN, etc.).
These models predict, for each detected box, its class (predictions in your case), and the bounding box this object occupies in the image (bboxes in your case).

The bboxes prediction uses a project-specific class Boxes. You should refer to the specific code you are running to see how this class is defined and how to iterate it.

Please note that in many object-detection frameworks, some of the returned bboxes are "background": that is they do not contain an actual object. Again, this is implementation dependant and you should know how the model you are using behaves.

Leave a Reply