License YOLO
Guides

Semantic vs Instance Segmentation: How to Choose the Right Task

Semantic segmentation labels every pixel by class; instance segmentation separates each object. Learn which one your computer vision project needs, and why.

Miles Deans7 min read

Listen to this article

YOLO26 semantic segmentation of a street scene with a bus and people in Ultralytics Platform, each class shown in its own color

Semantic segmentation and instance segmentation both label images at the pixel level, but they answer different questions. Semantic segmentation assigns a class to every pixel, so all the cars in a scene become one "car" region. Instance segmentation separates each object, so every car gets its own mask. Choosing between them comes down to one question: do you need to know what is at each pixel, or which object each pixel belongs to? This guide helps you make that choice. It also covers what each task costs to label and how each is evaluated. Ultralytics YOLO supports both tasks in the same framework.

The difference in one line#

  • Semantic segmentation classifies every pixel into a category, such as road, sky, person or car. Objects of the same class merge into one region. See the semantic segmentation glossary entry.
  • Instance segmentation finds each individual object and gives it its own mask and ID. It usually covers countable objects and ignores background such as sky or grass. See the instance segmentation glossary entry.

The same city street segmented two ways: Ultralytics YOLO26 semantic segmentation colors every pixel by class, instance segmentation gives each car and person its own mask

Fig 1. The same street with both tasks. Ultralytics YOLO26x-sem (Cityscapes classes) labels every pixel, so all cars share one "car" class. Ultralytics YOLO26x-seg gives each of the 8 cars and 3 people it found its own mask (confidence 0.5 or higher). The photo was generated for this article; the masks are real model outputs.

Which task does your project need?#

Start from the question your application has to answer:

If your application needs to…UseExample
Know how much of the scene is a given classSemanticDrivable road area, crop vs weed coverage, land cover
Label background regions as carefully as objectsSemanticSky, water, vegetation, tissue types in a scan
Count objectsInstanceFruit on a tree, people in a queue
Track objects across video framesInstance, plus a trackerPeople or vehicles moving through a scene
Measure or act on one object at a timeInstanceA robot picking one part from a pile, sizing each defect
Do both: full scene coverage and separate objectsPanopticStreet scenes for autonomous driving

If you're unsure, ask whether two touching objects of the same class must be told apart. If yes, you need instance segmentation (or panoptic). If no, semantic segmentation is simpler and usually cheaper to run.

Seven shoppers standing close together in a supermarket checkout queue: merged person regions in semantic segmentation, seven separate masks in instance segmentation

Fig 2. Seven shoppers standing close together in a checkout queue. In the semantic output (Ultralytics YOLO26x-sem) they merge into two connected "person" regions, so you can't count them from it. The instance output (Ultralytics YOLO26x-seg) separates all 7. The photo was generated for this article; the masks are real model outputs.

Key differences at a glance#

CriteriaSemantic segmentationInstance segmentation
Question answeredWhat class is each pixel?Which object does each pixel belong to?
Objects of the same classMerged into one regionSeparated, each with its own mask and ID
CoverageEvery pixel, including backgroundUsually only the objects of interest
OutputOne class map the size of the imageA list of masks, each with a class and confidence
Can you count objects?Not directlyYes
Main metricmean Intersection over Union (mIoU)Mask mean Average Precision (mask mAP)
Relative complexityLower: per-pixel classificationHigher: detection plus per-object masks

What each task costs to label#

The labeling effort is often what decides the choice in practice.

  • Semantic datasets assign a class to every pixel of every image, background included. They're usually stored as single-channel mask images. Every image is fully labeled, so no pixel can be skipped unless it's explicitly marked "ignore".
  • Instance datasets outline each object of interest separately, as a polygon or mask. Background can be left unlabeled, but every object needs its own outline, and crowded scenes multiply the work.

Both are labor-intensive. Assisted annotation, where a click or a box becomes a mask, cuts the effort for either task. If you only need region-level answers, don't pay for instance labels.

How each task is evaluated#

  • Semantic segmentation is measured mainly with mIoU: the overlap between predicted and true regions, averaged across classes. Pixel accuracy is also reported. IoU is the same overlap measure used in detection.
  • Instance segmentation is measured with mask mAP, the mean Average Precision used for detection but computed on mask overlap. It rewards finding each object, not just covering the right pixels.

These metrics aren't comparable with each other. A high mIoU says nothing about whether individual objects were separated.

