Skip to content

modosaic.depth.generators.factory

modosaic.depth.generators.factory

DepthGenerationModel

Bases: Enum

Depth generator implementations supported by the factory.

DepthGeneratorFactory

Factory for depth generator implementations.

get staticmethod

get(depth_model=DepthGenerationModel.DEPTH_ANYTHING_V2_SMALL)

Create a depth generator.

Parameters:

Name Type Description Default
depth_model DepthGenerationModel

Model implementation to instantiate.

DEPTH_ANYTHING_V2_SMALL

Returns:

Type Description
DepthGenerator

Configured depth generator.

Raises:

Type Description
ValueError

If the model is unsupported.

Source code in modosaic/depth/generators/factory.py
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
@staticmethod
def get(depth_model: DepthGenerationModel = DepthGenerationModel.DEPTH_ANYTHING_V2_SMALL) -> DepthGenerator:
    """Create a depth generator.

    Args:
        depth_model: Model implementation to instantiate.

    Returns:
        Configured depth generator.

    Raises:
        ValueError: If the model is unsupported.
    """
    logger.debug(f"Creating depth generator for model {depth_model}")
    match depth_model:
        case DepthGenerationModel.DEPTH_ANYTHING_SMALL:
            return DepthAnythingSmall()
        case DepthGenerationModel.DEPTH_ANYTHING_V2_METRIC_SMALL:
            return DepthAnythingV2MetricSmall()
        case DepthGenerationModel.DEPTH_ANYTHING_V2_SMALL:
            return DepthAnythingV2Small()
        case DepthGenerationModel.DEPTH_PRO:
            return DepthPro()
        case DepthGenerationModel.DPT_HYBRID_MIDAS:
            return DptHybridMidas()
        case DepthGenerationModel.MARIGOLD_DEPTH_V1_1:
            return MarigoldDepthV11()
        case _:
            raise ValueError(f"Unsupported depth generation model: {depth_model}")