CoolFace
Apppublic

havan2605/depth-estimation-sam3

sourceHugging Faceupdated 3mo agoView on Hugging Face
0likes
App README

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

  1. 1.Upload one image (required) and optionally 1–4 more photos of the same scene from different angles — extra views improve metric accuracy.
  2. 2.List two or more objects, comma-separated, e.g. the red chair, the wooden table, the floor lamp.
  3. 3.(Optional) place a printed ArUco DICT_4X4_50 marker of known size in the scene and enter its side length for automatic scale calibration.
  4. 4.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/sam3 is a gated model. Accept the license at huggingface.co/facebook/sam3, then add an HF_TOKEN secret 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.txt installs depth_anything_3 directly 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 declares Requires-Python: <=3.13,>=3.9, and a 3.13.x patch release can fail that check due to how version comparison works (3.13.14 sorts after 3.13) — keep this pin.