Panoptic segmentation: when you need both#

Panoptic segmentation gives every pixel a class and, for countable objects, an instance ID. Background "stuff" such as road and sky is labeled semantically. Foreground "things" such as cars and people are separated one by one. It's measured with Panoptic Quality (PQ). Choose it when you need full scene coverage and per-object separation at once. See panoptic segmentation.

How each works, briefly#

Semantic segmentation models are typically encoder-decoder networks that predict a class for every pixel. U-Net, DeepLab and SegFormer are well-known examples. Instance segmentation models usually build on object detection. Mask R-CNN predicts a mask inside each detected box, while single-stage models such as YOLACT and the Ultralytics YOLO segmentation models predict boxes and masks in one pass for real-time use. Universal architectures such as Mask2Former handle semantic, instance and panoptic segmentation in one model. For more on instance segmentation, see what is instance segmentation.

Both tasks in Ultralytics YOLO#

Ultralytics YOLO runs both tasks with the same Python API and CLI:

  • Instance segmentation uses the segment task.
  • Semantic segmentation uses the semantic task. YOLO26 semantic models carry a -sem suffix and come pretrained on Cityscapes and ADE20K. The task page includes a table showing exactly how the two tasks' outputs differ in code.

Both can be trained locally or in the cloud on Ultralytics Platform.

A country road segmented by Ultralytics YOLO26 semantic segmentation, with the share of pixels for sky, vegetation, road and terrain

Fig 3. Semantic segmentation answers "how much of the scene is each class". Ultralytics YOLO26x-sem labels 51.3% of this view as sky, 18.2% as vegetation, 15.2% as road and 14.9% as terrain. The photo was generated for this article; the class map and shares are real model outputs.

Frequently asked questions

  • Semantic segmentation labels every pixel with a class but treats all objects of the same class as one region. Instance segmentation separates each object into its own mask, so objects of the same class can be counted and tracked individually.

  • Ask whether two touching objects of the same class must be told apart. If you need to count, track or act on individual objects, use instance segmentation. If you only need to know which regions belong to which class, semantic segmentation is simpler.

  • Mask R-CNN is an instance segmentation model. It detects each object, then predicts a separate pixel mask inside that object's bounding box.

  • Instance segmentation is generally harder. It has to classify pixels and also split objects of the same class apart, which requires detection as well as segmentation.

  • Mostly with mean Intersection over Union (mIoU), the average overlap between predicted and true regions across classes. Instance segmentation uses mask mAP, and panoptic segmentation uses Panoptic Quality (PQ).

Written by

Miles Deans
Miles Deans

SEO Lead · Ultralytics

Miles Deans is the SEO Lead at Ultralytics, based in London, where he drives the company's search strategy and organic growth. He previously held roles at Adobe, Kaizen, and Virgin Media O2.

Comments

Ask a question, share your results, or help someone else.

Similar articles

Train, validation and test splits for computer vision: ratios, class balance and leakage

Train, validation and test splits for computer vision: ratios, class balance and leakage

Start at 70/15/15, split by camera or clip, check every class in every split, and score val and test separately with Ultralytics YOLO and Platform.
Learn more
Document layout analysis datasets for historical pages, and why old prints are hard

Document layout analysis datasets for historical pages, and why old prints are hard

Six historical document layout analysis datasets on Ultralytics Platform, from The History of England to a 15th-century music manuscript, compared.
Learn more
How to choose an edge AI device for computer vision, with measured Ultralytics YOLO26 results

How to choose an edge AI device for computer vision, with measured Ultralytics YOLO26 results

Measured YOLO26 results on Jetson, DGX Spark, Raspberry Pi 5 with Hailo-8 or DEEPX, RK3588, Snapdragon, iPhone, Apple M4 and STM32, each with its setup.
Learn more
Ultralytics Platform export options for YOLO26n: TensorRT for a Jetson Orin Nano Super at 4.57 ms and NCNN for a Raspberry Pi 5 CPU at 67.03 ms, from separate published benchmarks

Jetson Orin Nano Super vs Raspberry Pi 5 for YOLO26 object detection

YOLO26n inference: 4.57 ms on a Jetson Orin Nano Super (TensorRT FP16) vs 67.03 ms on a Pi 5 CPU, in separate tests. Choose by model, FPS and cameras.
Learn more
Ultralytics cover for the Azure Custom Vision migration checklist: the Ultralytics Platform New Dataset dialog with a panel mapping Custom Vision detection projects, tagging, training iterations and prediction endpoint to Platform datasets, annotation editor, cloud training and dedicated endpoints

