Skip to content

modosaic.depth.generators.impl.marigold_depth_v1_1

modosaic.depth.generators.impl.marigold_depth_v1_1

MarigoldDepthV11

MarigoldDepthV11()

Bases: DepthGenerator

Marigold Depth v1.1 generator.

Load the pinned Marigold diffusion pipeline.

Source code in modosaic/depth/generators/impl/marigold_depth_v1_1.py
20
21
22
23
24
25
26
27
28
def __init__(self):
    """Load the pinned Marigold diffusion pipeline."""
    super().__init__()
    self.model_specs = HFModelSpec(
        model_id="prs-eth/marigold-depth-v1-1",
        revision="9571e7123e258cf052b4e54241f17971c290e9a8",
        dtype=self.dtype,
    )
    self.pipeline = self._load_pipeline()

generate

generate(record)

Generate a depth map for one image record.

Source code in modosaic/depth/generators/impl/marigold_depth_v1_1.py
38
39
40
41
42
43
44
45
@override
def generate(self, record: ImageRecord) -> np.ndarray:
    """Generate a depth map for one image record."""
    logger.debug(f"Generating depth for record sample {record.sample_id}")
    img = ImageService.bytes_to_pil(record.image_bytes)
    np_depth = self.pipeline(img)["prediction"]

    return np_depth