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