Azure Custom Vision is retiring: a migration checklist for your vision models

Azure Custom Vision retires on September 25, 2028. Plan your migration, export your labeled data and retrain on Ultralytics Platform.
Learn more
Ultralytics Platform export list with the NCNN row highlighted above MNN, the format recommended for running YOLO26 on a Raspberry Pi 5 CPU

Raspberry Pi object detection: YOLO26 on a Pi 5 CPU, no accelerator

YOLO26n runs at 67.03 ms per image with NCNN on a Raspberry Pi 5 CPU, and Arm's open-source runtime measures 36.60 ms in its own test. Here's how to run both.
Learn more
Ultralytics licensing page showing the free AGPL-3.0 card and the paid Ultralytics Enterprise License card

Is Ultralytics YOLO free for commercial use? AGPL-3.0 vs the Enterprise License

Ultralytics YOLO is free under AGPL-3.0 if you open-source your whole project. Compare licensing for internal tools, SaaS and devices.
Learn more
Ultralytics security page cards for ISO/IEC 27001:2022 and SOC 2 Type I, with Ultralytics Platform workspace roles in front, on a gold gradient cover titled Regulated industries

Computer vision for regulated industries: an Ultralytics security review checklist

A security review checklist for computer vision in regulated industries: SOC 2 and ISO 27001 scope, on-premise and air-gapped options, privacy and SLAs.
Learn more
The Ultralytics Platform SAM smart annotation editor segmenting boxes on a warehouse conveyor, with a Batch Annotation estimated cost of $0.05 for 49 images

Budgeting for Image Annotation: Seats, AI and Exports

Compare image annotation software costs, free-plan limits and AI allowances. Estimate software and project costs with a worked three-person team example.
Learn more
Aerial view of a busy intersection with cars boxed by Ultralytics YOLO26s using 640-pixel tiles, dashed lines marking the tile seams

Small object detection with image tiling in Ultralytics YOLO, from Python to Rust

See when image tiling helps YOLO detect small objects, compare its costs, and run built-in tiled inference in Python or Rust without SAHI.
Learn more
A confusion matrix from model evaluation in Ultralytics Platform, beside compare workflows: no-code, developer control and edge export

Best platforms for training custom image classifiers

Image classifier training platforms compared: no-code AutoML, developer platforms and edge tools, and how to choose by control, deployment and cost.
Learn more
A rendered street scene with a bus, cars and people carrying pixel-perfect segmentation labels, beside three methods: simulation, generation and augmentation

Best synthetic data tools for computer vision training

Synthetic data tools for computer vision compared by method: 3D simulation, generative models and augmentation, and how to test them with Ultralytics YOLO.
Learn more
Missing PPE detection: train Ultralytics YOLO on Construction-PPE

Missing PPE detection: train Ultralytics YOLO on Construction-PPE

See how Construction-PPE labels missing helmets, vests and gloves, then train Ultralytics YOLO to detect missing PPE on your own site cameras.
Learn more
Drone detection dataset guide: train Ultralytics YOLO on tiny UAVs

Drone detection dataset guide: train Ultralytics YOLO on tiny UAVs

Compare DUT Anti-UAV, Drone-vs-Bird and thermal drone detection datasets, then train Ultralytics YOLO26 to find tiny drones and cut false alarms.
Learn more
A YOLO26 depth estimation prediction in Ultralytics Platform showing a dense depth map of a street scene with a bus, with timings and depth range

Best Depth Estimation Models: How to Choose

Compare monocular depth models such as Depth Anything, Depth Pro, Metric3D, UniDepth and Ultralytics YOLO26 for metric depth, edge devices and robotics.
Learn more
Two leaves classified as healthy and rust by an image classification model, with confidence scores

Best Image Classification Models: How to Choose

Compare the leading image classification models, from ConvNeXt V2 and DINOv3 to EfficientNetV2, ViT and Ultralytics YOLO26-cls, and learn how to choose.
Learn more
An engineer with a tablet beside industrial machinery, beside the costs beyond compute: data and labeling, cameras and hardware, integration and operations

What Enterprise Computer Vision Costs: A TCO Framework

