Segmentation

Learn to perform segmentation using Hugging Face API.

We'll cover the following

Segmentation has many applications, such as medical imaging, autonomous cars, or image retrieval. While it may seem like a straightforward task, it requires some appropriate learning before partitioning the pixels.

Overview

Image segmentation is used to partition the image into different segments (sets of pixels) corresponding to a distinct object.

It is usually used for detailed information about the image segments rather than object detection. It finds its use in several applications, especially in biomedical imaging. It can be divided into the following three types:

  • Semantic: This refers to pixel-level segmentation
  • Instance: This is similar to semantic segmentation and is also done on the pixel-level. Here, however, each instance is treated as a distinct segment. For example, instance segmentation of an image of three cats results in all three cats being treated as separate instances.
  • Panoptic: This is a new type of segmentation and is a hybrid of both semantic and instance segmentation.

Inference

Hugging Face provides us with models for all of three aforementioned types. To perform any of the three segmentations, we can simply call the respective model.

To use the pipeline for segmentation, we need to install the PyTorch image models library:

Get hands-on with 1200+ tech skills courses.