Перейти к содержанию

ImageSegmentator

ImageSegmentator — действие пайплайна для семантической или instance-сегментации.

Параметры:

  • kind"instance" (цели Mask R-CNN) или "semantic" (карта классов по пикселям)
  • num_classes — число классов включая фон; при None определяется из данных
  • input_channels — число каналов после подготовки входа (по умолчанию 3)
  • image_size(H, W) для semantic-batching; instance-модели масштабируют внутри

Используется с PairedImageMaskFolderDataset или полигональной разметкой YOLO.

from hyppopipe.data.dataset import PairedImageMaskFolderDataset
from hyppopipe.pipeline import Pipeline, Step
from hyppopipe.pipeline.image.segmentation import ImageSegmentator

splits = PairedImageMaskFolderDataset("data/nails/").as_split_data()

pipeline = Pipeline(
    {
        "nail_segment": Step(
            ImageSegmentator(kind="semantic"),
            description="Сегментация области ногтя",
        ),
    },
)

При инференсе SegmentationPrediction предоставляет маски и методы визуализации.

Документация

Pipeline step for semantic or instance segmentation.

__call__()

Marker callable; training uses attributes, not runtime invocation.

__init__(*, kind='instance', num_classes=None, input_channels=3, image_size=(224, 224))

Store segmentation training options.

Parameters:

Name Type Description Default
kind SegmentationKind

Desired label format: "instance" (Mask R-CNN targets) or "semantic" (class map). Training may adapt when the model architecture differs (see SegmentationTrainingTask).

'instance'
num_classes int | None

Classes including background; inferred from data when None.

None
input_channels int

Channel count after default semantic input preparation.

3
image_size tuple[int, int] | None

(H, W) for semantic batching; instance models resize internally.

(224, 224)

Raises:

Type Description
ValueError

If kind is not "instance" or "semantic".