A total-cost framework for enterprise computer vision covering data, annotation, cameras, edge hardware, training, inference, integration and retraining.
Learn more
Ultralytics Platform deployment monitoring showing total requests, active deployments and a ready YOLO26 segmentation endpoint

Computer Vision Inference at Scale: Seven Platforms Compared

Seven computer vision inference platforms compared: Azure ML, KServe, NVIDIA Triton, Roboflow, SageMaker AI, Ultralytics and Vertex AI, on latency and scale.
Learn more
Ultralytics Platform SAM smart annotation outlining a leopard, beside two different jobs: propose labels and select useful frames

How to Label Less: Auto-Labeling and Active-Learning Tools Compared

Ten auto-labeling and active-learning tools compared: CVAT, Encord, Label Studio, Labelbox, Lightly, Roboflow, SuperAnnotate, Ultralytics, V7 and FiftyOne.
Learn more
Elevated security-camera view of a city intersection with cars, a bus and pedestrians detected by Ultralytics YOLO26, beside three routes: analytics layer, VMS upgrade and self-hosted models

How to Add AI Analytics to Existing Security Cameras

Three routes to adding AI analytics to existing security cameras: analytics layers, VMS upgrades, or self-hosted models, and the constraints that decide.
Learn more
Metal castings on a conveyor with cracks and damaged parts detected, a magnified crack, and what to test: accuracy on your images, edge deployment and licensing

Choosing a Computer Vision Vendor: An Enterprise Procurement Guide

A procurement view of eight computer vision vendors: AWS, Azure, Cognex, Encord, Landing AI, NVIDIA, Roboflow and Ultralytics, with licensing checks.
Learn more
An edge computing board with a processor, beside where inference runs: managed endpoint, own hardware or hybrid

Managed Cloud vs Self-Hosted Computer Vision Deployment

Compare managed cloud and self-hosted computer vision deployment on cost, latency, data boundaries, scaling and exit risk, with three deployment patterns.
Learn more
A parcel on a modern conveyor detected by Ultralytics YOLOE, beside production readiness steps: validate, integrate, assign owners and monitor

Scaling Computer Vision from Pilot to Production

Six stage gates for taking computer vision from pilot to production, covering coverage matrices, workflow validation, model operations and site readiness.
Learn more
Bottles on a high-speed bottling line under an inspection camera, each detected by Ultralytics YOLO26

Computer Vision Platforms for Manufacturing: YOLO, Cognex and Keyence Compared

Compare computer vision platforms for manufacturing: Cognex, Edge Impulse, Keyence, Landing AI and Ultralytics YOLO, on inspection and MES fit.
Learn more
An Ultralytics Platform dataset gallery of labeled wildlife images, beside the question service or software: managed labeling or annotation software

Scale AI Alternatives for Data Labeling

Alternatives to Scale AI for vision data labeling: iMerit, SuperAnnotate and Ultralytics Platform, compared on cost, control, ramp time and data handling.
Learn more
Overhead view of people passing ticket gates in a bright concourse, detected by Ultralytics YOLO26, beside the four people-counting measurements: entries, occupancy, dwell time and queues

How People Counting and Occupancy Analytics Actually Work

How people counting and occupancy analytics work: comparing WiFi, ToF, thermal and camera-based vision methods, the products available, and how to build it.
Learn more
An industrial robot lifting a tyre from a stack in a warehouse, with the tyre detected by Ultralytics YOLOE

Vision-Guided Robotics for Assembly and Pick-and-Place

How vision-guided pick-and-place works across sensing, perception, calibration, grasp planning, motion and recovery, with a 2D versus 3D decision guide.
Learn more
Cherries segmented with precise polygon labels, beside who owns label quality: guidelines, review and a gold-standard set

Annotation Outsourcing vs In-House: The Real Trade-offs

Compare outsourced and in-house computer vision annotation on cost per usable label, ramp time, quality, security and the hybrid model most teams reach.
Learn more
PyTorch vs TensorFlow for computer vision projects

Choosing between PyTorch vs TensorFlow for computer vision projects

Compare PyTorch vs TensorFlow for computer vision across ease of use, flexibility, deployment, and scalability, and see how each fits Ultralytics YOLO.
Learn more
Supervised vs unsupervised learning in computer vision

Exploring supervised vs unsupervised learning in computer vision

Learn the differences between supervised and unsupervised learning in computer vision and how to choose the right approach for your data and project goals.
Learn more

Let's build the future of AI together!

Begin your journey with the future of machine learning