Instructions to use AXERA-TECH/LocateAnything-3B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use AXERA-TECH/LocateAnything-3B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("zero-shot-object-detection", model="AXERA-TECH/LocateAnything-3B")# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("AXERA-TECH/LocateAnything-3B", device_map="auto") - Notebooks
- Google Colab
- Kaggle
File size: 6,218 Bytes
b8f881b b81c0cf d6bb2ef b81c0cf b8f881b b81c0cf 43d1db0 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 | ---
license: mit
language:
- en
- zh
base_model:
- nvidia/LocateAnything-3B
pipeline_tag: zero-shot-object-detection
library_name: transformers
tags:
- LocateAnything-3B
- Int4
- VLM
- GPTQ
---
# LocateAnything-3B
This version of LocateAnything-3B have been converted to run on the Axera NPU using **w4a16** quantization.
Compatible with Pulsar2 version: 6.0
## Convert tools links:
For those who are interested in model conversion, you can try to export axmodel through the original repo :
- https://huggingface.co/nvidia/LocateAnything-3B
[Pulsar2 Link, How to Convert LLM from Huggingface to axmodel](https://pulsar2-docs.readthedocs.io/en/latest/appendix/build_llm.html)
[AXera NPU HOST LLM Runtime](TODO)
## Support Platform
- AX650
- AX650N DEMO Board
- [M4N-Dock(爱芯派Pro)](https://wiki.sipeed.com/hardware/zh/maixIV/m4ndock/m4ndock.html)
- [M.2 Accelerator card](https://docs.m5stack.com/zh_CN/ai_hardware/LLM-8850_Card)
**Image Process**
|Chips| input size | image num | image encoder | ttft(493 tokens) | w4a16 | CMM | Flash |
|--|--|--|--|--|--|--|--|
|AX650| 560*560 | 1 | 1152.583 ms | 2072.06 ms | 10.61 tokens/sec| 2.9GiB | 3.2GiB |
The DDR capacity refers to the CMM memory that needs to be consumed. Ensure that the CMM memory allocation on the development board is greater than this value.
## 模型下载(Hugging Face)
先创建模型目录并进入,然后下载到该目录:
```shell
mkdir -p AXERA-TECH/LocateAnything-3B
cd AXERA-TECH/LocateAnything-3B
hf download AXERA-TECH/LocateAnything-3B --local-dir .
# structure of the downloaded files
tree -L 3
.
└── AXERA-TECH
└── LocateAnything-3B
|-- assert
|-- config.json
|-- gradio_locateanything_axengine.py
|-- image_encoder_mlp.axmodel
|-- infer_locateanything_axengine.py
|-- model.embed_tokens.weight.bfloat16.bin
|-- post_config.json
|-- qwen2.5_tokenizer
|-- qwen2_5_tokenizer.txt
|-- qwen2_p128_l0_together.axmodel
|-- qwen2_p128_l10_together.axmodel
|-- qwen2_p128_l11_together.axmodel
|-- qwen2_p128_l12_together.axmodel
|-- qwen2_p128_l13_together.axmodel
|-- qwen2_p128_l14_together.axmodel
|-- qwen2_p128_l15_together.axmodel
|-- qwen2_p128_l16_together.axmodel
|-- qwen2_p128_l17_together.axmodel
|-- qwen2_p128_l18_together.axmodel
|-- qwen2_p128_l19_together.axmodel
|-- qwen2_p128_l1_together.axmodel
|-- qwen2_p128_l20_together.axmodel
|-- qwen2_p128_l21_together.axmodel
|-- qwen2_p128_l22_together.axmodel
|-- qwen2_p128_l23_together.axmodel
|-- qwen2_p128_l24_together.axmodel
|-- qwen2_p128_l25_together.axmodel
|-- qwen2_p128_l26_together.axmodel
|-- qwen2_p128_l27_together.axmodel
|-- qwen2_p128_l28_together.axmodel
|-- qwen2_p128_l29_together.axmodel
|-- qwen2_p128_l2_together.axmodel
|-- qwen2_p128_l30_together.axmodel
|-- qwen2_p128_l31_together.axmodel
|-- qwen2_p128_l32_together.axmodel
|-- qwen2_p128_l33_together.axmodel
|-- qwen2_p128_l34_together.axmodel
|-- qwen2_p128_l35_together.axmodel
|-- qwen2_p128_l3_together.axmodel
|-- qwen2_p128_l4_together.axmodel
|-- qwen2_p128_l5_together.axmodel
|-- qwen2_p128_l6_together.axmodel
|-- qwen2_p128_l7_together.axmodel
|-- qwen2_p128_l8_together.axmodel
|-- qwen2_p128_l9_together.axmodel
|-- qwen2_post.axmodel
|-- results
`-- test_data
4 directories, 44 files
```
## Inference with AX650 Host, such as M4N-Dock(爱芯派Pro) or AX650N DEMO Board
### Gradio Demo
```shell
(base) root@ax650:~/LocateAnything# python gradio_locateanything_axengine.py
[INFO] Available providers: ['AxEngineExecutionProvider', 'AXCLRTExecutionProvider']
[Gradio] starting LocateAnything UI
[Gradio] local: http://127.0.0.1:7860
[Gradio] LAN: http://10.126.29.50:7860
[Gradio] LAN: http://10.126.29.68:7860
[Gradio] LAN: http://172.17.0.1:7860
[Gradio] Use another computer in the same LAN to open the LAN URL.
* Running on local URL: http://0.0.0.0:7860
* To create a public link, set `share=True` in `launch()`.
```
Output:
detection:

ocr:

phrase grounding:

### WebUI (via ax-llm serve)
Besides the Gradio demo, [ax-llm](https://github.com/AXERA-TECH/ax-llm) provides an OpenAI-compatible `serve` plus a lightweight, dependency-free (Python stdlib only) web front-end — `scripts/locateanything_webui.py` — that draws detection boxes in real time as they stream.

#### 1. Start the model service with ax-llm
Build / obtain the `axllm` binary from [ax-llm](https://github.com/AXERA-TECH/ax-llm) (AX650 host build), then serve this model. The folder already contains everything `serve` needs (`config.json`, `qwen2_5_tokenizer.txt`, `post_config.json` and the axmodels):
```shell
# on the AX650 host (M4N-Dock / AX650N DEMO Board / M.2 card)
LD_LIBRARY_PATH=/soc/lib ./axllm serve /path/to/AXERA-TECH/LocateAnything-3B --port 8010
# ... loading ...
# OpenAI API Server starting on http://0.0.0.0:8010
# Models: AXERA-TECH/LocateAnything-3B
```
#### 2. Start the WebUI
The `pexels-images/` sample images (with per-image `tags.json` presets) ship in this repo. Point the webui at the running serve and at that image folder:
```shell
AXLLM_SERVE_URL=http://127.0.0.1:8010 \
AXLLM_IMAGE_DIR=/path/to/AXERA-TECH/LocateAnything-3B/pexels-images \
python3 scripts/locateanything_webui.py --host 0.0.0.0 --port 7861
```
Then open `http://<board-ip>:7861` from any machine on the same LAN.
- Pick a preset thumbnail from the top banner, or **Upload** your own image.
- **Object detection** — edit the category chips (one query per category,
- **Phrase grounding** — type a description (e.g. `the dog on the left`) to locate a specific instance.
- Press **Detect**; boxes are drawn one-by-one as they stream in. **Stop**
Flags: `--host`, `--port`, `--serve-url`, `--image-dir`, `--model`. |