Spaces:
Sleeping
Sleeping
| 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 | |
| 1. Upload one image (required) and optionally 1β4 more photos of the same | |
| scene from different angles β extra views improve metric accuracy. | |
| 2. List two or more objects, comma-separated, e.g. | |
| `the red chair, the wooden table, the floor lamp`. | |
| 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. 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](https://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. |