Skip to content

modosaic.segmentation.generators.factory

modosaic.segmentation.generators.factory

SegmentationGenerationModel

Bases: Enum

Segmentation generator implementations supported by the factory.

SegmentationGeneratorFactory

Factory for segmentation generator implementations.

get staticmethod

get(depth_model=SegmentationGenerationModel.SAM3)

Create a segmentation generator.

Parameters:

Name Type Description Default
depth_model SegmentationGenerationModel

Segmentation model implementation to instantiate.

SAM3

Returns:

Type Description
SegmentationGenerator

Configured segmentation generator.

Raises:

Type Description
ValueError

If the model is unsupported.

Source code in modosaic/segmentation/generators/factory.py
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
@staticmethod
def get(depth_model: SegmentationGenerationModel = SegmentationGenerationModel.SAM3) -> SegmentationGenerator:
    """Create a segmentation generator.

    Args:
        depth_model: Segmentation model implementation to instantiate.

    Returns:
        Configured segmentation generator.

    Raises:
        ValueError: If the model is unsupported.
    """
    logger.debug(f"Creating segmentation generator for model {depth_model}")
    match depth_model:
        case SegmentationGenerationModel.SAM:
            return SAM()
        case SegmentationGenerationModel.SAM2:
            return SAM2HieraSmall()
        case SegmentationGenerationModel.SAM3:
            return SAM3()
        case _:
            raise ValueError(f"Unsupported depth generation model: {depth_model}")