Spaces:
Sleeping
Sleeping
A newer version of the Gradio SDK is available: 6.24.0
metadata
title: Object Distance Estimator
emoji: π
colorFrom: purple
colorTo: yellow
sdk: gradio
sdk_version: 6.19.0
python_version: '3.11'
app_file: app.py
pinned: false
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.