ComfyUI > Nodes > ComfyUI-Sapiens2 > Sapiens2 Seg Extract Class

ComfyUI Node: Sapiens2 Seg Extract Class

Class Name

Sapiens2SegExtract

Category
Sapiens2
Author
kijai (Account age: 2864days)
Extension
ComfyUI-Sapiens2
Latest Updated
2026-05-06
Github Stars
0.05K

How to Install ComfyUI-Sapiens2

Install this extension via the ComfyUI Manager by searching for ComfyUI-Sapiens2
  • 1. Click the Manager button in the main menu
  • 2. Select Custom Nodes Manager button
  • 3. Enter ComfyUI-Sapiens2 in the search bar
After installation, click the Restart button to restart ComfyUI. Then, manually refresh your browser to clear the cache and access the updated list of nodes.

Visit ComfyUI Online for ready-to-use ComfyUI environment

  • Free trial available
  • 16GB VRAM to 80GB VRAM GPU machines
  • 400+ preloaded models/nodes
  • Freedom to upload custom models/nodes
  • 200+ ready-to-run workflows
  • 100% private workspace with up to 200GB storage
  • Dedicated Support

Run ComfyUI Online

Sapiens2 Seg Extract Class Description

Extract specific body parts from segmentation masks, invert masks for focused analysis and manipulation.

Sapiens2 Seg Extract Class:

The Sapiens2SegExtract node is designed to facilitate the extraction of specific body parts from a segmentation mask generated by the Sapiens2 Body-Part Segmentation model. This node allows you to isolate and work with individual body parts by selecting a class name corresponding to the desired body part. It provides the flexibility to invert the mask, which can be useful for various artistic and analytical purposes. By leveraging this node, you can focus on specific regions of interest within an image, enhancing your ability to manipulate and analyze segmented data effectively.

Sapiens2 Seg Extract Class Input Parameters:

class_id_mask

The class_id_mask is an input parameter that represents the output from the Sapiens2 Body-Part Segmentation model. It contains values that correspond to class IDs, normalized by dividing by (num_classes-1). This mask serves as the basis for extracting specific body parts, and its accuracy directly impacts the quality of the extracted mask.

class_name

The class_name parameter allows you to specify which body part you want to extract from the segmentation mask. It offers a selection from predefined options, such as "Face_Neck", which correspond to different body parts. The default value is "Face_Neck". Choosing the correct class name is crucial for obtaining the desired segment from the mask.

invert

The invert parameter is a boolean option that, when set to True, inverts the resulting binary mask. This means that the selected body part will be excluded from the mask, and all other parts will be included. The default value is False. This option is useful when you need to focus on all parts except the selected one.

num_classes

The num_classes parameter defines the total number of classes present in the source segmentation. The default value is 29, which corresponds to the standard Sapiens2 setup, including 28 body parts plus an additional "Eyeglass" class. The minimum value is 2, and the maximum is 256. This parameter ensures that the class IDs are correctly interpreted and scaled.

Sapiens2 Seg Extract Class Output Parameters:

mask

The mask output parameter is a binary mask that highlights the selected body part based on the class_name input. This mask is crucial for isolating specific regions within an image, allowing for targeted analysis or artistic manipulation. The mask's accuracy and quality depend on the input parameters and the original segmentation data.

Sapiens2 Seg Extract Class Usage Tips:

  • Ensure that the class_id_mask input is correctly generated by the Sapiens2 Body-Part Segmentation model to achieve accurate extraction results.
  • Use the invert option to easily switch between focusing on a specific body part and excluding it from the mask, depending on your artistic or analytical needs.
  • Adjust the num_classes parameter if you are working with a custom segmentation model that has a different number of classes than the standard Sapiens2 setup.

Sapiens2 Seg Extract Class Common Errors and Solutions:

ValueError: loaded checkpoint is task='seg', expected 'seg'

  • Explanation: This error occurs when the loaded model checkpoint is not compatible with the segmentation task expected by the node.
  • Solution: Ensure that the correct model checkpoint is loaded, specifically one that is designed for segmentation tasks.

IndexError: list index out of range

  • Explanation: This error may occur if the class_name provided does not exist in the predefined list of class names.
  • Solution: Verify that the class_name input is valid and corresponds to one of the available options in the Sapiens2 segmentation class list.

Sapiens2 Seg Extract Class Related Nodes

Go back to the extension to check out more related nodes.
ComfyUI-Sapiens2
RunComfy
Copyright 2025 RunComfy. All Rights Reserved.

RunComfy is the premier ComfyUI platform, offering ComfyUI online environment and services, along with ComfyUI workflows featuring stunning visuals. RunComfy also provides AI Models, enabling artists to harness the latest AI tools to create incredible art.

Sapiens2 Seg Extract Class