Simple, one-call Python interface for the nvidia/LocateAnything-3B UI element detection model.
Project description
locate-anything
A tiny Python package that wraps the full nvidia/LocateAnything-3B workflow —
dependency setup, model loading, preprocessing, inference, and output parsing —
behind a single class, so you don't have to re-copy notebook cells every time.
Install
Because torch needs a CUDA-specific build, install it first from the
PyTorch index, then install this package:
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu124
pip install locate-anything
(Or, from a local checkout: pip install . after the torch step above.)
LocateAnything-3B is a gated model, so you'll also need to authenticate once:
huggingface-cli login
or pass a token directly when creating the client (see below).
Usage
Python API
from locate_anything import LocateAnything
# Loads tokenizer, processor, and model once (put this outside any loop)
la = LocateAnything() # optionally: LocateAnything(hf_token="hf_...")
result = la.detect("screenshot.png", save_path="detected.png")
print(result["total"]) # number of detections
print(result["counts"]) # {"button": 12, "icon": 30, ...}
print(result["detections"]) # [{"label": "button", "bbox_pixels": [x1,y1,x2,y2]}, ...]
result["annotated_image"].show() # PIL.Image with boxes drawn
Custom categories:
result = la.detect(
"screenshot.png",
categories=["play button", "volume slider", "progress bar"],
)
Batch of images:
results = la.detect_batch(["a.png", "b.png", "c.png"])
Command line
locate-anything screenshot.png -o detected.png --json-output detections.json
What it handles for you
- Dependency management — pinned versions declared in
pyproject.toml(torch must be installed separately due to the CUDA index URL requirement). - Model initialization — tokenizer, processor, and model loaded once per
LocateAnythinginstance, inbfloat16on the best available device. - Preprocessing — builds the chat-template prompt and processes image/video inputs for you.
- Inference — calls
model.generate(...)with sane defaults (generation_mode="hybrid",use_cache=True). - Output processing — parses the model's
<box>tags back into pixel coordinates, tallies counts per label, and optionally draws + saves an annotated image.
Package layout
locate_anything/
├── __init__.py # public API: LocateAnything, DEFAULT_CATEGORIES
├── config.py # default model name, categories, regex pattern
├── core.py # LocateAnything class (load + detect)
├── postprocessing.py # parse_detections(), draw_detections()
└── cli.py # `locate-anything` command line entry point
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file locate_anything-0.1.0.tar.gz.
File metadata
- Download URL: locate_anything-0.1.0.tar.gz
- Upload date:
- Size: 6.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0a5ff6820b2b5133456da28aa020690b94a8a5df0b393aa82886c44405dd8944
|
|
| MD5 |
8814a968add22c360900775b8bd1ce87
|
|
| BLAKE2b-256 |
e26d703e9177bf2f7e3cfb2e13a97ed4411bfeab0575cd2fb3ca5b20af8e2899
|
File details
Details for the file locate_anything-0.1.0-py3-none-any.whl.
File metadata
- Download URL: locate_anything-0.1.0-py3-none-any.whl
- Upload date:
- Size: 7.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
783ab9ed46fafb3baba6bdcbbee5a1dd25bad2377b657c2bd24e0508c34dbb67
|
|
| MD5 |
f9b2adfccdc4e5d367dfc4b792a18670
|
|
| BLAKE2b-256 |
58570201af068df00a837f13faad4294e8df0f7efb8f07938d7716d283916e1f
|