Bird
Raised Fist0
Computer Visionml~8 mins

Mask R-CNN overview in Computer Vision - Model Metrics & Evaluation

Choose your learning style10 modes available
Metrics & Evaluation - Mask R-CNN overview
Which metric matters for Mask R-CNN and WHY

Mask R-CNN is used to find objects and their exact shapes in images. So, we care about how well it finds the right objects and how well it draws their shapes.

The key metrics are:

  • Mean Average Precision (mAP): Measures how well the model finds and correctly labels objects. It combines precision and recall over different thresholds.
  • Intersection over Union (IoU): Measures how closely the predicted mask matches the true object shape. Higher IoU means better shape accuracy.
  • Precision and Recall: Precision tells us how many predicted objects are correct. Recall tells us how many true objects were found.

We use these because Mask R-CNN does two things: detect objects and segment their shapes. Both need to be accurate.

Confusion matrix for object detection

For each object class, we can build a confusion matrix like this:

      | Predicted Object | No Object |
      |------------------|-----------|
      | True Positive (TP) | False Positive (FP) |
      | False Negative (FN) | True Negative (TN) |
    

Example for one class:

      TP = 80 (correctly detected objects)
      FP = 20 (wrongly detected objects)
      FN = 10 (missed objects)
      TN = not usually counted in detection
    

Precision = TP / (TP + FP) = 80 / (80 + 20) = 0.8

Recall = TP / (TP + FN) = 80 / (80 + 10) = 0.89

Precision vs Recall tradeoff in Mask R-CNN

Imagine a security camera detecting people wearing masks. If the model is very strict, it finds fewer people but is usually right (high precision, low recall).

If it is very loose, it finds almost everyone but sometimes mistakes objects for people (high recall, low precision).

For Mask R-CNN, balancing precision and recall is important. Too many false positives (low precision) means wrong objects or masks. Too many false negatives (low recall) means missing objects.

We adjust thresholds to find the best balance for the task.

Good vs Bad metric values for Mask R-CNN

Good values:

  • mAP above 0.7 means the model finds and labels objects well.
  • IoU above 0.5 means the predicted masks closely match true shapes.
  • Precision and recall both above 0.7 means balanced detection.

Bad values:

  • mAP below 0.4 means poor detection and labeling.
  • IoU below 0.3 means masks are not accurate.
  • Precision very low (<0.5) means many false detections.
  • Recall very low (<0.5) means many objects missed.
Common pitfalls in Mask R-CNN metrics
  • Ignoring mask quality: Only checking bounding box accuracy misses mask shape errors.
  • Data leakage: Testing on images seen during training inflates metrics.
  • Overfitting: High training mAP but low test mAP means model memorizes training data.
  • Imbalanced classes: Rare objects may have low recall but high overall accuracy.
  • Threshold choice: Changing detection confidence threshold affects precision and recall.
Self-check question

Your Mask R-CNN model has 98% accuracy but only 12% recall on small objects. Is it good for production?

Answer: No. The model misses most small objects (low recall), so it is not reliable for tasks needing those detections, despite high overall accuracy.

Key Result
Mask R-CNN performance is best judged by mean Average Precision (mAP) and Intersection over Union (IoU), balancing precision and recall for accurate object detection and mask quality.

Practice

(1/5)
1. What is the main purpose of Mask R-CNN in computer vision?
easy
A. To generate captions for images
B. To classify images into categories
C. To enhance image resolution
D. To detect objects and find their exact shapes in images

Solution

  1. Step 1: Understand Mask R-CNN's function

    Mask R-CNN is designed to detect objects and also predict masks that show the exact shape of each object.
  2. Step 2: Compare with other tasks

    Unlike classification or captioning, Mask R-CNN focuses on locating and segmenting objects precisely.
  3. Final Answer:

    To detect objects and find their exact shapes in images -> Option D
  4. Quick Check:

    Mask R-CNN = Object detection + precise shape masks [OK]
