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

ImageSegmentator

ImageSegmentator is a pipeline action for semantic or instance segmentation.

Parameters:

  • kind"instance" (Mask R-CNN targets) or "semantic" (per-pixel class map)
  • num_classes — classes including background; inferred from data when None
  • input_channels — channel count after default semantic input preparation (default 3)
  • image_size(H, W) for semantic batching; instance models resize internally

Use with PairedImageMaskFolderDataset or YOLO polygon labels.

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

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

pipeline = Pipeline(
    {
        "nail_segment": Step(
            ImageSegmentator(kind="semantic"),
            description="Segment nail region",
        ),
    },
)

At inference, SegmentationPrediction provides masks and visualization helpers.

Documentation

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".