Tutorial: Object Detection Finetuning

Hi there,
i am new to Objetct Detection and i tried the PyTorch Turorial Object Detection Finetuning. At the end of the Tutorial I can choose an image of the test dataset and I see the prediction. I checked out some pictures and looked at the prediction with the result that only one of the Person is detected. Is there any possibility to change the code that all person with a score higher than 80% will be shown?

Thanks for your help.

1 Like

At the end the tutorial uses something like prediction[0]['masks'][0, 0] to get a mask.

So taking the boolean selector tensor preds_to_keep = prediction[0]['scores'] > 0.8
and then indexing the masks as prediction[0]['masks'][preds_to_keep, 0]. should do the trix. use .max(dim=0).values or so to take the maximum over all masks.

Best regards

Thomas

1 Like

Thanks for help.
If I type this:

preds_to_keep = prediction[0]['scores'] > 0.8
Image.fromarray(prediction[0]['masks'][preds_to_keep, 0].mul(255).byte().cpu().numpy())

I get the error message: TypeError: Cannot handle this data type: (1, 1, 512), |u1

I think you need to throw in a .max(dim=0).values before the mul.

Thanks, now it works.