File size: 5,272 Bytes
6e303cd | 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 | ---
license: apache-2.0
base_model: JYT4chenxiyuxi/LookAnything
base_model_relation: quantized
library_name: onnx
tags:
- onnx
- onnxruntime-web
- webgpu
- gaze-following
- quantized
---
# LookAnything, ONNX for WebGPU
[JYT4chenxiyuxi/LookAnything](https://huggingface.co/JYT4chenxiyuxi/LookAnything) (LA-2B, gaze following, Apache-2.0)
converted to ONNX so it runs in a browser with ONNX Runtime Web on WebGPU: photos, video files and the webcam.
Demo: [WeReCooking/LookAnything-WebGPU](https://huggingface.co/spaces/WeReCooking/LookAnything-WebGPU).
LA-2B is Qwen3-VL-2B with LoRA on the vision tower and learned gaze queries. This conversion covers the **one-pass
query path** only: a single forward pass over `[prompt, image tokens, 27 gaze-query tokens]` gives the gaze point, the
gaze box, a heatmap and the head mask through the small decoder heads. Text generation (the describe / reasoning
tasks) is not included.
## Files (2.26 GB)
| file | what | size |
|---|---|---|
| `vis_a.onnx`, `vis_b.onnx` | vision tower in two halves, LoRA merged, 8-bit weights; outputs the image tokens and the 3 DeepStack features | 245 + 234 MB |
| `lm_1.onnx` … `lm_4.onnx` | the 28 language layers, 7 per file, 8-bit weights, final norm in `lm_4` | 408 MB each |
| `heads.onnx` | gaze point / box / heatmap / head-mask decoders, fp32 | 148 MB |
| `prompt.json`, `prompt_rows.bf16`, `ids.json` | the prompt token ids and just their embedding rows (55 rows), so no tokenizer or 600 MB embedding table is needed | 0.2 MB |
| `query_tokens.f32` | the 27 learned query embeddings | 0.2 MB |
| `manifest.json` | sizes, SHA-256 | |
Everything the model needs around the graphs (image resize and patch layout, vision position tables, M-RoPE ids and
tables, the query-group attention mask, prompt assembly) is in the Space's `app.js` and was checked against
transformers: `prep.js` / `infer.js` there, `scripts/tables.py` here.
## How to run it
1. Pixels: Qwen smart-resize to multiples of 32 within 12,544 to 451,584 pixels (the repo's `inference_config.json`),
Pillow bicubic, `(x/255 - 0.5)/0.5`, patches of 16 px, merged 2×2, each patch `C × 2 × 16 × 16` (image repeated twice).
2. `vis_a(patches, pos_idx, pos_w, cos, sin)` → `x, ds0, ds1`; `vis_b(x, cos, sin)` → `img, ds2`.
3. Sequence: prompt tokens with the image placeholders replaced by `img`, then the 27 queries; `ds0..2` are added at the
image positions after language layers 1 to 3 (`lm_1` takes them zero-padded as `ds [3, S, 2048]`).
4. `lm_1 … lm_4` with M-RoPE `cos/sin [S, 128]` and the additive mask `[S, S]` (causal; the depth, head and gaze query
groups cannot see each other).
5. `heads(gaze = hidden[P+18 : P+27], head = hidden[P+9 : P+18], vis = image-token hidden states [1, gh, gw, 2048])` →
`point [1,2]`, `box [1,4]`, `heatmap [1,1,64,64]` logits, `head_mask [1,1,64,64]` logits (all in 0..1 picture
coordinates; `P` = prompt length).
Prompts are the repo's `GTL_POINT` template ("the person") or `GTL_B2P` with a head box in 0..999.
## Accuracy against the original
Original `look_anything` code in fp32 on CPU against these files, 6 Unsplash photos (people from the front and the back):
| set | size | largest point change | largest box change | heatmap peak moved |
|---|---|---|---|---|
| fp32 export | 8 GB | < 0.001 | < 0.001 | no |
| **vision + language 8-bit (this repo)** | **2.26 GB** | **0.008** | **0.025** | no (one by 1 cell) |
| language MLP 4-bit, rest 8-bit | 1.6 GB | 0.102 | 0.312 | yes |
| everything 4-bit | 1.4 GB | 0.182 | 0.386 | yes |
Coordinates are fractions of the picture, so 0.008 is under 1% of its width. 4-bit was dropped. The page's own
JavaScript (resize, tables, prompt assembly) run end to end on these files with ONNX Runtime CPU agrees with the PyTorch
reference to within 0.005 on 5 runs, including a head-box prompt. About 10 s per picture on 4 CPU cores.
Pixel budget: the page uses 451,584 pixels for stills and about 200,000 for live video. In PyTorch the 200,000
pixel setting moved the point by 0.02 to 0.06 of the picture against the full setting, 100,000 by up to 0.10.
Note: with transformers 5.4.0 the code repo's `load_processor` silently skips its `min_pixels` / `max_pixels` (the
Qwen2VL image processor has no such attribute there), so stock inference uses far more image tokens than
`inference_config.json` asks for. These files follow `inference_config.json`.
## Rebuild
`scripts/ref_look.py` (reference), `export_look.py` (fp32 ONNX, LoRA merged in fp64; `LOOK_DIR` points at a folder holding
`src/` = the code repo, `ckpt/LA-2B`), `quantize.py` (ONNX Runtime `MatMulNBits`, block 32), `make_data.py`,
`pack.py`, `verify_look.py`. Made with torch 2.15, transformers 5.4.0, onnx 1.23 and onnxruntime 1.32.
Code repo used: github.com/Look-Anything/LookAnything at commit 689501f. Checkpoint revision 60790cf.
## License
Apache-2.0, as the original. Changes: format conversion, vision LoRA merged into the weights, weight quantization,
vision and language stacks split into several graphs, heads kept as fp32.
Reference: Tang, Zhou et al., *LookAnything: A Foundation Model for Holistic Gaze Following*, arXiv:2611.32351.
Do not use gaze estimates as the only evidence for decisions about people.
|