1. Learn
  2. /
  3. Courses
  4. /
  5. Deep Learning for Images with PyTorch

Connected

Exercise

Displaying soft masks

In the previous exercise, you have learned that the top two most likely objects the Mask R-CNN model has segmented are both cats. Now, you will display the masks for these two cats overlaid on top of the original image to visually verify their accuracy. This will require iterating over the two masks, and for each of them, plotting the original image followed by a semi-transparent mask on top of it.

Instructions

100 XP
  • Extract masks and labels from the prediction, assigning them to masks and labels, respectively.
  • Inside the for-loop, display the i-th mask over the image by passing mask[i, 0] to the plotting function, using the "jet" color map and setting the transparency parameter to 0.5.