Hint: Mask R-CNN = detection + mask prediction [OK]
Common Mistakes:
  • Confusing Mask R-CNN with image classification models
  • Thinking it only detects bounding boxes without masks
  • Assuming it generates image captions
2. Which component is NOT part of the Mask R-CNN architecture?
easy
A. Region Proposal Network (RPN)
B. Mask branch for pixel-level segmentation
C. Recurrent Neural Network (RNN) for sequence modeling
D. Fully Connected Layer for classification

Solution

  1. Step 1: Identify Mask R-CNN components

    Mask R-CNN includes RPN for proposing regions, fully connected layers for classifying objects, and a mask branch for segmentation.
  2. Step 2: Check for unrelated components

    RNNs are used for sequence data like text or speech, not for Mask R-CNN's image segmentation tasks.
  3. Final Answer:

    Recurrent Neural Network (RNN) for sequence modeling -> Option C
  4. Quick Check:

    Mask R-CNN excludes RNNs [OK]
Hint: Mask R-CNN uses CNNs, not RNNs [OK]
Common Mistakes:
  • Thinking RNNs are part of Mask R-CNN
  • Confusing mask branch with classification layers
  • Ignoring the role of RPN
3. Given the following simplified Mask R-CNN output for an image, what does the mask represent?
masks = [[[0,1,1],[0,1,1],[0,0,0]], [[1,0,0],[1,1,0],[0,0,0]]]
Each inner list is a 3x3 mask for one object. What does a '1' indicate?
medium
A. Pixels belonging to the object
B. Background pixels
C. Pixels with low confidence
D. Pixels to be ignored

Solution

  1. Step 1: Understand mask values in Mask R-CNN

    Mask R-CNN outputs masks where '1' marks pixels that belong to the detected object, and '0' marks background.
  2. Step 2: Interpret the given mask arrays

    In the given masks, '1's show the shape of each object in the 3x3 grid.
  3. Final Answer:

    Pixels belonging to the object -> Option A
  4. Quick Check:

    Mask '1' = object pixel [OK]
Hint: '1' in mask means object pixel [OK]
Common Mistakes:
  • Confusing '1' with background
  • Assuming '1' means low confidence
  • Thinking '1' means ignored pixels
4. You run Mask R-CNN but get an error: 'ValueError: mask size mismatch'. What is the most likely cause?
medium
A. The mask output size does not match the region proposal size
B. The input image is grayscale instead of color
C. The model is missing the classification head
D. The learning rate is too high

Solution

  1. Step 1: Understand mask size mismatch error

    This error usually means the predicted mask dimensions don't match the size of the proposed region where the mask should be applied.
  2. Step 2: Check other options

    Input image color or missing classification head won't cause mask size mismatch. Learning rate affects training, not mask size.
  3. Final Answer:

    The mask output size does not match the region proposal size -> Option A
  4. Quick Check:

    Mask size must match proposal size [OK]
Hint: Check mask and proposal sizes match [OK]
Common Mistakes:
  • Blaming input image color for mask size error
  • Ignoring mask and proposal size relation
  • Confusing training hyperparameters with output shape errors
5. You want to improve Mask R-CNN's mask accuracy on small objects in images. Which approach is best?
hard
A. Remove the mask branch and only use bounding boxes
B. Increase the resolution of the feature maps used for mask prediction
C. Use a simpler backbone network to speed up training
D. Reduce the number of region proposals generated by RPN

Solution

  1. Step 1: Identify how to improve mask accuracy for small objects

    Small objects need finer details, so increasing feature map resolution helps the mask branch capture small shapes better.
  2. Step 2: Evaluate other options

    Reducing proposals may miss objects, simpler backbone reduces feature quality, and removing mask branch loses mask prediction entirely.
  3. Final Answer:

    Increase the resolution of the feature maps used for mask prediction -> Option B
  4. Quick Check:

    Higher resolution features = better small object masks [OK]
Hint: Higher feature resolution helps small object masks [OK]
Common Mistakes:
  • Reducing proposals thinking it improves accuracy
  • Using simpler backbone hurting feature quality
  • Removing mask branch losing mask output
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard