rpx_benchmark.tasks.monocular_depth

Monocular absolute depth.

 1"""Monocular absolute depth."""
 2
 3from __future__ import annotations
 4
 5from dataclasses import dataclass
 6
 7from ..api import TaskType
 8from ._pipeline import PipelineResult, TaskRunConfig, run_pipeline
 9from .registry import TaskSpec, register_task
10
11PRIMARY_METRIC = "absrel"
12
13
14@dataclass
15class MonocularDepthRunConfig(TaskRunConfig):
16    compute_temporal_stability: bool = True
17
18
19def run_monocular_depth(cfg: MonocularDepthRunConfig) -> PipelineResult:
20    return run_pipeline(
21        task=TaskType.MONOCULAR_DEPTH,
22        primary_metric=PRIMARY_METRIC,
23        cfg=cfg,
24        compute_ts=cfg.compute_temporal_stability,
25    )
26
27
28def _temporal_stability_hook(predictions, samples, camera_poses):
29    from ..deployment import compute_temporal_stability_depth
30
31    return compute_temporal_stability_depth([p.depth_map for p in predictions], camera_poses)
32
33
34TASK_SPEC = TaskSpec(
35    task=TaskType.MONOCULAR_DEPTH,
36    display_name="Monocular Absolute Depth",
37    description="Metric depth (metres) from a single RGB frame.",
38    primary_metric=PRIMARY_METRIC,
39    required_modalities=["rgb", "depth"],
40    higher_is_better=False,
41    run=run_monocular_depth,
42    temporal_stability_fn=_temporal_stability_hook,
43)
44
45register_task(TASK_SPEC)
PRIMARY_METRIC = 'absrel'
@dataclass
class MonocularDepthRunConfig(rpx_benchmark.tasks._pipeline.TaskRunConfig):
15@dataclass
16class MonocularDepthRunConfig(TaskRunConfig):
17    compute_temporal_stability: bool = True

MonocularDepthRunConfig(model: 'Optional[BenchmarkableModel]' = None, split: 'Difficulty | str' = , repo_id: 'Optional[str]' = None, cache_dir: 'Optional[str]' = None, revision: 'Optional[str]' = '51432e5d48895bbafb490ae7c5e34e0f6b7da7d6', batch_size: 'int' = 1, require_cuda: 'bool' = False, skip_flops: 'bool' = False, max_samples: 'Optional[int]' = None, manifest_path: 'Optional[str]' = None, device: 'str' = 'cuda', output_dir: 'Optional[str]' = None, progress: 'Optional[ProgressCallback]' = None, metric_suite: 'Optional[MetricSuite]' = None, upload_to_box: 'bool' = False, box_folder_id: 'Optional[str]' = None, compute_temporal_stability: 'bool' = True)

MonocularDepthRunConfig( model: Optional[rpx_benchmark.adapters.BenchmarkableModel] = None, split: rpx_benchmark.api.Difficulty | str = <Difficulty.HARD: 'hard'>, repo_id: Optional[str] = None, cache_dir: Optional[str] = None, revision: Optional[str] = '51432e5d48895bbafb490ae7c5e34e0f6b7da7d6', batch_size: int = 1, require_cuda: bool = False, skip_flops: bool = False, max_samples: Optional[int] = None, manifest_path: Optional[str] = None, device: str = 'cuda', output_dir: Optional[str] = None, progress: Optional[Callable[[int, Optional[int], str], NoneType]] = None, metric_suite: Optional[rpx_benchmark.metrics.MetricSuite] = None, upload_to_box: bool = False, box_folder_id: Optional[str] = None, compute_temporal_stability: bool = True)
compute_temporal_stability: bool = True
def run_monocular_depth( cfg: MonocularDepthRunConfig) -> Tuple[rpx_benchmark.metrics.registry.BenchmarkResult, rpx_benchmark.deployment.DeploymentReadinessReport, Dict[str, pathlib.Path]]:
20def run_monocular_depth(cfg: MonocularDepthRunConfig) -> PipelineResult:
21    return run_pipeline(
22        task=TaskType.MONOCULAR_DEPTH,
23        primary_metric=PRIMARY_METRIC,
24        cfg=cfg,
25        compute_ts=cfg.compute_temporal_stability,
26    )
TASK_SPEC = TaskSpec(task=<TaskType.MONOCULAR_DEPTH: 'monocular_depth'>, display_name='Monocular Absolute Depth', primary_metric='absrel', required_modalities=['rgb', 'depth'], run=<function run_monocular_depth>, higher_is_better=False, description='Metric depth (metres) from a single RGB frame.', temporal_stability_fn=<function _temporal_stability_hook>, geometric_coherence_fn=None)