havan2605/depth-estimation-sam3
0
Object Distance Estimator
Segment two objects in a photo with a text prompt (SAM3), estimate metric depth (Depth Anything 3), and compute the real-world distance between the two objects.
Usage
- Upload one image (required) and optionally 1–4 more photos of the same scene from different angles — extra views improve metric accuracy.
- List two or more objects, comma-separated, e.g.
the red chair, the wooden table, the floor lamp. - (Optional) place a printed ArUco
DICT_4X4_50marker of known size in the scene and enter its side length for automatic scale calibration. - Click Estimate distances.
The app returns a mask overlay (each object gets a distinct color) and a pairwise distance matrix between every pair of objects — not just one distance. If a prompt fails to match anything, that object is skipped with a warning rather than aborting the whole run.
Accuracy features
- Blur gate — flags visibly blurry uploads before they reach the models; a bad extra view can otherwise quietly degrade DA3's joint depth solve.
- EXIF-derived intrinsics — if the primary image's EXIF has a 35mm-equivalent focal length, the app uses it instead of DA3's network-estimated intrinsics.
- Automatic scale calibration — an ArUco marker of known size in frame lets the app self-calibrate metric scale instead of requiring a manual measurement.
Notes
facebook/sam3is a gated model. Accept the license at huggingface.co/facebook/sam3, then add anHF_TOKENsecret to this Space (Settings → Repository secrets) with a token that has access to gated repos.- Use a GPU Space (T4 or better) — both models are slow on CPU.
- Only the metric checkpoints (
da3metric-large,DA3NESTED-GIANT-LARGE-1.1) give distances in real meters; the mono/relative checkpoints do not carry true scale. requirements.txtinstallsdepth_anything_3directly from its GitHub source rather than PyPI. Its PyPI availability has been inconsistent (sometimes resolvable, sometimes not, depending on when/where you build) — installing from the maintainers' repo directly sidesteps that entirely, at the cost of a longer build (it compiles from source rather than pulling a prebuilt wheel).python_version: "3.11"is still pinned above. Even installing from GitHub, the package's own metadata declaresRequires-Python: <=3.13,>=3.9, and a3.13.xpatch release can fail that check due to how version comparison works (3.13.14sorts after3.13) — keep this pin.
