|
1 | | -"""Defaults and semantic priors for ScaleObservation.""" |
| 1 | +"""Defaults and semantic priors for ScaleObservation. |
| 2 | +
|
| 3 | +How these tables were generated |
| 4 | +------------------------------- |
| 5 | +ScaleObservation uses two distinct kinds of per-class knowledge, derived two |
| 6 | +different ways: |
| 7 | +
|
| 8 | +1. **Size priors** (``SCALE_SIZE_PRIORS_M`` = COCO + YOLOE tables below). These |
| 9 | + are *hand-authored* broad physical priors, NOT fitted from any dataset. Each |
| 10 | + entry is ``{dimension: (mean_m, sigma_m), ..., "r": reliability}`` where |
| 11 | + ``mean_m``/``sigma_m`` are a real-world size estimate and its spread in |
| 12 | + metres, and ``r`` is a coarse per-class trust weight. Means/sigmas are taken |
| 13 | + from public reference catalogues (anthropometric stature tables, furniture |
| 14 | + and appliance size guides, common product specifications); the per-class |
| 15 | + ``# Source:`` comments record where each came from. Sigmas are intentionally |
| 16 | + wide -- these are size *priors*, not exact dimensions. |
| 17 | +
|
| 18 | +2. **Calibration corrections** (``CALIBRATED_SCALE_CORRECTION_BY_LABEL_DIM``). |
| 19 | + These ARE learned from data -- see the comment on that table for the method |
| 20 | + and the reproduction script. |
| 21 | +
|
| 22 | +The per-dimension reliability weights (``DIMENSION_RELIABILITY_BY_LABEL``) are |
| 23 | +also hand-tuned: they encode which axes of a class are stable enough to drive |
| 24 | +scene scale (e.g. a person's height is trustworthy, their depth is not). |
| 25 | +""" |
2 | 26 |
|
3 | 27 | from __future__ import annotations |
4 | 28 |
|
| 29 | +# COCO-aligned size priors, in metres. Intentionally broad physical priors, not |
| 30 | +# exact object dimensions. Each value is ``(mean_m, sigma_m)``; ``r`` is the |
| 31 | +# per-class reliability weight. Sources are cited per class below. |
5 | 32 | COCO_SIZE_PRIORS_M: dict[str, dict[str, object]] = { |
| 33 | + # Source: CDC/NCHS adult stature references for height; width/depth are broad |
| 34 | + # body-envelope priors, not a fixed anthropometric standard. |
6 | 35 | "person": {"height": (1.70, 0.15), "width": (0.45, 0.10), "depth": (0.30, 0.10), "r": 0.80}, |
| 36 | + # Source: BIFMA/ergonomic chair ranges and common dining/office chair product dimensions. |
7 | 37 | "chair": {"height": (0.85, 0.18), "width": (0.50, 0.12), "depth": (0.55, 0.14), "r": 0.70}, |
| 38 | + # Source: Dimensions.com sofa/couch references and common 2-3 seat sofa product ranges. |
8 | 39 | "couch": {"height": (0.85, 0.18), "width": (2.00, 0.45), "depth": (0.90, 0.20), "r": 0.65}, |
| 40 | + # Source: Dimensions.com queen bed / Sleep Foundation queen mattress dimensions; |
| 41 | + # height includes a broad mattress/frame allowance. |
9 | 42 | "bed": {"height": (0.60, 0.18), "width": (1.60, 0.35), "depth": (2.05, 0.30), "r": 0.75}, |
| 43 | + # Source: Dimensions.com dining table collection and common 4-person table dimensions. |
10 | 44 | "dining table": { |
11 | 45 | "height": (0.75, 0.08), |
12 | 46 | "width": (1.40, 0.40), |
13 | 47 | "depth": (0.90, 0.25), |
14 | 48 | "r": 0.65, |
15 | 49 | }, |
| 50 | + # Source: Rempros/Angi toilet dimension guides; height/depth cover tank and bowl envelope. |
16 | 51 | "toilet": {"height": (0.75, 0.10), "width": (0.38, 0.08), "depth": (0.70, 0.12), "r": 0.80}, |
| 52 | + # Source: Dimensions.com TV display references and common 43-55 inch TV sizes. |
17 | 53 | "tv": {"height": (0.65, 0.25), "width": (1.10, 0.40), "depth": (0.08, 0.05), "r": 0.60}, |
| 54 | + # Source: common 13-15 inch laptop product specifications; very weak height prior. |
18 | 55 | "laptop": {"height": (0.02, 0.01), "width": (0.34, 0.06), "depth": (0.24, 0.04), "r": 0.45}, |
| 56 | + # Source: common full-size keyboard specifications, approximately 17 x 5.5 inches. |
19 | 57 | "keyboard": {"height": (0.03, 0.01), "width": (0.43, 0.08), "depth": (0.14, 0.04), "r": 0.45}, |
| 58 | + # Source: common desktop mouse product specifications. |
20 | 59 | "mouse": {"height": (0.04, 0.02), "width": (0.065, 0.02), "depth": (0.11, 0.03), "r": 0.35}, |
| 60 | + # Source: ISO/US common book trim sizes; intentionally broad due to high variation. |
21 | 61 | "book": {"height": (0.03, 0.02), "width": (0.18, 0.08), "depth": (0.25, 0.08), "r": 0.35}, |
| 62 | + # Source: RTINGS refrigerator size guide and common full-size fridge product ranges. |
22 | 63 | "refrigerator": { |
23 | 64 | "height": (1.70, 0.25), |
24 | 65 | "width": (0.75, 0.15), |
25 | 66 | "depth": (0.75, 0.15), |
26 | 67 | "r": 0.80, |
27 | 68 | }, |
| 69 | + # Source: KitchenAid/Wayfair microwave size guides; typical countertop/OTR envelope. |
28 | 70 | "microwave": {"height": (0.30, 0.08), "width": (0.50, 0.10), "depth": (0.40, 0.08), "r": 0.65}, |
| 71 | + # Source: common 24 inch built-in/range oven product dimensions. |
29 | 72 | "oven": {"height": (0.75, 0.15), "width": (0.60, 0.10), "depth": (0.60, 0.10), "r": 0.70}, |
| 73 | + # Source: Dimensions.com kitchen sink collection and common 22 x 30 inch sink guides. |
30 | 74 | "sink": {"height": (0.20, 0.10), "width": (0.55, 0.18), "depth": (0.45, 0.15), "r": 0.45}, |
| 75 | + # Source: common decorative vase product dimensions; high variance, low reliability. |
31 | 76 | "vase": {"height": (0.30, 0.18), "width": (0.16, 0.10), "depth": (0.16, 0.10), "r": 0.30}, |
| 77 | + # Source: common beverage bottle dimensions; high category variance. |
32 | 78 | "bottle": {"height": (0.25, 0.12), "width": (0.08, 0.04), "depth": (0.08, 0.04), "r": 0.35}, |
| 79 | + # Source: Dimensions.com coffee mug/cup references and common mug product dimensions. |
33 | 80 | "cup": {"height": (0.10, 0.04), "width": (0.08, 0.03), "depth": (0.08, 0.03), "r": 0.30}, |
| 81 | + # Source: common cereal/soup bowl product dimensions; high category variance. |
34 | 82 | "bowl": {"height": (0.08, 0.04), "width": (0.18, 0.08), "depth": (0.18, 0.08), "r": 0.30}, |
| 83 | + # Source: common indoor potted plant product ranges; intentionally weak prior. |
35 | 84 | "potted plant": { |
36 | 85 | "height": (0.70, 0.45), |
37 | 86 | "width": (0.45, 0.30), |
|
42 | 91 |
|
43 | 92 | DEFAULT_DIMENSION_RELIABILITY = {"height": 0.75, "width": 0.65, "depth": 0.35} |
44 | 93 |
|
| 94 | +# Hand-tuned per-class/per-dimension trust weights in [0, 1]. The prior means |
| 95 | +# above stay as broad size references; these weights control whether a given |
| 96 | +# axis is stable enough to drive scene scale (e.g. person height is reliable, |
| 97 | +# person depth is not; a tv's thin depth is near-useless). |
45 | 98 | DIMENSION_RELIABILITY_BY_LABEL: dict[str, dict[str, float]] = { |
46 | 99 | "person": {"height": 0.90, "width": 0.25, "depth": 0.10}, |
47 | 100 | "chair": {"height": 0.65, "width": 0.55, "depth": 0.45}, |
|
68 | 121 | COCO_PRIOR_LABELS = frozenset(COCO_SIZE_PRIORS_M) |
69 | 122 |
|
70 | 123 |
|
| 124 | +# Expanded prompt-free YOLOE size priors, in metres. Same authoring method and |
| 125 | +# format as COCO_SIZE_PRIORS_M above: hand-set ``(mean_m, sigma_m)`` from common |
| 126 | +# furniture/fixture/appliance/electronics product-dimension references, not |
| 127 | +# fitted from data. These are consumed only when ObjectMaskAnnotation3D is run |
| 128 | +# with the YOLOE prompt-free checkpoint, which emits this wider label set. |
| 129 | +# NOTE: these classes have no entry in CALIBRATED_SCALE_CORRECTION_BY_LABEL_DIM |
| 130 | +# yet, so their calibration factor defaults to 1.0 (uncalibrated). |
71 | 131 | YOLOE_SIZE_PRIORS_M: dict[str, dict[str, object]] = { |
72 | 132 | "armchair": {"height": (0.90, 0.18), "width": (0.78, 0.22), "depth": (0.82, 0.20), "r": 0.62}, |
73 | 133 | "office chair": { |
|
315 | 375 | } |
316 | 376 |
|
317 | 377 |
|
| 378 | +# Learned (not hand-authored) per-class/per-dimension scale corrections, applied |
| 379 | +# as multipliers on each candidate's proposed scale at |
| 380 | +# scale.py:calibration_factor(). Derivation: from a full SUN RGB-D pipeline run |
| 381 | +# (originally the first v2_scene_object_consensus pass), each accepted |
| 382 | +# object/dimension candidate's *uncalibrated* scale was compared to the |
| 383 | +# ground-truth dimension-specific scene scale (gt_bounds[dim] / generated_bounds[dim]); |
| 384 | +# the per-(label, dimension) correction is the robust median of those ratios, |
| 385 | +# shrunk toward 1.0 when class support is low. Values < 1.0 dominate because the |
| 386 | +# monocular-depth backend systematically over-sizes objects. Classes/dimensions |
| 387 | +# absent here default to 1.0. |
| 388 | +# |
| 389 | +# Reproduce / extend (e.g. to add the YOLOE classes) with: |
| 390 | +# uv run python research/SCALE_OBSERVATION_RESEARCH/derive_scale_calibration.py \ |
| 391 | +# research/SCALE_OBSERVATION_RESEARCH/outputs/scale_observation_v4_current |
318 | 392 | CALIBRATED_SCALE_CORRECTION_BY_LABEL_DIM: dict[str, dict[str, float]] = { |
319 | 393 | "bed": {"depth": 0.6757}, |
320 | 394 | "book": {"height": 1.0, "width": 0.6788, "depth": 0.4039}, |
|
0 commit comments