Segmentation
CSC3104 · Lab

Paint a mask: IoU vs Dice

Paint a segmentation mask against a ground truth and watch IoU and Dice respond to every brush stroke — and confirm the identity linking them.

  1. 1 · Predict0/1
  2. 2 · Experiment0/2
  3. 3 · Explain0/1
  4. 4 · Code it0/1
  5. 5 · Challenge
  6. 0/4 tasks done

Predict first

Commit to a guess before you touch anything. Being wrong here is how it sticks.

A mask has IoU = 0.60. What's its Dice coefficient? (2 dp)

Experiment

Move the controls and watch the outputs. Goals tick off automatically when you reach them.

Paint your prediction

Dashed outline = ground truth · orange = true positive · pink = false positive · blue = missed

TP
0
FP
0
FN
0
IoU
0.000
Dice
0.000
Check the identity
2·0.000 / (1 + 0.000) = 0.000
Dice = 2·IoU / (1 + IoU) — always ≥ IoU

Explain it

Put what you saw into words. This is what the exam will ask you to do.

Why are skip connections essential in U-Net, and how do IoU and Dice differ?

Code it

Write real code against real data. Python and SQL run right here in your browser and hidden tests check your work; the AI reviews it like an examiner.

Pythoncore

IoU, Dice and mean IoU for masks

Write:

  • iou(pred, gt) and dice(pred, gt) for binary masks (booleans or 0/1). If both masks are empty, return 1.0.
  • mean_iou(pred, gt, num_classes) for multi-class label maps: average the per-class IoU over the classes that appear in gt or pred.

Verify dice == 2·iou / (1 + iou) on any example.

Ctrl/⌘ + Enter to run

Challenge

Fixed variations, a new problem every day, and unlimited AI challenges built from your current settings.

IoU to Dice Conversion

A predicted segmentation mask has IoU = 0.50 with the ground truth. What is its Dice coefficient? (2 decimals)