Views
No views yet
in_token_limit=1024) for local memory constraints, offering up to 20x faster inference speed and a significantly lower VRAM footprint.pip install mlx-vlm transformers pillow opencv-pythonmlx_vlm library.1from PIL import Image
2from mlx_vlm import load, generate
3
4# 1. Load the model and processor
5model_path = "andai-labs/LocateAnything-3B-MLX"
6model, processor = load(model_path, trust_remote_code=True)
7
8# 2. Prepare the image and prompt
9image = Image.open("path/to/your/image.jpg")
10prompt = "Locate the person."
11
12messages = [
13 {
14 "role": "user",
15 "content": [
16 {"type": "image"},
17 {"type": "text", "text": prompt}
18 ]
19 }
20]
21
22# 3. Format the chat template
23text_prompt = processor.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
24
25# 4. Generate the localization bounding box
26response = generate(model, processor, text_prompt, image=image, max_tokens=100)
27print("Model Output:", response.text)0 to 1000 in the format <ymin><xmin><ymax><xmax>:<ref>Locate the person</ref><box><247><220><757><1000></box>(height, width):
1import re
2
3# Parse coordinates
4pattern = r"<box><(\d+)><(\d+)><(\d+)><(\d+)></box>"
5match = re.search(pattern, response.text)
6if match:
7 ymin, xmin, ymax, xmax = [int(g) for g in match.groups()]
8
9 # Project back to image resolution
10 x1 = int(xmin * img_width / 1000)
11 y1 = int(ymin * img_height / 1000)
12 x2 = int(xmax * img_width / 1000)
13 y2 = int(ymax * img_height / 1000)1@article{locateanything2026,
2 title={LocateAnything: Open-Vocabulary Object Localization at Scale},
3 author={NVIDIA Research},
4 journal={arXiv preprint arXiv:2605.27365},
5 year={2026}
6}