Spatial predictions and generation / 4 of 6

Image segmentation

8 minOpening your notebook…

What you’ll learn

  • Explain the main idea of “Image segmentation” in your own words.
  • Trace a concrete example and identify the assumptions behind it.
  • Apply the principle in a practice problem and recognize a common failure.

The idea, intuitively

Segmentation assigns labels at pixel level. Semantic segmentation labels categories, while instance segmentation distinguishes individual objects of the same category. This gives finer spatial information than boxes.

Begin with the numeric image representation and the exact target the model must predict. Image classification, detection, and segmentation use different labels and evaluation rules. Changes in lighting, camera, geography, and resolution can create distribution shifts even when the subject appears unchanged to a person.

Under the hood

Dense prediction models output a spatial map aligned with the input. Pixel accuracy can hide failure on small regions, so class IoU or Dice scores often give a more useful picture.

A useful caution

Annotation boundaries can be ambiguous and should be accounted for in evaluation.

A worked example

In a road scene, semantic masks label all cars as car; instance masks assign each car a distinct identity.

How to use this way of thinking

Inspect inputs after preprocessing, not only the original files. Visualize labels and predictions together. Evaluate small objects, rare classes, and unfamiliar capture conditions separately. If a transformation changes the label meaning, it is not a valid augmentation for that task.

Try it yourself

Why can pixel accuracy mislead when a target occupies 1% of an image?

Key takeaways

  • Instance segmentation
  • Annotation boundaries can be ambiguous and should be accounted for in evaluation.
  • Check the assumptions with a small example before applying this idea to a larger system.

Check your understanding

0/2 checked

Use feedback to learn. Quiz scores and lesson completion are tracked separately.

1Which task distinguishes two neighboring cars?
2True or false: Semantic segmentation necessarily distinguishes individual objects of the same category.
Go to lesson completion

Further reading

Original papers and reference material for this school. External resources may be in English and require internet access.

Stanford CS231n notes (opens a new tab)Hugging Face Diffusers documentation (opens a new tab)

Finish this lesson

Mark this lesson complete when you’re ready to continue.

Start with a question

Introduction to AIAI FoundationsA brief history of AIAI FoundationsTypes of AIAI FoundationsAI, ML, and deep learningAI FoundationsUnderstanding generative AIAI FoundationsEthics, limitations, and responsibilityAI FoundationsLinear algebra for learning systemsMathematics for AIVectors, matrices, and similarityMathematics for AICalculus: measuring changeMathematics for AIDerivatives and gradientsMathematics for AIProbability and statisticsMathematics for AIOptimization and objectivesMathematics for AI
K to open · Escape to close