Instructions to use oliver0804/LocateAnything-3B-RK3588 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- RKLLM
How to use oliver0804/LocateAnything-3B-RK3588 with RKLLM:
# No code snippets available yet for this library. # To use this model, check the repository files and the library's documentation. # Want to help? PRs adding snippets are welcome at: # https://github.com/huggingface/huggingface.js
- Notebooks
- Google Colab
- Kaggle
Add RK3588 conversion of nvidia/LocateAnything-3B (RKLLM w8a8 + RKNN fp16)
Browse files- .gitattributes +3 -0
- LICENSE +74 -0
- LICENSE-Qwen +54 -0
- LocateAnything-3B_LLM_RK3588_w8a8.rkllm +3 -0
- LocateAnything-3B_vision_RK3588.rknn +3 -0
- NOTICE +22 -0
- README.md +109 -0
- SHA256SUMS +3 -0
- eval/eval_set.json +1 -0
- eval/preds_board_sampled.json +1 -0
- eval/preds_gpu_sampled.json +1 -0
- rk3588/locate3b.py +301 -0
- rk3588/rkllm_binding.py +266 -0
- tokenizer.json +3 -0
- tools/build_rknn.py +12 -0
- tools/convert_rkllm.py +45 -0
- tools/eval_board.py +24 -0
- tools/extract_llm.py +37 -0
- tools/prep_coco_subset.py +25 -0
- tools/score_coco.py +43 -0
- tools/vit_fixed.py +94 -0
.gitattributes
CHANGED
|
@@ -33,3 +33,6 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
LocateAnything-3B_LLM_RK3588_w8a8.rkllm filter=lfs diff=lfs merge=lfs -text
|
| 37 |
+
LocateAnything-3B_vision_RK3588.rknn filter=lfs diff=lfs merge=lfs -text
|
| 38 |
+
tokenizer.json filter=lfs diff=lfs merge=lfs -text
|
LICENSE
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
NVIDIA License
|
| 2 |
+
|
| 3 |
+
1. Definitions
|
| 4 |
+
|
| 5 |
+
“Licensor” means any person or entity that distributes its Work.
|
| 6 |
+
|
| 7 |
+
“Work” means (a) the original work of authorship made available under this license,
|
| 8 |
+
which may include software, documentation, or other files, and (b) any additions to or
|
| 9 |
+
derivative works thereof that are made available under this license.
|
| 10 |
+
|
| 11 |
+
The terms “reproduce,” “reproduction,” “derivative works,” and “distribution” have the
|
| 12 |
+
meaning as provided under U.S. copyright law; provided, however, that for the purposes
|
| 13 |
+
of this license, derivative works shall not include works that remain separable from, or
|
| 14 |
+
merely link (or bind by name) to the interfaces of, the Work.
|
| 15 |
+
|
| 16 |
+
Works are “made available” under this license by including in or with the Work either
|
| 17 |
+
(a) a copyright notice referencing the applicability of this license to the Work, or
|
| 18 |
+
(b) a copy of this license.
|
| 19 |
+
|
| 20 |
+
2. License Grant
|
| 21 |
+
|
| 22 |
+
2.1 Copyright Grant. Subject to the terms and conditions of this license, each Licensor
|
| 23 |
+
grants to you a perpetual, worldwide, non-exclusive, royalty-free, copyright license to
|
| 24 |
+
use, reproduce, prepare derivative works of, publicly display, publicly perform,
|
| 25 |
+
sublicense and distribute its Work and any resulting derivative works in any form.
|
| 26 |
+
|
| 27 |
+
3. Limitations
|
| 28 |
+
|
| 29 |
+
3.1 Redistribution. You may reproduce or distribute the Work only if (a) you do so under
|
| 30 |
+
this license, (b) you include a complete copy of this license with your distribution,
|
| 31 |
+
and (c) you retain without modification any copyright, patent, trademark, or attribution
|
| 32 |
+
notices that are present in the Work.
|
| 33 |
+
|
| 34 |
+
3.2 Derivative Works. You may specify that additional or different terms apply to the
|
| 35 |
+
use, reproduction, and distribution of your derivative works of the Work (“Your Terms”)
|
| 36 |
+
only if (a) Your Terms provide that the use limitation in Section 3.3 applies to your
|
| 37 |
+
derivative works, and (b) you identify the specific derivative works that are subject
|
| 38 |
+
to Your Terms. Notwithstanding Your Terms, this license (including the redistribution
|
| 39 |
+
requirements in Section 3.1) will continue to apply to the Work itself.
|
| 40 |
+
|
| 41 |
+
3.3 Use Limitation. The Work and any derivative works thereof only may be used or
|
| 42 |
+
intended for use non-commercially. Notwithstanding the foregoing, NVIDIA Corporation
|
| 43 |
+
and its affiliates may use the Work and any derivative works commercially. As used
|
| 44 |
+
herein, “non-commercially” means for research or evaluation purposes only.
|
| 45 |
+
|
| 46 |
+
3.4 Patent Claims. If you bring or threaten to bring a patent claim against any
|
| 47 |
+
Licensor (including any claim, cross-claim or counterclaim in a lawsuit) to enforce any
|
| 48 |
+
patents that you allege are infringed by any Work, then your rights under this license
|
| 49 |
+
from such Licensor (including the grant in Section 2.1) will terminate immediately.
|
| 50 |
+
|
| 51 |
+
3.5 Trademarks. This license does not grant any rights to use any Licensor’s or its
|
| 52 |
+
affiliates’ names, logos, or trademarks, except as necessary to reproduce the notices
|
| 53 |
+
described in this license.
|
| 54 |
+
|
| 55 |
+
3.6 Termination. If you violate any term of this license, then your rights under this
|
| 56 |
+
license (including the grant in Section 2.1) will terminate immediately.
|
| 57 |
+
|
| 58 |
+
4. Disclaimer of Warranty.
|
| 59 |
+
|
| 60 |
+
THE WORK IS PROVIDED “AS IS” WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER
|
| 61 |
+
EXPRESS OR IMPLIED, INCLUDING WARRANTIES OR CONDITIONS OF MERCHANTABILITY, FITNESS FOR
|
| 62 |
+
A PARTICULAR PURPOSE, TITLE OR NON-INFRINGEMENT. YOU BEAR THE RISK OF UNDERTAKING ANY
|
| 63 |
+
ACTIVITIES UNDER THIS LICENSE.
|
| 64 |
+
|
| 65 |
+
5. Limitation of Liability.
|
| 66 |
+
|
| 67 |
+
EXCEPT AS PROHIBITED BY APPLICABLE LAW, IN NO EVENT AND UNDER NO LEGAL THEORY, WHETHER
|
| 68 |
+
IN TORT (INCLUDING NEGLIGENCE), CONTRACT, OR OTHERWISE SHALL ANY LICENSOR BE LIABLE TO
|
| 69 |
+
YOU FOR DAMAGES, INCLUDING ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
|
| 70 |
+
DAMAGES ARISING OUT OF OR RELATED TO THIS LICENSE, THE USE OR INABILITY TO USE THE WORK
|
| 71 |
+
(INCLUDING BUT NOT LIMITED TO LOSS OF GOODWILL, BUSINESS INTERRUPTION, LOST PROFITS OR
|
| 72 |
+
DATA, COMPUTER FAILURE OR MALFUNCTION, OR ANY OTHER DAMAGES OR LOSSES), EVEN IF THE
|
| 73 |
+
LICENSOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
| 74 |
+
|
LICENSE-Qwen
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Qwen RESEARCH LICENSE AGREEMENT
|
| 2 |
+
|
| 3 |
+
Qwen RESEARCH LICENSE AGREEMENT Release Date: September 19, 2024
|
| 4 |
+
|
| 5 |
+
By clicking to agree or by using or distributing any portion or element of the Qwen Materials, you will be deemed to have recognized and accepted the content of this Agreement, which is effective immediately.
|
| 6 |
+
|
| 7 |
+
1. Definitions
|
| 8 |
+
a. This Qwen RESEARCH LICENSE AGREEMENT (this "Agreement") shall mean the terms and conditions for use, reproduction, distribution and modification of the Materials as defined by this Agreement.
|
| 9 |
+
b. "We" (or "Us") shall mean Alibaba Cloud.
|
| 10 |
+
c. "You" (or "Your") shall mean a natural person or legal entity exercising the rights granted by this Agreement and/or using the Materials for any purpose and in any field of use.
|
| 11 |
+
d. "Third Parties" shall mean individuals or legal entities that are not under common control with us or you.
|
| 12 |
+
e. "Qwen" shall mean the large language models, and software and algorithms, consisting of trained model weights, parameters (including optimizer states), machine-learning model code, inference-enabling code, training-enabling code, fine-tuning enabling code and other elements of the foregoing distributed by us.
|
| 13 |
+
f. "Materials" shall mean, collectively, Alibaba Cloud's proprietary Qwen and Documentation (and any portion thereof) made available under this Agreement.
|
| 14 |
+
g. "Source" form shall mean the preferred form for making modifications, including but not limited to model source code, documentation source, and configuration files.
|
| 15 |
+
h. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
|
| 16 |
+
i. "Non-Commercial" shall mean for research or evaluation purposes only.
|
| 17 |
+
|
| 18 |
+
2. Grant of Rights
|
| 19 |
+
a. You are granted a non-exclusive, worldwide, non-transferable and royalty-free limited license under Alibaba Cloud's intellectual property or other rights owned by us embodied in the Materials to use, reproduce, distribute, copy, create derivative works of, and make modifications to the Materials FOR NON-COMMERCIAL PURPOSES ONLY.
|
| 20 |
+
b. If you are commercially using the Materials, you shall request a license from us.
|
| 21 |
+
|
| 22 |
+
3. Redistribution
|
| 23 |
+
You may distribute copies or make the Materials, or derivative works thereof, available as part of a product or service that contains any of them, with or without modifications, and in Source or Object form, provided that you meet the following conditions:
|
| 24 |
+
a. You shall give any other recipients of the Materials or derivative works a copy of this Agreement;
|
| 25 |
+
b. You shall cause any modified files to carry prominent notices stating that you changed the files;
|
| 26 |
+
c. You shall retain in all copies of the Materials that you distribute the following attribution notices within a "Notice" text file distributed as a part of such copies: "Qwen is licensed under the Qwen RESEARCH LICENSE AGREEMENT, Copyright (c) Alibaba Cloud. All Rights Reserved."; and
|
| 27 |
+
d. You may add your own copyright statement to your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of your modifications, or for any such derivative works as a whole, provided your use, reproduction, and distribution of the work otherwise complies with the terms and conditions of this Agreement.
|
| 28 |
+
|
| 29 |
+
4. Rules of use
|
| 30 |
+
a. The Materials may be subject to export controls or restrictions in China, the United States or other countries or regions. You shall comply with applicable laws and regulations in your use of the Materials.
|
| 31 |
+
b. If you use the Materials or any outputs or results therefrom to create, train, fine-tune, or improve an AI model that is distributed or made available, you shall prominently display “Built with Qwen” or “Improved using Qwen” in the related product documentation.
|
| 32 |
+
|
| 33 |
+
5. Intellectual Property
|
| 34 |
+
a. We retain ownership of all intellectual property rights in and to the Materials and derivatives made by or for us. Conditioned upon compliance with the terms and conditions of this Agreement, with respect to any derivative works and modifications of the Materials that are made by you, you are and will be the owner of such derivative works and modifications.
|
| 35 |
+
b. No trademark license is granted to use the trade names, trademarks, service marks, or product names of us, except as required to fulfill notice requirements under this Agreement or as required for reasonable and customary use in describing and redistributing the Materials.
|
| 36 |
+
c. If you commence a lawsuit or other proceedings (including a cross-claim or counterclaim in a lawsuit) against us or any entity alleging that the Materials or any output therefrom, or any part of the foregoing, infringe any intellectual property or other right owned or licensable by you, then all licenses granted to you under this Agreement shall terminate as of the date such lawsuit or other proceeding is commenced or brought.
|
| 37 |
+
|
| 38 |
+
6. Disclaimer of Warranty and Limitation of Liability
|
| 39 |
+
a. We are not obligated to support, update, provide training for, or develop any further version of the Qwen Materials or to grant any license thereto.
|
| 40 |
+
b. THE MATERIALS ARE PROVIDED "AS IS" WITHOUT ANY EXPRESS OR IMPLIED WARRANTY OF ANY KIND INCLUDING WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT, OR FITNESS FOR A PARTICULAR PURPOSE. WE MAKE NO WARRANTY AND ASSUME NO RESPONSIBILITY FOR THE SAFETY OR STABILITY OF THE MATERIALS AND ANY OUTPUT THEREFROM.
|
| 41 |
+
c. IN NO EVENT SHALL WE BE LIABLE TO YOU FOR ANY DAMAGES, INCLUDING, BUT NOT LIMITED TO ANY DIRECT, OR INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING FROM YOUR USE OR INABILITY TO USE THE MATERIALS OR ANY OUTPUT OF IT, NO MATTER HOW IT’S CAUSED.
|
| 42 |
+
d. You will defend, indemnify and hold harmless us from and against any claim by any third party arising out of or related to your use or distribution of the Materials.
|
| 43 |
+
|
| 44 |
+
7. Survival and Termination.
|
| 45 |
+
a. The term of this Agreement shall commence upon your acceptance of this Agreement or access to the Materials and will continue in full force and effect until terminated in accordance with the terms and conditions herein.
|
| 46 |
+
b. We may terminate this Agreement if you breach any of the terms or conditions of this Agreement. Upon termination of this Agreement, you must delete and cease use of the Materials. Sections 6 and 8 shall survive the termination of this Agreement.
|
| 47 |
+
|
| 48 |
+
8. Governing Law and Jurisdiction.
|
| 49 |
+
a. This Agreement and any dispute arising out of or relating to it will be governed by the laws of China, without regard to conflict of law principles, and the UN Convention on Contracts for the International Sale of Goods does not apply to this Agreement.
|
| 50 |
+
b. The People's Courts in Hangzhou City shall have exclusive jurisdiction over any dispute arising out of this Agreement.
|
| 51 |
+
|
| 52 |
+
9. Other Terms and Conditions.
|
| 53 |
+
a. Any arrangements, understandings, or agreements regarding the Material not stated herein are separate from and independent of the terms and conditions of this Agreement. You shall request a separate license from us, if you use the Materials in ways not expressly agreed to in this Agreement.
|
| 54 |
+
b. We shall not be bound by any additional or different terms or conditions communicated by you unless expressly agreed.
|
LocateAnything-3B_LLM_RK3588_w8a8.rkllm
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:ea770e15b70df1afbd11ed4ec1f8a8dedc1306691be334d78d7aac94ba886d2c
|
| 3 |
+
size 3761495380
|
LocateAnything-3B_vision_RK3588.rknn
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:f2465d40113f20e8ec44db38eda8c72371e693359d539767a638d45e0d4a0d8c
|
| 3 |
+
size 919587315
|
NOTICE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
This repository contains files converted from nvidia/LocateAnything-3B (https://huggingface.co/nvidia/LocateAnything-3B).
|
| 2 |
+
|
| 3 |
+
LocateAnything-3B is Copyright (c) 2026, NVIDIA CORPORATION, and is licensed under the NVIDIA License (see LICENSE).
|
| 4 |
+
Use is limited to non-commercial research or evaluation purposes. Commercial use is not permitted, except by NVIDIA
|
| 5 |
+
Corporation and its affiliates. The converted weights and the code in this repository are derivative works of that
|
| 6 |
+
Work and are distributed under the same license; no additional terms ("Your Terms") are applied.
|
| 7 |
+
|
| 8 |
+
Qwen is licensed under the Qwen RESEARCH LICENSE AGREEMENT, Copyright (c) Alibaba Cloud. All Rights Reserved.
|
| 9 |
+
(The language model of LocateAnything-3B is Qwen2.5-3B-Instruct; see LICENSE-Qwen.)
|
| 10 |
+
|
| 11 |
+
Vision encoder: MoonViT-SO-400M by Moonshot AI, released under the MIT License as declared on its model card
|
| 12 |
+
(https://huggingface.co/moonshotai/MoonViT-SO-400M). The upstream repository does not include a LICENSE file or a
|
| 13 |
+
named copyright holder.
|
| 14 |
+
|
| 15 |
+
Built with Qwen.
|
| 16 |
+
|
| 17 |
+
Modifications: the model weights were extracted, converted and quantized (language model: RKLLM w8a8; vision encoder
|
| 18 |
+
plus projector: RKNN fp16, fixed 448x448 input) for the Rockchip RK3588 NPU. The Python files under rk3588/ and tools/
|
| 19 |
+
were written or modified for this conversion; portions are ported from NVIDIA's generate_utils.py,
|
| 20 |
+
modeling_locateanything.py and modeling_vit.py.
|
| 21 |
+
|
| 22 |
+
COCO val2017 annotations (CC BY 4.0, https://cocodataset.org) were used to build eval/eval_set.json.
|
README.md
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: other
|
| 3 |
+
license_name: nvidia-license
|
| 4 |
+
license_link: LICENSE
|
| 5 |
+
base_model: nvidia/LocateAnything-3B
|
| 6 |
+
base_model_relation: quantized
|
| 7 |
+
pipeline_tag: image-text-to-text
|
| 8 |
+
tags:
|
| 9 |
+
- rknn
|
| 10 |
+
- rkllm
|
| 11 |
+
- rk3588
|
| 12 |
+
- vlm
|
| 13 |
+
- visual-grounding
|
| 14 |
+
- object-detection
|
| 15 |
+
---
|
| 16 |
+
|
| 17 |
+
# LocateAnything-3B for RK3588 (RKLLM + RKNN)
|
| 18 |
+
|
| 19 |
+
**Built with Qwen.** Converted from [nvidia/LocateAnything-3B](https://huggingface.co/nvidia/LocateAnything-3B) so it
|
| 20 |
+
runs on the NPU of Rockchip **RK3588** boards (tested on a Radxa Rock 5C, 8 GB).
|
| 21 |
+
|
| 22 |
+
> **Non-commercial research and evaluation use only.** This is a derivative of NVIDIA's model and is distributed under
|
| 23 |
+
> the [NVIDIA License](LICENSE). It also contains Qwen2.5-3B-Instruct weights, which are subject to the
|
| 24 |
+
> [Qwen Research License](LICENSE-Qwen). See [NOTICE](NOTICE). This is an unofficial community conversion; it is not
|
| 25 |
+
> endorsed by NVIDIA, Alibaba Cloud or Rockchip.
|
| 26 |
+
|
| 27 |
+
This is **not** the same as the other LocateAnything RKNN repository on the Hub (`RKNNAI/RK182X-VLM-LocateAnything-3B`),
|
| 28 |
+
which targets the RK1828/RK182X coprocessor. The files here target RK3588 (`.rkllm` for runtime 1.3.0 and `.rknn`).
|
| 29 |
+
|
| 30 |
+
## Files
|
| 31 |
+
|
| 32 |
+
| File | Size | Description |
|
| 33 |
+
| --- | --- | --- |
|
| 34 |
+
| `LocateAnything-3B_LLM_RK3588_w8a8.rkllm` | 3.76 GB | Qwen2.5-3B language model (vocabulary extended to 152,681 with box/coordinate tokens), RKLLM 1.3.0 toolkit, w8a8, 3 NPU cores, max context 4096 |
|
| 35 |
+
| `LocateAnything-3B_vision_RK3588.rknn` | 0.92 GB | MoonViT-SO-400M + patch merger + `mlp1` projector, RKNN-Toolkit2 2.5.0, fp16 (no quantization), fixed **448x448** input, outputs 256 x 2048 |
|
| 36 |
+
| `tokenizer.json` | 11.6 MB | Tokenizer (exported from the original) |
|
| 37 |
+
| `rk3588/locate3b.py`, `rk3588/rkllm_binding.py` | | Inference engine and ctypes binding for `librkllmrt.so` |
|
| 38 |
+
| `tools/` | | Conversion and evaluation scripts |
|
| 39 |
+
| `eval/` | | Evaluation subset (ids and boxes only) and raw predictions |
|
| 40 |
+
|
| 41 |
+
SHA-256: see `SHA256SUMS`.
|
| 42 |
+
|
| 43 |
+
## Usage (on the board)
|
| 44 |
+
|
| 45 |
+
Requirements: RK3588 with the RKNPU driver, `librkllmrt.so` **1.3.0** in `/usr/lib`, `rknn-toolkit-lite2` 2.5.0,
|
| 46 |
+
`numpy`, `Pillow`, `tokenizers`. About 4.7 GB of RAM is needed (the 3.8 GB LLM plus the 0.9 GB vision model), so stop
|
| 47 |
+
other NPU services first.
|
| 48 |
+
|
| 49 |
+
```bash
|
| 50 |
+
python rk3588/locate3b.py image.jpg "Locate all the instances that matches the following description: person." -v
|
| 51 |
+
```
|
| 52 |
+
|
| 53 |
+
Prompts are the same as in the original model card, for example `Locate all the instances that matches the following
|
| 54 |
+
description: <category>.` and `Point to: <phrase>.`. Boxes are `<box><x1><y1><x2><y2></box>` with coordinates
|
| 55 |
+
normalized to 0-1000. Defaults follow the original `batch_infer.py`: `temperature=0.7, top_p=0.9,
|
| 56 |
+
repetition_penalty=1.1`. **Do not use greedy decoding**: in my tests it almost never terminates and keeps emitting
|
| 57 |
+
boxes (F1 0.38-0.46 on the same subset on a GPU).
|
| 58 |
+
|
| 59 |
+
## How it differs from the original (read this)
|
| 60 |
+
|
| 61 |
+
1. **Causal PBD window.** LocateAnything predicts a box with Parallel Box Decoding: a 6-token window
|
| 62 |
+
(`last token + 5 <text_mask>`) that uses *bidirectional* attention inside the window. RKLLM cannot take a custom
|
| 63 |
+
attention mask, so here the window is evaluated with a *causal* mask. The engine sends the accepted tokens plus
|
| 64 |
+
5 `<text_mask>` tokens each step and relies on the runtime reusing the KV cache of the common prefix (no explicit
|
| 65 |
+
rollback). Token positions match the original layout, but the model was trained with bidirectional
|
| 66 |
+
attention inside the window, so this is an approximation.
|
| 67 |
+
2. **Fixed 448x448 input.** Images are squashed to 448x448 (256 image tokens). Coordinates are normalized, so boxes
|
| 68 |
+
map back to the original size, but small objects suffer. The original supports dynamic resolution up to ~25k patches.
|
| 69 |
+
3. **Quantization.** The language model is w8a8; the vision encoder runs in fp16 on the NPU.
|
| 70 |
+
4. The hybrid MTP/AR logic (`handle_pattern`, `decode_bbox_avg`, `decode_ref`) is a numpy port of NVIDIA's code.
|
| 71 |
+
|
| 72 |
+
## Evaluation
|
| 73 |
+
|
| 74 |
+
Protocol: 100 images from COCO val2017 (seed 0; one query per image for the most frequent category; 1-8 instances;
|
| 75 |
+
all boxes >= 32x32 px; crowd regions excluded). Prompt: `Locate all the instances that matches the following
|
| 76 |
+
description: <category>.` Box F1 at IoU 0.5 (greedy matching in output order, micro-averaged), plus mean IoU of matched
|
| 77 |
+
boxes. Predictions are truncated at the first box that duplicates an earlier one (IoU > 0.85) and capped at 30 boxes,
|
| 78 |
+
applied identically to all rows. Sampling: `temperature 0.7, top_p 0.9, repetition_penalty 1.1`, one seed.
|
| 79 |
+
Because the sampling libraries differ (PyTorch vs numpy), the board and GPU rows do not see the same random draws.
|
| 80 |
+
|
| 81 |
+
| Setup | Precision | Recall | F1@0.5 | F1@0.75 | mIoU (matched) | s / image |
|
| 82 |
+
| --- | --- | --- | --- | --- | --- | --- |
|
| 83 |
+
| Original model, GPU bf16, bidirectional window, 448x448 | 0.842 | 0.716 | 0.774 | 0.660 | 0.874 | 0.14 |
|
| 84 |
+
| Original model, GPU bf16, **causal** window, 448x448 | 0.760 | 0.716 | 0.738 | 0.624 | 0.871 | 0.14 |
|
| 85 |
+
| Original model, GPU bf16, bidirectional, native resolution | 0.747 | 0.712 | 0.729 | 0.645 | 0.885 | 0.19 |
|
| 86 |
+
| **This conversion, Rock 5C (RK3588)** | 0.710 | 0.529 | **0.606** | 0.408 | 0.795 | 5.8 |
|
| 87 |
+
|
| 88 |
+
On this small subset the conversion reaches about 78% of the original's F1 (0.606 vs 0.774). Roughly 4 F1 points come
|
| 89 |
+
from the causal window; the rest comes from quantization, the fp16 NPU vision encoder and other numerical differences,
|
| 90 |
+
which I did not separate. n = 100 and a single seed, so differences of a few points are within noise. 99 of 100 outputs
|
| 91 |
+
ended normally. The Rock 5C time per image covers image encoding, prefill and about 7 decoding steps on average; I did not time the stages separately.
|
| 92 |
+
Raw predictions are in `eval/`.
|
| 93 |
+
|
| 94 |
+
## Reproducing the conversion
|
| 95 |
+
|
| 96 |
+
See `tools/`: `extract_llm.py` (split the Qwen2 language model), `convert_rkllm.py` (RKLLM 1.3.0 toolkit, w8a8),
|
| 97 |
+
`vit_fixed.py` (fixed-size MoonViT + projector with 2D RoPE and position embeddings baked in; verified against the
|
| 98 |
+
original, cosine 1.0, max abs diff 5e-4), `build_rknn.py` (RKNN-Toolkit2 2.5.0). Conversion was done on x86 Linux.
|
| 99 |
+
|
| 100 |
+
## License and attribution
|
| 101 |
+
|
| 102 |
+
- **LocateAnything-3B**, Copyright (c) 2026 NVIDIA CORPORATION, [NVIDIA License](LICENSE): non-commercial research or
|
| 103 |
+
evaluation only; redistribution must keep the license and notices. Original: https://huggingface.co/nvidia/LocateAnything-3B
|
| 104 |
+
- **Qwen2.5-3B-Instruct** language model: [Qwen Research License](LICENSE-Qwen). *Qwen is licensed under the Qwen
|
| 105 |
+
RESEARCH LICENSE AGREEMENT, Copyright (c) Alibaba Cloud. All Rights Reserved.* **Built with Qwen.**
|
| 106 |
+
Files in this repository were modified (converted and quantized).
|
| 107 |
+
- **MoonViT-SO-400M** vision encoder, Moonshot AI, MIT License (as declared by the upstream model card).
|
| 108 |
+
|
| 109 |
+
The weights are provided "as is" without warranty of any kind.
|
SHA256SUMS
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
ea770e15b70df1afbd11ed4ec1f8a8dedc1306691be334d78d7aac94ba886d2c LocateAnything-3B_LLM_RK3588_w8a8.rkllm
|
| 2 |
+
f2465d40113f20e8ec44db38eda8c72371e693359d539767a638d45e0d4a0d8c LocateAnything-3B_vision_RK3588.rknn
|
| 3 |
+
f56587c1c7b4d69be60b018606b1bf2f90e46ca9d51fb2689090997281df7e40 tokenizer.json
|
eval/eval_set.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
[{"id": 370818, "file": "img/000000370818.jpg", "cat": "potted plant", "n_gt": 1, "boxes": [[0.0, 325.96875000000006, 59.597457627118644, 431.921875]], "w": 472, "h": 640}, {"id": 343453, "file": "img/000000343453.jpg", "cat": "person", "n_gt": 1, "boxes": [[390.140625, 114.35416666666667, 686.0937500000001, 986.5416666666665]], "w": 640, "h": 480}, {"id": 119828, "file": "img/000000119828.jpg", "cat": "cat", "n_gt": 1, "boxes": [[237.1, 391.3866666666667, 877.4200000000001, 810.7466666666667]], "w": 500, "h": 375}, {"id": 47769, "file": "img/000000047769.jpg", "cat": "chair", "n_gt": 3, "boxes": [[631.74, 729.4933333333333, 774.3, 984.3466666666667], [608.26, 739.5733333333333, 704.52, 918.72], [441.54, 709.52, 575.74, 944.5066666666667]], "w": 500, "h": 375}, {"id": 438907, "file": "img/000000438907.jpg", "cat": "person", "n_gt": 2, "boxes": [[106.52838427947597, 255.5, 281.9868995633188, 766.703125], [269.73799126637556, 33.484375, 661.3318777292576, 628.4375]], "w": 458, "h": 640}, {"id": 27972, "file": "img/000000027972.jpg", "cat": "person", "n_gt": 1, "boxes": [[562.421875, 197.37089201877933, 785.2812499999999, 565.9154929577464]], "w": 640, "h": 426}, {"id": 64499, "file": "img/000000064499.jpg", "cat": "zebra", "n_gt": 2, "boxes": [[1.6875000000000002, 316.16666666666663, 594.9375, 979.0833333333333], [153.37499999999997, 391.0208333333333, 535.953125, 892.125]], "w": 640, "h": 480}, {"id": 49810, "file": "img/000000049810.jpg", "cat": "cat", "n_gt": 2, "boxes": [[178.09375, 333.32547169811323, 998.7343750000001, 1000.0], [1.484375, 426.95754716981133, 270.953125, 988.7735849056604]], "w": 640, "h": 424}, {"id": 334530, "file": "img/000000334530.jpg", "cat": "surfboard", "n_gt": 1, "boxes": [[416.921875, 501.02396514161217, 580.671875, 601.8300653594771]], "w": 640, "h": 459}, {"id": 65350, "file": "img/000000065350.jpg", "cat": "bicycle", "n_gt": 4, "boxes": [[447.046875, 54.84777517564404, 543.15625, 200.46838407494144], [342.875, 8.782201405152223, 613.34375, 207.5878220140515], [725.2500000000001, 0.0, 931.3750000000001, 220.79625292740047], [932.34375, 1.5690866510538641, 1000.0, 227.1662763466042]], "w": 640, "h": 427}, {"id": 210030, "file": "img/000000210030.jpg", "cat": "fork", "n_gt": 1, "boxes": [[475.68, 332.2, 794.6, 904.2750000000001]], "w": 500, "h": 400}, {"id": 227985, "file": "img/000000227985.jpg", "cat": "sandwich", "n_gt": 2, "boxes": [[501.10937499999994, 229.91666666666666, 930.9062499999999, 895.375], [100.89062499999999, 4.479166666666667, 654.1406249999999, 813.8958333333333]], "w": 640, "h": 480}, {"id": 27932, "file": "img/000000027932.jpg", "cat": "baseball glove", "n_gt": 1, "boxes": [[114.96527777777777, 424.7231270358306, 668.3333333333335, 826.9706840390879]], "w": 288, "h": 307}, {"id": 185292, "file": "img/000000185292.jpg", "cat": "person", "n_gt": 1, "boxes": [[419.4536817102138, 678.109375, 479.66745843230404, 753.84375]], "w": 421, "h": 640}, {"id": 207728, "file": "img/000000207728.jpg", "cat": "sheep", "n_gt": 2, "boxes": [[135.078125, 509.8659517426274, 651.59375, 990.5630026809652], [213.45312500000003, 148.04289544235925, 740.25, 997.3994638069704]], "w": 640, "h": 373}, {"id": 165518, "file": "img/000000165518.jpg", "cat": "motorcycle", "n_gt": 1, "boxes": [[427.05882352941177, 429.24836601307186, 708.7581699346405, 834.0032679738562]], "w": 612, "h": 612}, {"id": 179285, "file": "img/000000179285.jpg", "cat": "sports ball", "n_gt": 1, "boxes": [[481.61214953271025, 375.34375, 843.9018691588785, 631.453125]], "w": 428, "h": 640}, {"id": 326541, "file": "img/000000326541.jpg", "cat": "person", "n_gt": 6, "boxes": [[1.265625, 22.472222222222225, 415.87500000000006, 988.7777777777777], [506.87499999999994, 456.3333333333333, 654.7812499999999, 865.3055555555555], [715.453125, 62.916666666666664, 1000.0, 1000.0], [462.234375, 386.47222222222223, 541.90625, 672.2222222222223], [410.546875, 83.11111111111113, 968.6718750000001, 987.0], [650.1406249999999, 333.1666666666667, 699.8749999999999, 511.0555555555556]], "w": 640, "h": 360}, {"id": 312586, "file": "img/000000312586.jpg", "cat": "bear", "n_gt": 3, "boxes": [[281.15625, 569.5327102803737, 687.140625, 896.1915887850466], [606.40625, 280.16355140186914, 700.09375, 364.67289719626166], [838.265625, 100.32710280373831, 920.125, 199.2289719626168]], "w": 640, "h": 428}, {"id": 512194, "file": "img/000000512194.jpg", "cat": "vase", "n_gt": 1, "boxes": [[481.34375, 615.7352941176471, 834.0, 984.2647058823529]], "w": 640, "h": 476}, {"id": 344100, "file": "img/000000344100.jpg", "cat": "sandwich", "n_gt": 1, "boxes": [[614.71875, 442.0140515222483, 784.1250000000001, 700.4449648711944]], "w": 640, "h": 427}, {"id": 527784, "file": "img/000000527784.jpg", "cat": "sandwich", "n_gt": 3, "boxes": [[567.234375, 407.79296875, 888.84375, 690.8203125], [94.609375, 385.8203125, 228.828125, 624.66796875], [221.40624999999997, 422.55859375, 422.0625, 614.74609375]], "w": 640, "h": 512}, {"id": 231879, "file": "img/000000231879.jpg", "cat": "person", "n_gt": 5, "boxes": [[455.65625, 4.694835680751174, 762.421875, 1000.0], [99.17187499999999, 310.93896713615027, 456.76562500000006, 988.1455399061034], [190.51562500000003, 2.6995305164319245, 462.87500000000006, 351.1032863849765], [371.12500000000006, 269.17840375586854, 522.8906249999999, 740.9624413145539], [700.71875, 0.0, 872.484375, 989.2253521126761]], "w": 640, "h": 426}, {"id": 348045, "file": "img/000000348045.jpg", "cat": "toilet", "n_gt": 3, "boxes": [[770.4591836734693, 624.34375, 995.4931972789113, 905.25], [9.45578231292517, 643.46875, 236.70068027210885, 927.484375], [405.3231292517007, 638.015625, 615.0850340136055, 929.6875]], "w": 588, "h": 640}, {"id": 33104, "file": "img/000000033104.jpg", "cat": "person", "n_gt": 6, "boxes": [[55.373831775700936, 55.0, 498.411214953271, 926.34], [346.5186915887851, 71.92, 889.9532710280373, 950.56], [675.7943925233645, 42.6, 927.2429906542056, 363.22], [845.3271028037384, 0.0, 1000.0, 195.5], [926.7056074766356, 56.68, 1000.0, 587.2199999999999], [0.0, 30.72, 120.53738317757009, 510.6000000000001]], "w": 428, "h": 500}, {"id": 263860, "file": "img/000000263860.jpg", "cat": "elephant", "n_gt": 2, "boxes": [[405.15625, 203.26291079812208, 1000.0, 1000.0], [0.0, 120.49295774647887, 479.73437499999994, 1000.0]], "w": 640, "h": 426}, {"id": 367818, "file": "img/000000367818.jpg", "cat": "horse", "n_gt": 1, "boxes": [[223.828125, 116.13583138173303, 856.5781250000001, 916.1358313817332]], "w": 640, "h": 427}, {"id": 448365, "file": "img/000000448365.jpg", "cat": "person", "n_gt": 1, "boxes": [[232.93750000000003, 80.21028037383176, 579.0312500000001, 792.5700934579438]], "w": 640, "h": 428}, {"id": 163640, "file": "img/000000163640.jpg", "cat": "person", "n_gt": 3, "boxes": [[160.109375, 300.43763676148797, 454.6875, 999.5623632385121], [698.53125, 289.7374179431072, 954.84375, 1000.0], [453.15625, 353.3260393873086, 594.171875, 677.2647702407002]], "w": 640, "h": 457}, {"id": 556158, "file": "img/000000556158.jpg", "cat": "person", "n_gt": 1, "boxes": [[307.9166666666667, 220.00000000000003, 597.9166666666666, 724.4843750000001]], "w": 480, "h": 640}, {"id": 80413, "file": "img/000000080413.jpg", "cat": "teddy bear", "n_gt": 1, "boxes": [[350.5625, 233.70833333333334, 613.484375, 548.3125]], "w": 640, "h": 480}, {"id": 110359, "file": "img/000000110359.jpg", "cat": "airplane", "n_gt": 1, "boxes": [[348.65625, 351.1214953271028, 665.75, 883.7149532710281]], "w": 640, "h": 428}, {"id": 99810, "file": "img/000000099810.jpg", "cat": "donut", "n_gt": 5, "boxes": [[724.38, 898.2530120481929, 821.24, 1000.0], [811.72, 853.9457831325301, 901.24, 979.7891566265059], [751.96, 786.6566265060242, 847.6600000000001, 908.5843373493977], [664.56, 826.6867469879518, 753.02, 964.1566265060239], [393.1, 805.3012048192771, 473.92, 896.1445783132531]], "w": 500, "h": 332}, {"id": 147518, "file": "img/000000147518.jpg", "cat": "toilet", "n_gt": 2, "boxes": [[236.70833333333334, 691.765625, 527.3333333333334, 961.4218750000001], [336.125, 494.046875, 663.4166666666666, 709.0625]], "w": 480, "h": 640}, {"id": 80659, "file": "img/000000080659.jpg", "cat": "horse", "n_gt": 4, "boxes": [[481.453125, 218.6182669789227, 1000.0, 905.9953161592507], [3.0, 433.70023419203744, 205.40624999999994, 779.7658079625294], [68.87499999999999, 199.6487119437939, 601.1875, 913.6299765807962], [354.265625, 598.6651053864168, 564.7656249999999, 843.9110070257611]], "w": 640, "h": 427}, {"id": 41635, "file": "img/000000041635.jpg", "cat": "cow", "n_gt": 4, "boxes": [[6.453125, 346.22916666666663, 388.703125, 718.2708333333333], [1.6093750000000002, 533.0416666666667, 51.04687500000001, 695.6666666666666], [325.328125, 342.85416666666663, 648.703125, 677.9166666666666], [518.25, 307.4791666666667, 998.1249999999999, 641.2708333333334]], "w": 640, "h": 480}, {"id": 448448, "file": "img/000000448448.jpg", "cat": "giraffe", "n_gt": 2, "boxes": [[212.84375, 163.29166666666666, 1000.0, 1000.0], [173.59375, 4.500000000000001, 923.59375, 519.1041666666666]], "w": 640, "h": 480}, {"id": 80273, "file": "img/000000080273.jpg", "cat": "person", "n_gt": 1, "boxes": [[268.125, 106.49532710280374, 593.6875, 980.2102803738318]], "w": 640, "h": 428}, {"id": 166166, "file": "img/000000166166.jpg", "cat": "chair", "n_gt": 3, "boxes": [[30.64, 324.72, 300.0, 653.76], [719.18, 269.62666666666667, 795.9799999999999, 485.6266666666667], [802.7, 275.49333333333334, 894.0600000000001, 482.0]], "w": 500, "h": 375}, {"id": 24919, "file": "img/000000024919.jpg", "cat": "elephant", "n_gt": 2, "boxes": [[457.21875, 316.6823529411765, 810.6875, 670.7058823529411], [178.67187499999997, 350.51764705882357, 533.03125, 700.3058823529411]], "w": 640, "h": 425}, {"id": 325347, "file": "img/000000325347.jpg", "cat": "chair", "n_gt": 2, "boxes": [[454.859375, 0.0, 571.4375, 253.42618384401118], [622.9375, 9.24791086350975, 740.2656249999999, 255.06963788300834]], "w": 640, "h": 359}, {"id": 108026, "file": "img/000000108026.jpg", "cat": "person", "n_gt": 1, "boxes": [[173.9375, 0.0, 1000.0, 988.7850467289719]], "w": 640, "h": 428}, {"id": 14007, "file": "img/000000014007.jpg", "cat": "cat", "n_gt": 1, "boxes": [[531.640625, 360.0469483568075, 651.375, 700.5164319248826]], "w": 640, "h": 426}, {"id": 328683, "file": "img/000000328683.jpg", "cat": "parking meter", "n_gt": 1, "boxes": [[340.8125, 56.3125, 621.8333333333334, 374.703125]], "w": 480, "h": 640}, {"id": 427077, "file": "img/000000427077.jpg", "cat": "person", "n_gt": 1, "boxes": [[337.9651162790698, 152.26, 792.906976744186, 814.12]], "w": 344, "h": 500}, {"id": 73702, "file": "img/000000073702.jpg", "cat": "handbag", "n_gt": 2, "boxes": [[97.73706896551725, 385.078125, 151.70258620689657, 557.234375], [548.1465517241379, 392.859375, 1000.0, 909.734375]], "w": 464, "h": 640}, {"id": 357567, "file": "img/000000357567.jpg", "cat": "toilet", "n_gt": 1, "boxes": [[585.9583333333334, 570.8593750000001, 1000.0, 967.7187500000001]], "w": 480, "h": 640}, {"id": 190756, "file": "img/000000190756.jpg", "cat": "motorcycle", "n_gt": 1, "boxes": [[182.4375, 215.08333333333331, 770.265625, 884.0]], "w": 640, "h": 480}, {"id": 311909, "file": "img/000000311909.jpg", "cat": "bus", "n_gt": 1, "boxes": [[0.0, 94.375, 999.6562499999999, 903.366935483871]], "w": 640, "h": 496}, {"id": 19221, "file": "img/000000019221.jpg", "cat": "person", "n_gt": 1, "boxes": [[382.671875, 710.1046025104603, 862.6875, 993.2635983263598]], "w": 640, "h": 478}, {"id": 112626, "file": "img/000000112626.jpg", "cat": "couch", "n_gt": 1, "boxes": [[631.7730496453901, 270.53125, 1000.0, 737.328125]], "w": 423, "h": 640}, {"id": 187249, "file": "img/000000187249.jpg", "cat": "person", "n_gt": 2, "boxes": [[213.578125, 263.0833333333333, 585.828125, 658.2500000000001], [417.98437499999994, 264.79166666666663, 709.546875, 667.0416666666666]], "w": 640, "h": 480}, {"id": 267434, "file": "img/000000267434.jpg", "cat": "cow", "n_gt": 7, "boxes": [[67.734375, 434.4166666666667, 224.18749999999997, 905.375], [147.65625, 423.04166666666663, 402.68750000000006, 946.5208333333334], [435.734375, 406.3541666666667, 560.453125, 753.2708333333335], [530.46875, 457.7708333333333, 680.34375, 753.6041666666667], [627.34375, 424.70833333333337, 771.125, 738.8541666666666], [741.34375, 466.3125, 829.1875, 716.3125000000001], [810.5781249999999, 454.0416666666667, 998.2656249999999, 693.1041666666666]], "w": 640, "h": 480}, {"id": 422670, "file": "img/000000422670.jpg", "cat": "person", "n_gt": 2, "boxes": [[287.859375, 111.68618266978922, 914.578125, 965.6206088992975], [52.92187499999999, 584.3091334894614, 493.10937500000006, 999.4379391100703]], "w": 640, "h": 427}, {"id": 130566, "file": "img/000000130566.jpg", "cat": "train", "n_gt": 1, "boxes": [[29.921874999999996, 274.89461358313815, 905.046875, 736.768149882904]], "w": 640, "h": 427}, {"id": 365098, "file": "img/000000365098.jpg", "cat": "boat", "n_gt": 1, "boxes": [[62.96874999999999, 215.7377049180328, 1000.0, 914.6135831381733]], "w": 640, "h": 427}, {"id": 253386, "file": "img/000000253386.jpg", "cat": "person", "n_gt": 2, "boxes": [[4.28, 2.402402402402403, 167.22, 832.8828828828829], [838.5, 5.6456456456456445, 999.0, 965.105105105105]], "w": 500, "h": 333}, {"id": 470779, "file": "img/000000470779.jpg", "cat": "person", "n_gt": 5, "boxes": [[654.0468749999999, 77.70354906054278, 849.5781250000001, 856.9728601252609], [550.109375, 95.92901878914407, 694.125, 833.8204592901878], [400.28125000000006, 114.61377870563675, 630.7031249999999, 797.7453027139875], [95.875, 213.4864300626305, 265.73437499999994, 820.2296450939457], [165.40625, 147.24425887265136, 554.03125, 837.6409185803758]], "w": 640, "h": 479}, {"id": 335328, "file": "img/000000335328.jpg", "cat": "person", "n_gt": 2, "boxes": [[658.10546875, 345.4375, 961.40625, 517.09375], [100.80078125, 516.4375, 422.24609375, 669.078125]], "w": 512, "h": 640}, {"id": 161397, "file": "img/000000161397.jpg", "cat": "vase", "n_gt": 2, "boxes": [[141.578125, 581.1875000000001, 374.26562499999994, 761.2291666666667], [0.0, 487.6458333333333, 171.90624999999997, 728.0833333333334]], "w": 640, "h": 480}, {"id": 433980, "file": "img/000000433980.jpg", "cat": "cell phone", "n_gt": 1, "boxes": [[206.21333333333334, 582.52, 405.8666666666667, 870.14]], "w": 375, "h": 500}, {"id": 80057, "file": "img/000000080057.jpg", "cat": "teddy bear", "n_gt": 1, "boxes": [[0.0, 16.0, 901.725768321513, 630.109375]], "w": 423, "h": 640}, {"id": 336265, "file": "img/000000336265.jpg", "cat": "person", "n_gt": 1, "boxes": [[502.2916666666667, 471.578125, 569.3333333333333, 568.625]], "w": 480, "h": 640}, {"id": 133567, "file": "img/000000133567.jpg", "cat": "train", "n_gt": 1, "boxes": [[1.5, 193.24766355140184, 903.1875000000001, 685.3971962616822]], "w": 640, "h": 428}, {"id": 231549, "file": "img/000000231549.jpg", "cat": "bed", "n_gt": 1, "boxes": [[187.078125, 729.6458333333334, 793.8125, 1000.0]], "w": 640, "h": 480}, {"id": 502336, "file": "img/000000502336.jpg", "cat": "person", "n_gt": 5, "boxes": [[301.71875, 671.9953596287703, 357.921875, 907.0069605568445], [219.53125, 689.3735498839907, 299.671875, 910.5800464037123], [943.9375, 608.7935034802783, 996.921875, 888.352668213457], [474.421875, 642.2041763341067, 606.46875, 973.4338747099767], [263.87499999999994, 670.0232018561484, 306.62500000000006, 773.8515081206497]], "w": 640, "h": 431}, {"id": 468632, "file": "img/000000468632.jpg", "cat": "person", "n_gt": 4, "boxes": [[116.85937500000001, 411.2526096033403, 297.78125, 855.615866388309], [101.546875, 374.1544885177453, 229.62499999999997, 814.19624217119], [456.453125, 293.7160751565762, 652.78125, 856.4926931106471], [745.078125, 395.5114822546973, 909.8906250000001, 883.152400835073]], "w": 640, "h": 479}, {"id": 156292, "file": "img/000000156292.jpg", "cat": "clock", "n_gt": 5, "boxes": [[312.5, 377.53125, 635.0934579439253, 582.015625], [648.5046728971963, 382.0, 793.5514018691589, 473.046875], [154.6728971962617, 381.171875, 299.7196261682243, 473.59374999999994], [137.52336448598132, 478.43749999999994, 296.4719626168224, 582.609375], [336.02803738317755, 615.734375, 631.7289719626168, 806.7343749999999]], "w": 428, "h": 640}, {"id": 115885, "file": "img/000000115885.jpg", "cat": "cat", "n_gt": 1, "boxes": [[690.32, 8.613333333333333, 1000.0, 668.8266666666667]], "w": 500, "h": 375}, {"id": 581615, "file": "img/000000581615.jpg", "cat": "toilet", "n_gt": 1, "boxes": [[291.46443514644346, 603.1718749999999, 692.2175732217573, 970.515625]], "w": 478, "h": 640}, {"id": 556873, "file": "img/000000556873.jpg", "cat": "cake", "n_gt": 1, "boxes": [[232.92740046838406, 522.515625, 570.4918032786884, 765.765625]], "w": 427, "h": 640}, {"id": 575372, "file": "img/000000575372.jpg", "cat": "traffic light", "n_gt": 4, "boxes": [[632.640625, 155.64583333333331, 711.578125, 398.79166666666663], [415.953125, 343.6666666666667, 473.99999999999994, 550.4375], [188.75, 800.2708333333334, 237.28124999999997, 913.7500000000001], [940.421875, 788.1874999999999, 993.546875, 931.7708333333334]], "w": 640, "h": 480}, {"id": 394328, "file": "img/000000394328.jpg", "cat": "toilet", "n_gt": 1, "boxes": [[326.5833333333333, 579.78125, 743.0625, 984.2656250000001]], "w": 480, "h": 640}, {"id": 360943, "file": "img/000000360943.jpg", "cat": "cat", "n_gt": 1, "boxes": [[391.59680638722557, 375.8125, 554.2914171656687, 444.26562500000006]], "w": 501, "h": 640}, {"id": 287545, "file": "img/000000287545.jpg", "cat": "giraffe", "n_gt": 2, "boxes": [[374.15625, 507.3333333333333, 479.12499999999994, 726.2916666666666], [98.703125, 229.95833333333331, 639.734375, 741.0833333333334]], "w": 640, "h": 480}, {"id": 194506, "file": "img/000000194506.jpg", "cat": "bear", "n_gt": 2, "boxes": [[443.796875, 288.25301204819283, 646.1874999999999, 484.9799196787149], [125.84375, 237.0281124497992, 469.20312500000006, 552.2289156626505]], "w": 640, "h": 498}, {"id": 107087, "file": "img/000000107087.jpg", "cat": "cat", "n_gt": 1, "boxes": [[77.64062499999999, 195.62060889929742, 406.57812500000006, 813.911007025761]], "w": 640, "h": 427}, {"id": 263474, "file": "img/000000263474.jpg", "cat": "toilet", "n_gt": 1, "boxes": [[21.022964509394573, 314.60937499999994, 801.6701461377871, 964.046875]], "w": 479, "h": 640}, {"id": 407518, "file": "img/000000407518.jpg", "cat": "bird", "n_gt": 1, "boxes": [[581.28125, 210.1873536299766, 870.5, 901.1709601873537]], "w": 640, "h": 427}, {"id": 31620, "file": "img/000000031620.jpg", "cat": "person", "n_gt": 4, "boxes": [[387.0625, 373.640625, 792.6666666666667, 679.796875], [381.5625, 346.390625, 494.54166666666663, 520.15625], [0.08333333333333333, 449.46875, 61.52083333333333, 556.0625], [59.270833333333336, 395.6875, 184.9375, 608.859375]], "w": 480, "h": 640}, {"id": 398237, "file": "img/000000398237.jpg", "cat": "kite", "n_gt": 4, "boxes": [[139.265625, 499.10416666666663, 820.4687500000001, 886.125], [464.28125, 102.87500000000001, 625.796875, 282.60416666666663], [150.515625, 74.41666666666666, 389.859375, 214.29166666666666], [754.90625, 71.5, 841.171875, 197.95833333333334]], "w": 640, "h": 480}, {"id": 509403, "file": "img/000000509403.jpg", "cat": "person", "n_gt": 3, "boxes": [[562.4687500000001, 139.01639344262296, 750.953125, 876.6744730679158], [274.46875, 295.4566744730679, 332.75, 547.400468384075], [63.90625, 381.8501170960187, 146.78125, 685.9953161592506]], "w": 640, "h": 427}, {"id": 292456, "file": "img/000000292456.jpg", "cat": "person", "n_gt": 3, "boxes": [[369.1, 121.49333333333334, 625.28, 802.3999999999999], [644.52, 183.14666666666668, 708.26, 429.2266666666667], [259.82, 85.14666666666666, 380.52, 720.6933333333333]], "w": 500, "h": 375}, {"id": 359833, "file": "img/000000359833.jpg", "cat": "apple", "n_gt": 8, "boxes": [[350.75, 443.546875, 478.5833333333334, 545.828125], [0.0, 247.07812499999997, 605.25, 575.28125], [0.0, 566.078125, 312.5625, 1000.0], [113.35416666666666, 0.21875000000000003, 742.7291666666666, 118.78124999999999], [353.4375, 160.9375, 437.4375, 215.484375], [58.5625, 128.23437499999997, 155.77083333333334, 193.93749999999997], [0.0, 210.359375, 136.93750000000003, 286.796875], [305.6041666666667, 216.14062500000003, 497.0625, 297.546875]], "w": 480, "h": 640}, {"id": 261982, "file": "img/000000261982.jpg", "cat": "car", "n_gt": 3, "boxes": [[0.0, 13.328125, 551.2035010940918, 348.671875], [896.9146608315099, 188.765625, 1000.0, 332.57812500000006], [782.691466083151, 172.28125, 1000.0, 313.578125]], "w": 457, "h": 640}, {"id": 429761, "file": "img/000000429761.jpg", "cat": "person", "n_gt": 2, "boxes": [[293.04687500000006, 182.03271028037383, 482.40625000000006, 907.873831775701], [468.875, 139.32242990654206, 635.6875, 833.714953271028]], "w": 640, "h": 428}, {"id": 482719, "file": "img/000000482719.jpg", "cat": "chair", "n_gt": 2, "boxes": [[388.046875, 0.0, 780.0625, 288.08333333333337], [184.62499999999997, 0.0, 395.671875, 114.14583333333333]], "w": 640, "h": 480}, {"id": 506178, "file": "img/000000506178.jpg", "cat": "person", "n_gt": 2, "boxes": [[826.24, 198.36, 1000.0, 426.54], [188.34666666666666, 181.88, 801.2, 989.06]], "w": 375, "h": 500}, {"id": 131131, "file": "img/000000131131.jpg", "cat": "tv", "n_gt": 1, "boxes": [[84.078125, 183.75, 876.125, 872.0833333333333]], "w": 640, "h": 480}, {"id": 68286, "file": "img/000000068286.jpg", "cat": "bed", "n_gt": 1, "boxes": [[36.015625, 126.448087431694, 860.5937499999999, 999.1256830601092]], "w": 640, "h": 366}, {"id": 67896, "file": "img/000000067896.jpg", "cat": "clock", "n_gt": 1, "boxes": [[284.828125, 127.70833333333334, 748.3124999999999, 725.4583333333334]], "w": 640, "h": 480}, {"id": 297830, "file": "img/000000297830.jpg", "cat": "dog", "n_gt": 1, "boxes": [[314.51171875, 92.46875, 927.4218750000001, 849.46875]], "w": 512, "h": 640}, {"id": 398810, "file": "img/000000398810.jpg", "cat": "cat", "n_gt": 2, "boxes": [[443.02, 296.78, 997.84, 866.66], [193.74, 262.62, 388.56, 427.92]], "w": 500, "h": 500}, {"id": 569565, "file": "img/000000569565.jpg", "cat": "truck", "n_gt": 2, "boxes": [[207.515625, 447.5175644028103, 696.3125, 743.5597189695551], [742.421875, 547.2599531615925, 971.703125, 684.2857142857142]], "w": 640, "h": 427}, {"id": 161879, "file": "img/000000161879.jpg", "cat": "person", "n_gt": 1, "boxes": [[84.53125, 2.284710017574693, 369.59375, 601.8980667838313]], "w": 640, "h": 569}, {"id": 333069, "file": "img/000000333069.jpg", "cat": "giraffe", "n_gt": 2, "boxes": [[212.1728971962617, 309.6875, 771.2383177570094, 917.796875], [556.5420560747664, 294.40625, 943.2476635514017, 620.7968749999999]], "w": 428, "h": 640}, {"id": 544306, "file": "img/000000544306.jpg", "cat": "clock", "n_gt": 2, "boxes": [[536.9281045751635, 670.4901960784313, 627.2385620915034, 803.8725490196078], [718.1699346405228, 669.656862745098, 815.2450980392156, 804.6241830065359]], "w": 612, "h": 612}, {"id": 455555, "file": "img/000000455555.jpg", "cat": "person", "n_gt": 2, "boxes": [[193.125, 186.5090909090909, 710.6718750000001, 865.1636363636363], [737.34375, 82.74545454545454, 973.5781249999999, 436.43636363636364]], "w": 640, "h": 550}, {"id": 377575, "file": "img/000000377575.jpg", "cat": "dog", "n_gt": 1, "boxes": [[137.1361502347418, 248.98437499999997, 658.2394366197184, 973.1249999999999]], "w": 426, "h": 640}, {"id": 157213, "file": "img/000000157213.jpg", "cat": "elephant", "n_gt": 1, "boxes": [[429.46875, 209.47222222222223, 616.9687500000001, 612.6111111111111]], "w": 640, "h": 360}]
|
eval/preds_board_sampled.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"370818": {"text": "<ref>potted plant</ref><box>None</box><|im_end|>", "sec": 5.38, "stats": {"steps": 3, "total_s": 2.56, "npu_llm_s": 2.43, "ar_switches": 0, "tokens": 9}}, "343453": {"text": "<ref>person</ref><box><405><124><681><998></box><|im_end|>", "sec": 4.89, "stats": {"steps": 3, "total_s": 2.22, "npu_llm_s": 2.09, "ar_switches": 0, "tokens": 10}}, "119828": {"text": "<ref>cat</ref><box>None</box><|im_end|>", "sec": 4.84, "stats": {"steps": 3, "total_s": 2.18, "npu_llm_s": 2.08, "ar_switches": 0, "tokens": 7}}, "47769": {"text": "<ref>chair</ref><box>None</box><|im_end|>", "sec": 5.17, "stats": {"steps": 5, "total_s": 2.5, "npu_llm_s": 2.35, "ar_switches": 1, "tokens": 7}}, "438907": {"text": "<ref>person</ref><box><114><269><255><782></box><box><275><44><622><637></box><|im_end|>", "sec": 5.08, "stats": {"steps": 4, "total_s": 2.41, "npu_llm_s": 2.26, "ar_switches": 0, "tokens": 16}}, "27972": {"text": "<ref>person</ref><box><562><200><755><564></box><|im_end|>", "sec": 4.88, "stats": {"steps": 3, "total_s": 2.2, "npu_llm_s": 2.09, "ar_switches": 0, "tokens": 10}}, "64499": {"text": "<ref>zebra</ref><box><0><312><580><1000></box><|im_end|>", "sec": 4.9, "stats": {"steps": 3, "total_s": 2.23, "npu_llm_s": 2.11, "ar_switches": 0, "tokens": 11}}, "49810": {"text": "<ref>cat</ref><box><177><342><997><998></box><|im_end|>", "sec": 5.56, "stats": {"steps": 8, "total_s": 2.89, "npu_llm_s": 2.75, "ar_switches": 1, "tokens": 10}}, "334530": {"text": "<ref>surfboard</ref><box><414><560><573><608></box><|im_end|>", "sec": 4.9, "stats": {"steps": 3, "total_s": 2.22, "npu_llm_s": 2.11, "ar_switches": 0, "tokens": 11}}, "65350": {"text": "<ref>bicycle</ref><box><297><0><998><224></box><|im_end|>", "sec": 4.9, "stats": {"steps": 3, "total_s": 2.23, "npu_llm_s": 2.1, "ar_switches": 0, "tokens": 11}}, "210030": {"text": "<ref>fork</ref><box><488><432><759><903></box><|im_end|>", "sec": 5.45, "stats": {"steps": 7, "total_s": 2.78, "npu_llm_s": 2.65, "ar_switches": 1, "tokens": 10}}, "227985": {"text": "<ref>sandwich</ref><box><104><239><456><706></box><box><541><271><896><745></box><|im_end|>", "sec": 5.66, "stats": {"steps": 8, "total_s": 2.98, "npu_llm_s": 2.82, "ar_switches": 1, "tokens": 17}}, "27932": {"text": "<ref>baseball glove</ref><box><120><148><878><868></box><|im_end|>", "sec": 5.46, "stats": {"steps": 7, "total_s": 2.79, "npu_llm_s": 2.66, "ar_switches": 1, "tokens": 12}}, "185292": {"text": "<ref>person</ref><box><419><668><475><745></box><|im_end|>", "sec": 4.89, "stats": {"steps": 3, "total_s": 2.22, "npu_llm_s": 2.09, "ar_switches": 0, "tokens": 10}}, "207728": {"text": "<ref>sheep</ref><box><133><705><588><998></box><box><209><150><756><998></box><|im_end|>", "sec": 5.09, "stats": {"steps": 4, "total_s": 2.42, "npu_llm_s": 2.27, "ar_switches": 0, "tokens": 17}}, "165518": {"text": "<ref>motorcycle</ref><box><422><429><700><844></box><|im_end|>", "sec": 4.88, "stats": {"steps": 3, "total_s": 2.21, "npu_llm_s": 2.09, "ar_switches": 0, "tokens": 11}}, "179285": {"text": "<ref>sports ball</ref><box><484><357><854><635></box><|im_end|>", "sec": 4.9, "stats": {"steps": 3, "total_s": 2.23, "npu_llm_s": 2.11, "ar_switches": 0, "tokens": 11}}, "326541": {"text": "<ref>person</ref><box><0><0><421><1000></box><box><256><409><410><1000></box><box><408><0><1000><1000></box><box><526><407><756><1000></box><|im_end|>", "sec": 7.38, "stats": {"steps": 19, "total_s": 4.72, "npu_llm_s": 4.41, "ar_switches": 3, "tokens": 28}}, "312586": {"text": "<ref>bear</ref><box><278><559><684><908></box><|im_end|>", "sec": 4.88, "stats": {"steps": 3, "total_s": 2.2, "npu_llm_s": 2.09, "ar_switches": 0, "tokens": 10}}, "512194": {"text": "<ref>vase</ref><box><492><622><831><998></box><|im_end|>", "sec": 4.88, "stats": {"steps": 3, "total_s": 2.21, "npu_llm_s": 2.09, "ar_switches": 0, "tokens": 11}}, "344100": {"text": "<ref>sandwich</ref><box><594><431><806><703></box><|im_end|>", "sec": 4.9, "stats": {"steps": 3, "total_s": 2.23, "npu_llm_s": 2.11, "ar_switches": 0, "tokens": 11}}, "527784": {"text": "<ref>sandwich</ref><box><561><418><869><685></box><|im_end|>", "sec": 5.56, "stats": {"steps": 8, "total_s": 2.89, "npu_llm_s": 2.76, "ar_switches": 1, "tokens": 11}}, "231879": {"text": "<ref>person</ref><box><89><312><523><1000></box><box><340><290><524><1000></box><box><444><0><788><1000></box><box><637><0><876><1000></box><|im_end|>", "sec": 6.07, "stats": {"steps": 10, "total_s": 3.4, "npu_llm_s": 3.17, "ar_switches": 1, "tokens": 28}}, "348045": {"text": "<ref>toilet</ref><box><0><633><216><1000></box><box><402><636><604><1000></box><box><778><627><998><1000></box><|im_end|>", "sec": 5.3, "stats": {"steps": 5, "total_s": 2.63, "npu_llm_s": 2.45, "ar_switches": 0, "tokens": 23}}, "33104": {"text": "<ref>person</ref><box><0><0><130><923></box><box><102><0><433><909></box><box><508><0><698><908></box><box><700><0><998><888></box><|im_end|>", "sec": 6.5, "stats": {"steps": 13, "total_s": 3.83, "npu_llm_s": 3.59, "ar_switches": 2, "tokens": 28}}, "263860": {"text": "<ref>elephant</ref><box><0><122><998><998></box><|im_end|>", "sec": 4.88, "stats": {"steps": 3, "total_s": 2.21, "npu_llm_s": 2.09, "ar_switches": 0, "tokens": 11}}, "367818": {"text": "<ref>horse</ref><box><247><138><832><908></box><|im_end|>", "sec": 4.88, "stats": {"steps": 3, "total_s": 2.21, "npu_llm_s": 2.09, "ar_switches": 0, "tokens": 10}}, "448365": {"text": "<ref>person</ref><box><211><77><574><748></box><|im_end|>", "sec": 4.88, "stats": {"steps": 3, "total_s": 2.2, "npu_llm_s": 2.09, "ar_switches": 0, "tokens": 10}}, "163640": {"text": "<ref>person</ref><box><125><294><458><1000></box><box><685><295><944><1000></box><|im_end|>", "sec": 5.08, "stats": {"steps": 4, "total_s": 2.41, "npu_llm_s": 2.26, "ar_switches": 0, "tokens": 16}}, "556158": {"text": "<ref>person</ref><box><349><218><581><672></box><|im_end|>", "sec": 4.88, "stats": {"steps": 3, "total_s": 2.21, "npu_llm_s": 2.09, "ar_switches": 0, "tokens": 10}}, "80413": {"text": "<ref>teddy bear</ref><box><364><238><567><525></box><|im_end|>", "sec": 4.89, "stats": {"steps": 3, "total_s": 2.22, "npu_llm_s": 2.11, "ar_switches": 0, "tokens": 12}}, "110359": {"text": "<ref>airplane</ref><box><348><324><659><897></box><|im_end|>", "sec": 4.89, "stats": {"steps": 3, "total_s": 2.22, "npu_llm_s": 2.11, "ar_switches": 0, "tokens": 11}}, "99810": {"text": "<ref>donut</ref><box>None</box><|im_end|>", "sec": 4.87, "stats": {"steps": 3, "total_s": 2.21, "npu_llm_s": 2.1, "ar_switches": 0, "tokens": 8}}, "147518": {"text": "<ref>toilet</ref><box><222><492><658><998></box><|im_end|>", "sec": 4.88, "stats": {"steps": 3, "total_s": 2.21, "npu_llm_s": 2.09, "ar_switches": 0, "tokens": 11}}, "80659": {"text": "<ref>horse</ref><box><0><219><999><902></box><|im_end|>", "sec": 4.87, "stats": {"steps": 3, "total_s": 2.2, "npu_llm_s": 2.09, "ar_switches": 0, "tokens": 10}}, "41635": {"text": "<ref>cow</ref><box><0><322><998><685></box><|im_end|>", "sec": 4.9, "stats": {"steps": 3, "total_s": 2.22, "npu_llm_s": 2.09, "ar_switches": 0, "tokens": 10}}, "448448": {"text": "<ref>giraffe</ref><box><188><0><999><999></box><|im_end|>", "sec": 4.89, "stats": {"steps": 3, "total_s": 2.22, "npu_llm_s": 2.1, "ar_switches": 0, "tokens": 12}}, "80273": {"text": "<ref>person</ref><box><262><101><581><998></box><|im_end|>", "sec": 4.88, "stats": {"steps": 3, "total_s": 2.21, "npu_llm_s": 2.09, "ar_switches": 0, "tokens": 10}}, "166166": {"text": "<ref>chair</ref><box><0><318><225><764></box><|im_end|>", "sec": 5.17, "stats": {"steps": 5, "total_s": 2.5, "npu_llm_s": 2.38, "ar_switches": 1, "tokens": 10}}, "24919": {"text": "<ref>elephant</ref><box><161><344><511><716></box><box><483><348><812><717></box><|im_end|>", "sec": 5.09, "stats": {"steps": 4, "total_s": 2.41, "npu_llm_s": 2.27, "ar_switches": 0, "tokens": 17}}, "325347": {"text": "<ref>chair</ref><box>None</box><|im_end|>", "sec": 4.86, "stats": {"steps": 3, "total_s": 2.18, "npu_llm_s": 2.08, "ar_switches": 0, "tokens": 7}}, "108026": {"text": "<ref>person</ref><box><161><0><1000><1000></box><|im_end|>", "sec": 4.88, "stats": {"steps": 3, "total_s": 2.21, "npu_llm_s": 2.09, "ar_switches": 0, "tokens": 10}}, "14007": {"text": "<ref>cat</ref><box>None</box><|im_end|>", "sec": 4.85, "stats": {"steps": 3, "total_s": 2.18, "npu_llm_s": 2.08, "ar_switches": 0, "tokens": 7}}, "328683": {"text": "<ref>parking meter</ref><box><358><58><594><932></box><|im_end|>", "sec": 4.9, "stats": {"steps": 3, "total_s": 2.22, "npu_llm_s": 2.11, "ar_switches": 0, "tokens": 12}}, "427077": {"text": "<ref>person</ref><box><358><148><800><818></box><|im_end|>", "sec": 4.87, "stats": {"steps": 3, "total_s": 2.21, "npu_llm_s": 2.09, "ar_switches": 0, "tokens": 10}}, "73702": {"text": "<ref>handbag</ref><box>None</box><|im_end|>", "sec": 4.88, "stats": {"steps": 3, "total_s": 2.2, "npu_llm_s": 2.1, "ar_switches": 0, "tokens": 8}}, "357567": {"text": "<ref>toilet</ref><box><577><720><998><998></box><|im_end|>", "sec": 4.88, "stats": {"steps": 3, "total_s": 2.21, "npu_llm_s": 2.09, "ar_switches": 0, "tokens": 11}}, "190756": {"text": "<ref>motorcycle</ref><box><148><198><780><910></box><|im_end|>", "sec": 5.46, "stats": {"steps": 7, "total_s": 2.79, "npu_llm_s": 2.64, "ar_switches": 1, "tokens": 11}}, "311909": {"text": "<ref>bus</ref><box><0><99><999><905></box><|im_end|>", "sec": 4.88, "stats": {"steps": 3, "total_s": 2.21, "npu_llm_s": 2.1, "ar_switches": 0, "tokens": 10}}, "19221": {"text": "<ref>person</ref><box><128><0><901><1000></box><|im_end|>", "sec": 5.58, "stats": {"steps": 8, "total_s": 2.91, "npu_llm_s": 2.76, "ar_switches": 1, "tokens": 10}}, "112626": {"text": "<ref>couch</ref><box><612><267><998><733></box><|im_end|>", "sec": 4.9, "stats": {"steps": 3, "total_s": 2.22, "npu_llm_s": 2.1, "ar_switches": 0, "tokens": 11}}, "187249": {"text": "<ref>person</ref><box><200><262><588><668></box><|im_end|>", "sec": 4.89, "stats": {"steps": 3, "total_s": 2.22, "npu_llm_s": 2.09, "ar_switches": 0, "tokens": 10}}, "267434": {"text": "<ref>cow</ref><box><78><426><239><906></box><box><188><412><379><1000></box><box><438><402><567><751></box><box><542><418><644><743></box><box><633><413><752><734></box><box><728><415><827><705></box><box><821><416><935><681></box><box><897><417><1000><698></box><|im_end|>", "sec": 7.23, "stats": {"steps": 16, "total_s": 4.55, "npu_llm_s": 4.18, "ar_switches": 2, "tokens": 52}}, "422670": {"text": "<ref>person</ref><box><340><146><998><998></box><|im_end|>", "sec": 4.87, "stats": {"steps": 3, "total_s": 2.2, "npu_llm_s": 2.09, "ar_switches": 0, "tokens": 10}}, "130566": {"text": "<ref>train</ref><box><0><272><911><733></box><|im_end|>", "sec": 4.88, "stats": {"steps": 3, "total_s": 2.2, "npu_llm_s": 2.09, "ar_switches": 0, "tokens": 10}}, "365098": {"text": "<ref>boat</ref><box><74><144><1000><945></box><|im_end|>", "sec": 5.45, "stats": {"steps": 7, "total_s": 2.78, "npu_llm_s": 2.65, "ar_switches": 1, "tokens": 10}}, "253386": {"text": "<ref>person</ref><box><0><0><998><998></box><|im_end|>", "sec": 4.87, "stats": {"steps": 3, "total_s": 2.21, "npu_llm_s": 2.09, "ar_switches": 0, "tokens": 10}}, "470779": {"text": "<ref>person</ref><box><88><200><275><812></box><box><231><188><439><815></box><box><359><155><576><778></box><box><510><115><684><770></box><box><611><92><842><755></box><|im_end|>", "sec": 5.71, "stats": {"steps": 7, "total_s": 3.04, "npu_llm_s": 2.8, "ar_switches": 0, "tokens": 34}}, "335328": {"text": "<ref>person</ref><box><108><515><418><667></box><box><664><326><958><511></box><|im_end|>", "sec": 5.08, "stats": {"steps": 4, "total_s": 2.41, "npu_llm_s": 2.26, "ar_switches": 0, "tokens": 16}}, "161397": {"text": "<ref>vase</ref><box><130><552><362><760></box><|im_end|>", "sec": 5.56, "stats": {"steps": 8, "total_s": 2.89, "npu_llm_s": 2.76, "ar_switches": 1, "tokens": 11}}, "433980": {"text": "<ref>cell phone</ref><box><205><562><380><998></box><|im_end|>", "sec": 5.58, "stats": {"steps": 8, "total_s": 2.91, "npu_llm_s": 2.77, "ar_switches": 1, "tokens": 11}}, "80057": {"text": "<ref>teddy bear</ref><box><0><0><881><655></box><|im_end|>", "sec": 4.9, "stats": {"steps": 3, "total_s": 2.23, "npu_llm_s": 2.11, "ar_switches": 0, "tokens": 12}}, "336265": {"text": "<ref>person</ref><box><515><477><569><564></box><|im_end|>", "sec": 4.88, "stats": {"steps": 3, "total_s": 2.21, "npu_llm_s": 2.09, "ar_switches": 0, "tokens": 10}}, "133567": {"text": "<ref>train</ref><box><0><201><900><694></box><|im_end|>", "sec": 4.88, "stats": {"steps": 3, "total_s": 2.21, "npu_llm_s": 2.09, "ar_switches": 0, "tokens": 10}}, "231549": {"text": "<ref>bed</ref><box><163><0><839><998></box><|im_end|>", "sec": 5.58, "stats": {"steps": 8, "total_s": 2.91, "npu_llm_s": 2.76, "ar_switches": 1, "tokens": 10}}, "502336": {"text": "<ref>person</ref><box><261><684><594><998></box><box><947><617><1000><888></box><|im_end|>", "sec": 5.77, "stats": {"steps": 9, "total_s": 3.1, "npu_llm_s": 2.94, "ar_switches": 1, "tokens": 16}}, "468632": {"text": "<ref>person</ref><box><108><362><250><856></box><box><112><293><612><866></box><box><456><291><637><749></box><box><770><376><912><888></box><|im_end|>", "sec": 5.95, "stats": {"steps": 9, "total_s": 3.28, "npu_llm_s": 3.05, "ar_switches": 1, "tokens": 28}}, "156292": {"text": "<ref>clock</ref><box>None</box><|im_end|>", "sec": 4.86, "stats": {"steps": 3, "total_s": 2.19, "npu_llm_s": 2.08, "ar_switches": 0, "tokens": 7}}, "115885": {"text": "<ref>cat</ref><box><448><405><998><995></box><|im_end|>", "sec": 5.44, "stats": {"steps": 7, "total_s": 2.76, "npu_llm_s": 2.64, "ar_switches": 1, "tokens": 10}}, "581615": {"text": "<ref>toilet</ref><box><304><597><673><998></box><|im_end|>", "sec": 4.89, "stats": {"steps": 3, "total_s": 2.22, "npu_llm_s": 2.1, "ar_switches": 0, "tokens": 11}}, "556873": {"text": "<ref>cake</ref><box><204><497><577><828></box><|im_end|>", "sec": 4.88, "stats": {"steps": 3, "total_s": 2.21, "npu_llm_s": 2.1, "ar_switches": 0, "tokens": 10}}, "575372": {"text": "<ref>traffic light</ref><box><417><766><480><999></box><box><422><364><471><569></box><box><495><144><700><380></box><box><922><765><1000><999></box><|im_end|>", "sec": 6.53, "stats": {"steps": 13, "total_s": 3.86, "npu_llm_s": 3.61, "ar_switches": 2, "tokens": 29}}, "394328": {"text": "<ref>toilet</ref><box><336><569><748><998></box><|im_end|>", "sec": 4.88, "stats": {"steps": 3, "total_s": 2.21, "npu_llm_s": 2.09, "ar_switches": 0, "tokens": 11}}, "360943": {"text": "<ref>cat</ref><box><403><359><556><456></box><|im_end|>", "sec": 4.87, "stats": {"steps": 3, "total_s": 2.2, "npu_llm_s": 2.09, "ar_switches": 0, "tokens": 10}}, "287545": {"text": "<ref>giraffe</ref><box><95><234><603><748></box><box><353><479><495><735></box><|im_end|>", "sec": 5.79, "stats": {"steps": 9, "total_s": 3.12, "npu_llm_s": 2.95, "ar_switches": 1, "tokens": 18}}, "194506": {"text": "<ref>bear</ref><box><133><218><471><574></box><box><454><295><627><508></box><|im_end|>", "sec": 5.77, "stats": {"steps": 9, "total_s": 3.1, "npu_llm_s": 2.93, "ar_switches": 1, "tokens": 16}}, "107087": {"text": "<ref>cat</ref><box>None</box><|im_end|>", "sec": 4.85, "stats": {"steps": 3, "total_s": 2.18, "npu_llm_s": 2.08, "ar_switches": 0, "tokens": 7}}, "263474": {"text": "<ref>toilet</ref><box><47><312><806><998></box><|im_end|>", "sec": 4.88, "stats": {"steps": 3, "total_s": 2.21, "npu_llm_s": 2.09, "ar_switches": 0, "tokens": 11}}, "407518": {"text": "<ref>bird</ref><box><573><197><866><826></box><|im_end|>", "sec": 5.18, "stats": {"steps": 5, "total_s": 2.51, "npu_llm_s": 2.39, "ar_switches": 1, "tokens": 10}}, "31620": {"text": "<ref>person</ref><box><406><357><511><630></box><|im_end|>", "sec": 5.56, "stats": {"steps": 8, "total_s": 2.89, "npu_llm_s": 2.76, "ar_switches": 1, "tokens": 10}}, "398237": {"text": "<ref>kite</ref><box><131><491><408><718></box><box><138><77><366><235></box><box><475><106><612><267></box><box><769><70><842><207></box><|im_end|>", "sec": 6.67, "stats": {"steps": 14, "total_s": 3.99, "npu_llm_s": 3.75, "ar_switches": 2, "tokens": 29}}, "509403": {"text": "<ref>person</ref><box><71><362><135><697></box><box><260><300><339><519></box><box><562><143><757><888></box><|im_end|>", "sec": 5.31, "stats": {"steps": 5, "total_s": 2.63, "npu_llm_s": 2.45, "ar_switches": 0, "tokens": 22}}, "292456": {"text": "<ref>person</ref><box><241><94><375><730></box><box><405><126><598><944></box><box><625><176><892><946></box><|im_end|>", "sec": 5.3, "stats": {"steps": 5, "total_s": 2.63, "npu_llm_s": 2.45, "ar_switches": 0, "tokens": 22}}, "359833": {"text": "<ref>apple</ref><box><0><158><42><201></box><box><0><212><67><266></box><box><0><262><71><315></box><box><0><312><73><375></box><box><0><372><78><435></box><box><0><432><83><505></box><box><0><502><89><562></box><box><0><625><91><708></box><box><0><702><92><818></box><box><0><810><94><909></box><box><2><107><53><153></box><box><5><148><97><207></box><box><7><215><98><267></box><box><8><265><101><318></box><box><10><316><103><370></box><box><12><88><109><150></box><box><15><558><114><638></box><box><19><807><122><909></box><box><23><557><112><639></box><box><25><417><125><481></box><box><29><477><102><532></box><box><31><90><105><148></box><box><33><145><128><203></box><box><35><204><127><262></box><box><37><258><132><317></box><box><38><310><135><373></box><box><40><367><137><422></box><box><44><425><142><478></box><box><47><168><131><216></box><box><50><770><123><839></box><box><52><898><113><969></box><box><57><70><136><124></box><box><59><909><130><982></box><box><62><697><143><152></box><box><65><492><140><561></box><box><69><652><141><715></box><box><72><147><160><205></box><box><77><254><164><319></box><box><79><206><167><263></box><box><81><315><165><368></box><box><85><420><169><420></box><box><87><68><173><119></box><box><89><419><175><482></box><box><93><674><163><743></box><box><95><916><174><974></box><box><96><908><177><972></box><box><99><718><188><791></box><box><100><788><185><863></box><box><104><782><192><853></box><box><106><536><179><621></box><box><108><893><191><959></box><box><110><628><194><694></box><box><111><230><189><286></box><box><115><288><198><322></box><box><117><320><199><369></box><box><120><366><208><423></box><box><126><418><211><480></box><box><129><197><213><250></box><box><133><479><223><540></box><box><134><121><226><172></box><box><138><843><223><915></box><box><139><64><227><118></box><box><144><912><228><966></box><box><146><769><233><836></box><box><151><232><225><290></box><box><154><282><235><325></box><box><156><321><237><365></box>", "sec": 64.61, "stats": {"steps": 222, "total_s": 61.94, "npu_llm_s": 56.79, "ar_switches": 43, "tokens": 405}}, "261982": {"text": "<ref>car</ref><box><0><0><574><358></box><|im_end|>", "sec": 5.31, "stats": {"steps": 6, "total_s": 2.64, "npu_llm_s": 2.51, "ar_switches": 1, "tokens": 10}}, "429761": {"text": "<ref>person</ref><box><304><188><500><924></box><box><452><133><612><856></box><|im_end|>", "sec": 5.09, "stats": {"steps": 4, "total_s": 2.41, "npu_llm_s": 2.26, "ar_switches": 0, "tokens": 16}}, "482719": {"text": "<ref>chair</ref><box>None</box><|im_end|>", "sec": 4.86, "stats": {"steps": 3, "total_s": 2.18, "npu_llm_s": 2.08, "ar_switches": 0, "tokens": 7}}, "506178": {"text": "<ref>person</ref><box><197><188><760><998></box><|im_end|>", "sec": 5.3, "stats": {"steps": 6, "total_s": 2.63, "npu_llm_s": 2.5, "ar_switches": 1, "tokens": 10}}, "131131": {"text": "<ref>tv</ref><box><104><202><887><999></box><|im_end|>", "sec": 4.88, "stats": {"steps": 3, "total_s": 2.21, "npu_llm_s": 2.1, "ar_switches": 0, "tokens": 10}}, "68286": {"text": "<ref>bed</ref><box><0><149><856><998></box><|im_end|>", "sec": 4.87, "stats": {"steps": 3, "total_s": 2.21, "npu_llm_s": 2.09, "ar_switches": 0, "tokens": 10}}, "67896": {"text": "<ref>clock</ref><box><271><140><729><755></box><|im_end|>", "sec": 4.88, "stats": {"steps": 3, "total_s": 2.21, "npu_llm_s": 2.09, "ar_switches": 0, "tokens": 10}}, "297830": {"text": "<ref>dog</ref><box><336><88><908><1000></box><|im_end|>", "sec": 4.88, "stats": {"steps": 3, "total_s": 2.21, "npu_llm_s": 2.09, "ar_switches": 0, "tokens": 10}}, "398810": {"text": "<ref>cat</ref><box><452><302><998><903></box><|im_end|>", "sec": 5.17, "stats": {"steps": 5, "total_s": 2.5, "npu_llm_s": 2.38, "ar_switches": 1, "tokens": 10}}, "569565": {"text": "<ref>truck</ref><box><188><431><998><732></box><|im_end|>", "sec": 4.89, "stats": {"steps": 3, "total_s": 2.21, "npu_llm_s": 2.1, "ar_switches": 0, "tokens": 10}}, "161879": {"text": "<ref>person</ref><box><102><0><362><604></box><|im_end|>", "sec": 4.88, "stats": {"steps": 3, "total_s": 2.2, "npu_llm_s": 2.09, "ar_switches": 0, "tokens": 10}}, "333069": {"text": "<ref>giraffe</ref><box><222><304><600><915></box><box><538><300><908><908></box><|im_end|>", "sec": 5.1, "stats": {"steps": 4, "total_s": 2.43, "npu_llm_s": 2.28, "ar_switches": 0, "tokens": 18}}, "544306": {"text": "<ref>clock</ref><box><541><660><616><810></box><box><716><662><819><808></box><|im_end|>", "sec": 5.08, "stats": {"steps": 4, "total_s": 2.41, "npu_llm_s": 2.26, "ar_switches": 0, "tokens": 16}}, "455555": {"text": "<ref>person</ref><box><222><200><673><902></box><box><728><98><960><425></box><|im_end|>", "sec": 5.77, "stats": {"steps": 9, "total_s": 3.1, "npu_llm_s": 2.93, "ar_switches": 1, "tokens": 16}}, "377575": {"text": "<ref>dog</ref><box><128><302><622><958></box><|im_end|>", "sec": 4.88, "stats": {"steps": 3, "total_s": 2.2, "npu_llm_s": 2.09, "ar_switches": 0, "tokens": 10}}, "157213": {"text": "<ref>elephant</ref><box><438><208><607><630></box><|im_end|>", "sec": 4.88, "stats": {"steps": 3, "total_s": 2.21, "npu_llm_s": 2.1, "ar_switches": 0, "tokens": 11}}}
|
eval/preds_gpu_sampled.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"gpu_bidir_448": {"370818": {"text": "<ref>potted plant</ref><box>None</box><|im_end|>", "sec": 0.8}, "343453": {"text": "<ref>person</ref><box><395><123><681><998></box><|im_end|>", "sec": 0.11}, "119828": {"text": "<ref>cat</ref><box><224><398><880><998></box><|im_end|>", "sec": 0.14}, "47769": {"text": "<ref>chair</ref><box><625><726><775><998></box><|im_end|>", "sec": 0.09}, "438907": {"text": "<ref>person</ref><box><98><253><274><773></box><box><277><33><655><630></box><|im_end|>", "sec": 0.11}, "27972": {"text": "<ref>person</ref><box><567><206><783><574></box><|im_end|>", "sec": 0.09}, "64499": {"text": "<ref>zebra</ref><box><0><324><585><998></box><|im_end|>", "sec": 0.09}, "49810": {"text": "<ref>cat</ref><box><0><356><998><998></box><|im_end|>", "sec": 0.17}, "334530": {"text": "<ref>surfboard</ref><box><380><485><577><602></box><|im_end|>", "sec": 0.09}, "65350": {"text": "<ref>bicycle</ref><box><344><0><998><228></box><|im_end|>", "sec": 0.14}, "210030": {"text": "<ref>fork</ref><box><472><339><790><905></box><|im_end|>", "sec": 0.15}, "227985": {"text": "<ref>sandwich</ref><box><47><0><928><905></box><|im_end|>", "sec": 0.15}, "27932": {"text": "<ref>baseball glove</ref><box><77><317><770><925></box><|im_end|>", "sec": 0.09}, "185292": {"text": "<ref>person</ref><box><417><677><480><750></box><|im_end|>", "sec": 0.09}, "207728": {"text": "<ref>sheep</ref><box><142><590><650><998></box><box><212><148><740><755></box><|im_end|>", "sec": 0.11}, "165518": {"text": "<ref>motorcycle</ref><box><402><427><709><833></box><|im_end|>", "sec": 0.09}, "179285": {"text": "<ref>sports ball</ref><box><480><373><848><624></box><|im_end|>", "sec": 0.09}, "326541": {"text": "<ref>person</ref><box><0><5><441><998></box><box><265><410><507><1000></box><box><402><387><546><676></box><box><403><81><997><998></box><box><502><465><668><890></box><box><667><342><705><433></box><|im_end|>", "sec": 0.46}, "312586": {"text": "<ref>bear</ref><box><281><562><688><894></box><|im_end|>", "sec": 0.09}, "512194": {"text": "<ref>vase</ref><box><487><618><834><998></box><|im_end|>", "sec": 0.09}, "344100": {"text": "<ref>sandwich</ref><box><610><446><791><701></box><|im_end|>", "sec": 0.09}, "527784": {"text": "<ref>sandwich</ref><box><0><387><480><618></box><box><508><410><1000><882></box><|im_end|>", "sec": 0.19}, "231879": {"text": "<ref>person</ref><box><82><322><519><1000></box><box><186><0><461><702></box><box><333><300><520><1000></box><box><448><0><778><1000></box><box><679><0><874><1000></box><|im_end|>", "sec": 0.2}, "348045": {"text": "<ref>toilet</ref><box><7><639><235><924></box><box><407><634><612><926></box><box><768><628><992><904></box><|im_end|>", "sec": 0.13}, "33104": {"text": "<ref>person</ref><box><0><0><120><902></box><box><47><66><480><932></box><box><372><96><812><958></box><box><678><48><998><868></box><box><848><0><998><592></box><|im_end|>", "sec": 0.17}, "263860": {"text": "<ref>elephant</ref><box><0><127><479><998></box><box><409><195><998><998></box><|im_end|>", "sec": 0.16}, "367818": {"text": "<ref>horse</ref><box><220><127><848><890></box><|im_end|>", "sec": 0.09}, "448365": {"text": "<ref>person</ref><box><233><77><580><794></box><box><695><499><748><602></box><|im_end|>", "sec": 0.18}, "163640": {"text": "<ref>person</ref><box><132><293><452><1000></box><box><472><354><598><677></box><box><698><298><948><1000></box><|im_end|>", "sec": 0.13}, "556158": {"text": "<ref>person</ref><box><325><224><593><674></box><|im_end|>", "sec": 0.09}, "80413": {"text": "<ref>teddy bear</ref><box><348><231><616><544></box><|im_end|>", "sec": 0.09}, "110359": {"text": "<ref>airplane</ref><box><342><345><658><888></box><|im_end|>", "sec": 0.09}, "99810": {"text": "<ref>donut</ref><box><400><802><477><892></box><box><663><830><753><965></box><box><725><897><820><998></box><box><750><785><848><905></box><box><810><852><900><988></box><|im_end|>", "sec": 0.17}, "147518": {"text": "<ref>toilet</ref><box><241><500><650><970></box><|im_end|>", "sec": 0.09}, "80659": {"text": "<ref>horse</ref><box><0><208><849><880></box><box><478><225><998><967></box><|im_end|>", "sec": 0.18}, "41635": {"text": "<ref>cow</ref><box><0><325><398><703></box><box><320><333><648><674></box><box><516><310><998><642></box><|im_end|>", "sec": 0.18}, "448448": {"text": "<ref>giraffe</ref><box><158><0><998><998></box><|im_end|>", "sec": 0.12}, "80273": {"text": "<ref>person</ref><box><267><105><595><980></box><|im_end|>", "sec": 0.09}, "166166": {"text": "<ref>chair</ref><box><0><324><258><998></box><|im_end|>", "sec": 0.12}, "24919": {"text": "<ref>elephant</ref><box><181><353><536><706></box><box><469><357><811><709></box><|im_end|>", "sec": 0.15}, "325347": {"text": "<ref>chair</ref><box><445><9><570><255></box><box><622><10><740><254></box><|im_end|>", "sec": 0.11}, "108026": {"text": "<ref>person</ref><box><176><0><998><998></box><|im_end|>", "sec": 0.09}, "14007": {"text": "<ref>cat</ref><box><536><369><654><698></box><|im_end|>", "sec": 0.17}, "328683": {"text": "<ref>parking meter</ref><box><345><51><608><362></box><|im_end|>", "sec": 0.09}, "427077": {"text": "<ref>person</ref><box><328><148><793><817></box><|im_end|>", "sec": 0.09}, "73702": {"text": "<ref>handbag</ref><box><538><365><995><905></box><|im_end|>", "sec": 0.15}, "357567": {"text": "<ref>toilet</ref><box><582><575><998><969></box><|im_end|>", "sec": 0.14}, "190756": {"text": "<ref>motorcycle</ref><box><182><94><769><882></box><|im_end|>", "sec": 0.09}, "311909": {"text": "<ref>bus</ref><box><0><94><979><905></box><|im_end|>", "sec": 0.09}, "19221": {"text": "<ref>person</ref><box><382><693><852><998></box><|im_end|>", "sec": 0.09}, "112626": {"text": "<ref>couch</ref><box><623><265><1000><732></box><|im_end|>", "sec": 0.09}, "187249": {"text": "<ref>person</ref><box><211><262><588><664></box><box><416><261><717><667></box><|im_end|>", "sec": 0.12}, "267434": {"text": "<ref>cow</ref><box><66><448><216><897></box><box><151><423><399><951></box><box><437><410><562><758></box><box><527><459><641><747></box><box><627><462><689><706></box><box><662><441><812><753></box><box><792><456><1000><688></box><|im_end|>", "sec": 0.21}, "422670": {"text": "<ref>person</ref><box><200><129><722><998></box><|im_end|>", "sec": 0.09}, "130566": {"text": "<ref>train</ref><box><28><272><906><740></box><|im_end|>", "sec": 0.09}, "365098": {"text": "<ref>boat</ref><box><67><228><999><912></box><|im_end|>", "sec": 0.16}, "253386": {"text": "<ref>person</ref><box><0><0><998><998></box><|im_end|>", "sec": 0.14}, "470779": {"text": "<ref>person</ref><box><83><199><276><844></box><box><211><143><490><865></box><box><405><115><625><793></box><box><511><86><708><849></box><box><648><62><843><857></box><|im_end|>", "sec": 0.17}, "335328": {"text": "<ref>person</ref><box><106><520><414><672></box><box><658><344><962><519></box><|im_end|>", "sec": 0.11}, "161397": {"text": "<ref>vase</ref><box><0><46><222><370></box><box><0><358><134><735></box><box><137><355><372><765></box><box><265><165><348><283></box><box><352><180><467><345></box><|im_end|>", "sec": 0.38}, "433980": {"text": "<ref>cell phone</ref><box><208><575><408><869></box><|im_end|>", "sec": 0.12}, "80057": {"text": "<ref>teddy bear</ref><box><0><15><892><655></box><|im_end|>", "sec": 0.09}, "336265": {"text": "<ref>person</ref><box><505><474><570><573></box><|im_end|>", "sec": 0.09}, "133567": {"text": "<ref>train</ref><box><0><200><897><694></box><|im_end|>", "sec": 0.09}, "231549": {"text": "<ref>bed</ref><box><179><733><808><999></box><|im_end|>", "sec": 0.09}, "502336": {"text": "<ref>person</ref><box><214><689><282><911></box><box><262><671><314><909></box><box><300><670><364><919></box><box><475><642><607><968></box><box><947><609><998><887></box><|im_end|>", "sec": 0.17}, "468632": {"text": "<ref>person</ref><box><111><411><298><859></box><box><116><381><225><819></box><box><455><301><653><856></box><box><745><385><908><883></box><|im_end|>", "sec": 0.15}, "156292": {"text": "<ref>clock</ref><box><317><373><637><585></box><|im_end|>", "sec": 0.09}, "115885": {"text": "<ref>cat</ref><box><694><0><998><661></box><|im_end|>", "sec": 0.12}, "581615": {"text": "<ref>toilet</ref><box><302><600><681><1000></box><|im_end|>", "sec": 0.09}, "556873": {"text": "<ref>cake</ref><box><239><523><575><778></box><|im_end|>", "sec": 0.09}, "575372": {"text": "<ref>traffic light</ref><box><191><791><242><918></box><box><416><347><474><547></box><box><636><153><705><397></box><box><927><792><998><932></box><|im_end|>", "sec": 0.18}, "394328": {"text": "<ref>toilet</ref><box><325><578><740><998></box><|im_end|>", "sec": 0.09}, "360943": {"text": "<ref>cat</ref><box><396><374><553><440></box><|im_end|>", "sec": 0.09}, "287545": {"text": "<ref>giraffe</ref><box><94><228><640><740></box><box><363><513><484><722></box><|im_end|>", "sec": 0.11}, "194506": {"text": "<ref>bear</ref><box><120><234><473><538></box><box><438><289><650><533></box><|im_end|>", "sec": 0.11}, "107087": {"text": "<ref>cat</ref><box><42><178><414><998></box><|im_end|>", "sec": 0.17}, "263474": {"text": "<ref>toilet</ref><box><38><315><798><974></box><|im_end|>", "sec": 0.09}, "407518": {"text": "<ref>bird</ref><box><580><209><868><887></box><|im_end|>", "sec": 0.09}, "31620": {"text": "<ref>person</ref><box><0><391><179><607></box><box><385><349><797><679></box><box><865><544><998><998></box><|im_end|>", "sec": 0.13}, "398237": {"text": "<ref>kite</ref><box><142><506><774><773></box><box><151><0><520><383></box><box><471><106><623><277></box><box><753><71><839><199></box><|im_end|>", "sec": 0.35}, "509403": {"text": "<ref>person</ref><box><565><135><750><870></box><|im_end|>", "sec": 0.14}, "292456": {"text": "<ref>person</ref><box><258><84><382><725></box><box><368><121><824><930></box><box><618><176><886><900></box><|im_end|>", "sec": 0.13}, "359833": {"text": "<ref>apple</ref><box><0><67><713><331></box><box><0><185><600><456></box><box><0><445><319><573></box><box><0><553><321><998></box><box><120><0><734><117></box><box><123><453><475><552></box><box><272><467><369><583></box><box><462><422><584><505></box><|im_end|>", "sec": 0.34}, "261982": {"text": "<ref>car</ref><box><0><16><551><356></box><|im_end|>", "sec": 0.14}, "429761": {"text": "<ref>person</ref><box><297><190><485><905></box><box><449><142><635><835></box><|im_end|>", "sec": 0.11}, "482719": {"text": "<ref>chair</ref><box><186><0><763><291></box><|im_end|>", "sec": 0.15}, "506178": {"text": "<ref>person</ref><box><176><184><869><1000></box><|im_end|>", "sec": 0.14}, "131131": {"text": "<ref>tv</ref><box><88><186><876><863></box><|im_end|>", "sec": 0.09}, "68286": {"text": "<ref>bed</ref><box><35><146><859><998></box><|im_end|>", "sec": 0.09}, "67896": {"text": "<ref>clock</ref><box><255><103><755><792></box><|im_end|>", "sec": 0.09}, "297830": {"text": "<ref>dog</ref><box><318><62><918><946></box><|im_end|>", "sec": 0.09}, "398810": {"text": "<ref>cat</ref><box><210><258><393><433></box><box><449><308><998><866></box><|im_end|>", "sec": 0.16}, "569565": {"text": "<ref>truck</ref><box><209><435><706><745></box><|im_end|>", "sec": 0.09}, "161879": {"text": "<ref>person</ref><box><94><0><366><606></box><|im_end|>", "sec": 0.09}, "333069": {"text": "<ref>giraffe</ref><box><220><306><629><908></box><box><539><305><922><642></box><|im_end|>", "sec": 0.19}, "544306": {"text": "<ref>clock</ref><box><534><663><632><823></box><box><712><667><820><824></box><|im_end|>", "sec": 0.11}, "455555": {"text": "<ref>person</ref><box><188><184><717><860></box><box><722><85><977><439></box><|im_end|>", "sec": 0.11}, "377575": {"text": "<ref>dog</ref><box><141><269><642><944></box><|im_end|>", "sec": 0.09}, "157213": {"text": "<ref>elephant</ref><box><434><208><618><625></box><|im_end|>", "sec": 0.09}}, "gpu_causal_448": {"370818": {"text": "<ref>potted plant</ref><box>None</box><|im_end|>", "sec": 0.09}, "343453": {"text": "<ref>person</ref><box><395><122><681><998></box><|im_end|>", "sec": 0.09}, "119828": {"text": "<ref>cat</ref><box><224><398><880><998></box><|im_end|>", "sec": 0.12}, "47769": {"text": "<ref>chair</ref><box><625><726><775><998></box><|im_end|>", "sec": 0.09}, "438907": {"text": "<ref>person</ref><box><118><254><274><773></box><box><277><33><655><630></box><|im_end|>", "sec": 0.11}, "27972": {"text": "<ref>person</ref><box><567><206><783><574></box><|im_end|>", "sec": 0.09}, "64499": {"text": "<ref>zebra</ref><box><0><324><585><998></box><|im_end|>", "sec": 0.09}, "49810": {"text": "<ref>cat</ref><box><0><356><998><998></box><|im_end|>", "sec": 0.17}, "334530": {"text": "<ref>surfboard</ref><box><382><485><578><602></box><|im_end|>", "sec": 0.09}, "65350": {"text": "<ref>bicycle</ref><box><344><0><998><228></box><|im_end|>", "sec": 0.14}, "210030": {"text": "<ref>fork</ref><box><472><344><792><902></box><|im_end|>", "sec": 0.09}, "227985": {"text": "<ref>sandwich</ref><box><47><0><928><905></box><|im_end|>", "sec": 0.15}, "27932": {"text": "<ref>baseball glove</ref><box><77><317><770><924></box><|im_end|>", "sec": 0.09}, "185292": {"text": "<ref>person</ref><box><417><677><480><750></box><|im_end|>", "sec": 0.09}, "207728": {"text": "<ref>sheep</ref><box><142><590><650><998></box><box><212><148><740><755></box><|im_end|>", "sec": 0.11}, "165518": {"text": "<ref>motorcycle</ref><box><402><427><709><833></box><|im_end|>", "sec": 0.09}, "179285": {"text": "<ref>sports ball</ref><box><480><373><848><624></box><|im_end|>", "sec": 0.09}, "326541": {"text": "<ref>person</ref><box><0><5><441><998></box><box><265><410><507><1000></box><box><402><387><546><676></box><box><502><465><748><1000></box><box><633><342><706><491></box><box><685><2><1000><1000></box><|im_end|>", "sec": 0.45}, "312586": {"text": "<ref>bear</ref><box><281><562><686><894></box><|im_end|>", "sec": 0.09}, "512194": {"text": "<ref>vase</ref><box><488><618><834><998></box><|im_end|>", "sec": 0.09}, "344100": {"text": "<ref>sandwich</ref><box><610><446><790><701></box><|im_end|>", "sec": 0.09}, "527784": {"text": "<ref>sandwich</ref><box><0><387><480><618></box><box><508><410><1000><882></box><|im_end|>", "sec": 0.18}, "231879": {"text": "<ref>person</ref><box><83><323><519><1000></box><box><188><0><461><702></box><box><333><300><518><1000></box><box><448><0><778><1000></box><box><694><0><873><1000></box><|im_end|>", "sec": 0.2}, "348045": {"text": "<ref>toilet</ref><box><7><639><235><923></box><box><407><633><612><926></box><box><768><628><993><904></box><|im_end|>", "sec": 0.14}, "33104": {"text": "<ref>person</ref><box><0><0><120><902></box><box><47><66><480><932></box><box><372><96><811><958></box><box><678><48><998><868></box><box><845><0><998><592></box><|im_end|>", "sec": 0.17}, "263860": {"text": "<ref>elephant</ref><box><0><127><479><998></box><box><408><195><998><998></box><|im_end|>", "sec": 0.16}, "367818": {"text": "<ref>horse</ref><box><220><127><848><890></box><|im_end|>", "sec": 0.09}, "448365": {"text": "<ref>person</ref><box><233><77><580><794></box><box><695><499><748><602></box><|im_end|>", "sec": 0.19}, "163640": {"text": "<ref>person</ref><box><132><293><452><1000></box><box><472><354><598><677></box><box><698><298><948><1000></box><|im_end|>", "sec": 0.13}, "556158": {"text": "<ref>person</ref><box><327><224><593><674></box><|im_end|>", "sec": 0.09}, "80413": {"text": "<ref>teddy bear</ref><box><348><231><616><544></box><|im_end|>", "sec": 0.09}, "110359": {"text": "<ref>airplane</ref><box><342><345><658><888></box><|im_end|>", "sec": 0.09}, "99810": {"text": "<ref>donut</ref><box><400><801><477><889></box><box><663><829><753><966></box><box><725><896><822><998></box><box><750><784><848><904></box><box><810><852><901><988></box><|im_end|>", "sec": 0.2}, "147518": {"text": "<ref>toilet</ref><box><241><500><650><970></box><|im_end|>", "sec": 0.09}, "80659": {"text": "<ref>horse</ref><box><0><208><849><880></box><box><478><225><998><964></box><|im_end|>", "sec": 0.18}, "41635": {"text": "<ref>cow</ref><box><0><325><398><703></box><box><320><333><648><674></box><box><516><309><998><642></box><|im_end|>", "sec": 0.17}, "448448": {"text": "<ref>giraffe</ref><box><158><0><998><998></box><|im_end|>", "sec": 0.12}, "80273": {"text": "<ref>person</ref><box><267><105><595><980></box><|im_end|>", "sec": 0.09}, "166166": {"text": "<ref>chair</ref><box><0><324><258><998></box><|im_end|>", "sec": 0.12}, "24919": {"text": "<ref>elephant</ref><box><181><353><536><706></box><box><469><357><811><709></box><|im_end|>", "sec": 0.16}, "325347": {"text": "<ref>chair</ref><box><445><10><570><255></box><box><622><9><740><254></box><|im_end|>", "sec": 0.11}, "108026": {"text": "<ref>person</ref><box><174><0><998><998></box><|im_end|>", "sec": 0.09}, "14007": {"text": "<ref>cat</ref><box><536><369><654><698></box><|im_end|>", "sec": 0.17}, "328683": {"text": "<ref>parking meter</ref><box><345><51><608><362></box><|im_end|>", "sec": 0.1}, "427077": {"text": "<ref>person</ref><box><328><148><793><817></box><|im_end|>", "sec": 0.1}, "73702": {"text": "<ref>handbag</ref><box><538><362><998><902></box><|im_end|>", "sec": 0.1}, "357567": {"text": "<ref>toilet</ref><box><582><574><998><905></box><|im_end|>", "sec": 0.17}, "190756": {"text": "<ref>motorcycle</ref><box><183><94><767><882></box><|im_end|>", "sec": 0.1}, "311909": {"text": "<ref>bus</ref><box><0><94><979><905></box><|im_end|>", "sec": 0.1}, "19221": {"text": "<ref>person</ref><box><382><693><852><998></box><|im_end|>", "sec": 0.09}, "112626": {"text": "<ref>couch</ref><box><623><265><1000><732></box><|im_end|>", "sec": 0.09}, "187249": {"text": "<ref>person</ref><box><211><262><588><664></box><box><416><261><717><667></box><|im_end|>", "sec": 0.11}, "267434": {"text": "<ref>cow</ref><box><66><448><215><897></box><box><151><423><399><951></box><box><437><410><562><758></box><box><527><459><641><747></box><box><627><462><691><706></box><box><662><439><755><753></box><box><738><477><814><720></box><box><792><456><942><673></box><box><933><475><1000><689></box><|im_end|>", "sec": 0.24}, "422670": {"text": "<ref>person</ref><box><200><129><722><998></box><|im_end|>", "sec": 0.09}, "130566": {"text": "<ref>train</ref><box><28><272><906><740></box><|im_end|>", "sec": 0.09}, "365098": {"text": "<ref>boat</ref><box><67><228><999><912></box><|im_end|>", "sec": 0.17}, "253386": {"text": "<ref>person</ref><box><0><0><998><998></box><|im_end|>", "sec": 0.14}, "470779": {"text": "<ref>person</ref><box><83><199><276><848></box><box><211><143><490><865></box><box><405><114><625><793></box><box><511><86><708><849></box><box><648><62><843><858></box><|im_end|>", "sec": 0.17}, "335328": {"text": "<ref>person</ref><box><106><520><414><672></box><box><658><344><963><519></box><|im_end|>", "sec": 0.11}, "161397": {"text": "<ref>vase</ref><box><0><46><222><370></box><box><0><358><134><735></box><box><23><359><218><513></box><box><137><537><372><763></box><box><350><174><466><355></box><|im_end|>", "sec": 0.39}, "433980": {"text": "<ref>cell phone</ref><box><208><577><408><869></box><|im_end|>", "sec": 0.12}, "80057": {"text": "<ref>teddy bear</ref><box><0><15><892><655></box><|im_end|>", "sec": 0.09}, "336265": {"text": "<ref>person</ref><box><505><475><570><573></box><|im_end|>", "sec": 0.09}, "133567": {"text": "<ref>train</ref><box><0><200><897><694></box><|im_end|>", "sec": 0.09}, "231549": {"text": "<ref>bed</ref><box><175><730><807><999></box><|im_end|>", "sec": 0.17}, "502336": {"text": "<ref>person</ref><box><214><689><282><912></box><box><265><671><314><910></box><box><299><670><362><920></box><box><475><642><607><968></box><box><947><608><998><888></box><|im_end|>", "sec": 0.17}, "468632": {"text": "<ref>person</ref><box><111><411><298><859></box><box><115><381><225><819></box><box><455><301><653><856></box><box><745><385><908><883></box><|im_end|>", "sec": 0.15}, "156292": {"text": "<ref>clock</ref><box><317><374><637><585></box><|im_end|>", "sec": 0.09}, "115885": {"text": "<ref>cat</ref><box><694><0><998><661></box><|im_end|>", "sec": 0.12}, "581615": {"text": "<ref>toilet</ref><box><302><600><681><1000></box><|im_end|>", "sec": 0.09}, "556873": {"text": "<ref>cake</ref><box><239><523><575><777></box><|im_end|>", "sec": 0.09}, "575372": {"text": "<ref>traffic light</ref><box><191><793><242><918></box><box><416><347><474><547></box><box><634><153><705><397></box><box><927><791><998><930></box><|im_end|>", "sec": 0.18}, "394328": {"text": "<ref>toilet</ref><box><325><580><740><998></box><|im_end|>", "sec": 0.09}, "360943": {"text": "<ref>cat</ref><box><396><374><551><440></box><|im_end|>", "sec": 0.09}, "287545": {"text": "<ref>giraffe</ref><box><94><228><640><742></box><box><362><513><484><722></box><|im_end|>", "sec": 0.11}, "194506": {"text": "<ref>bear</ref><box><120><234><473><545></box><box><438><289><650><533></box><|im_end|>", "sec": 0.11}, "107087": {"text": "<ref>cat</ref><box><42><178><414><998></box><|im_end|>", "sec": 0.17}, "263474": {"text": "<ref>toilet</ref><box><38><315><798><974></box><|im_end|>", "sec": 0.09}, "407518": {"text": "<ref>bird</ref><box><580><209><868><887></box><|im_end|>", "sec": 0.09}, "31620": {"text": "<ref>person</ref><box><0><391><179><607></box><box><386><349><797><679></box><box><865><544><998><998></box><|im_end|>", "sec": 0.13}, "398237": {"text": "<ref>kite</ref><box><142><506><774><773></box><box><151><75><446><393></box><box><471><105><622><275></box><box><753><71><839><199></box><|im_end|>", "sec": 0.33}, "509403": {"text": "<ref>person</ref><box><567><135><750><870></box><|im_end|>", "sec": 0.14}, "292456": {"text": "<ref>person</ref><box><258><84><382><725></box><box><368><121><824><930></box><box><618><176><886><900></box><|im_end|>", "sec": 0.13}, "359833": {"text": "<ref>apple</ref><box><0><67><713><331></box><box><0><309><54><456></box><box><0><673><189><835></box><box><2><819><34><881></box><box><5><309><143><413></box><box><7><444><122><552></box><box><23><596><179><698></box><box><50><289><158><355></box><box><100><793><311><951></box><box><103><404><194><461></box><box><113><188><219><255></box><box><125><453><294><556></box><box><132><245><227><302></box><box><137><273><257><346></box><box><150><336><267><422></box><box><193><646><319><763></box><box><253><299><395><380></box><box><272><375><372><526></box><box><275><468><373><553></box><box><333><268><445><328></box><box><343><451><477><547></box><box><387><366><498><460></box><box><420><297><541><382></box><box><463><423><585><502></box><box><485><350><600><448></box><|im_end|>", "sec": 1.0}, "261982": {"text": "<ref>car</ref><box><0><15><551><356></box><|im_end|>", "sec": 0.14}, "429761": {"text": "<ref>person</ref><box><297><190><485><906></box><box><449><142><636><836></box><|im_end|>", "sec": 0.11}, "482719": {"text": "<ref>chair</ref><box><186><0><763><291></box><|im_end|>", "sec": 0.15}, "506178": {"text": "<ref>person</ref><box><178><184><869><1000></box><|im_end|>", "sec": 0.14}, "131131": {"text": "<ref>tv</ref><box><88><186><876><863></box><|im_end|>", "sec": 0.09}, "68286": {"text": "<ref>bed</ref><box><35><146><858><998></box><|im_end|>", "sec": 0.1}, "67896": {"text": "<ref>clock</ref><box><256><104><763><742></box><|im_end|>", "sec": 0.15}, "297830": {"text": "<ref>dog</ref><box><317><62><918><946></box><|im_end|>", "sec": 0.09}, "398810": {"text": "<ref>cat</ref><box><210><259><393><433></box><box><449><307><998><866></box><|im_end|>", "sec": 0.16}, "569565": {"text": "<ref>truck</ref><box><209><431><706><745></box><|im_end|>", "sec": 0.09}, "161879": {"text": "<ref>person</ref><box><94><0><366><605></box><|im_end|>", "sec": 0.09}, "333069": {"text": "<ref>giraffe</ref><box><220><307><630><908></box><box><539><305><922><642></box><|im_end|>", "sec": 0.19}, "544306": {"text": "<ref>clock</ref><box><534><663><630><806></box><box><714><667><817><810></box><|im_end|>", "sec": 0.11}, "455555": {"text": "<ref>person</ref><box><188><184><717><860></box><box><722><85><977><439></box><|im_end|>", "sec": 0.11}, "377575": {"text": "<ref>dog</ref><box><141><269><642><944></box><|im_end|>", "sec": 0.09}, "157213": {"text": "<ref>elephant</ref><box><434><208><618><625></box><|im_end|>", "sec": 0.09}}, "gpu_bidir_native": {"370818": {"text": "<ref>potted plant</ref><box>None</box><|im_end|>", "sec": 0.13}, "343453": {"text": "<ref>person</ref><box><395><123><680><998></box><|im_end|>", "sec": 0.12}, "119828": {"text": "<ref>cat</ref><box><224><397><880><997></box><|im_end|>", "sec": 0.09}, "47769": {"text": "<ref>chair</ref><box><628><728><776><1000></box><|im_end|>", "sec": 0.09}, "438907": {"text": "<ref>person</ref><box><114><255><277><773></box><box><279><34><656><627></box><|im_end|>", "sec": 0.2}, "27972": {"text": "<ref>person</ref><box><567><207><758><561></box><|im_end|>", "sec": 0.12}, "64499": {"text": "<ref>zebra</ref><box><0><317><586><998></box><box><169><362><588><927></box><|im_end|>", "sec": 0.14}, "49810": {"text": "<ref>cat</ref><box><202><350><998><1000></box><|im_end|>", "sec": 0.12}, "334530": {"text": "<ref>surfboard</ref><box><367><488><581><602></box><|im_end|>", "sec": 0.12}, "65350": {"text": "<ref>bicycle</ref><box><347><0><998><218></box><|im_end|>", "sec": 0.16}, "210030": {"text": "<ref>fork</ref><box><472><340><792><902></box><|im_end|>", "sec": 0.1}, "227985": {"text": "<ref>sandwich</ref><box><50><2><928><898></box><|im_end|>", "sec": 0.18}, "27932": {"text": "<ref>baseball glove</ref><box><88><90><873><923></box><|im_end|>", "sec": 0.07}, "185292": {"text": "<ref>person</ref><box><415><677><478><753></box><|im_end|>", "sec": 0.12}, "207728": {"text": "<ref>sheep</ref><box><144><502><652><997></box><box><212><150><742><757></box><|im_end|>", "sec": 0.12}, "165518": {"text": "<ref>motorcycle</ref><box><402><425><709><835></box><|im_end|>", "sec": 0.15}, "179285": {"text": "<ref>sports ball</ref><box><480><373><848><623></box><|im_end|>", "sec": 0.12}, "326541": {"text": "<ref>person</ref><box><0><11><406><997></box><box><275><411><748><997></box><box><466><392><541><678></box><box><509><472><666><886></box><box><669><347><698><422></box><box><684><83><998><997></box><|im_end|>", "sec": 0.45}, "312586": {"text": "<ref>bear</ref><box><283><560><684><892></box><|im_end|>", "sec": 0.12}, "512194": {"text": "<ref>vase</ref><box><488><616><836><998></box><|im_end|>", "sec": 0.12}, "344100": {"text": "<ref>sandwich</ref><box><609><445><791><700></box><|im_end|>", "sec": 0.12}, "527784": {"text": "<ref>sandwich</ref><box><512><420><1000><880></box><|im_end|>", "sec": 0.2}, "231879": {"text": "<ref>person</ref><box><88><326><483><998></box><box><191><0><458><700></box><box><331><304><516><998></box><box><452><0><809><998></box><box><697><0><872><859></box><|im_end|>", "sec": 0.25}, "348045": {"text": "<ref>toilet</ref><box><9><639><236><928></box><box><406><634><610><927></box><box><768><628><992><906></box><|im_end|>", "sec": 0.18}, "33104": {"text": "<ref>person</ref><box><0><20><118><898></box><box><50><66><493><932></box><box><370><96><812><960></box><box><680><46><998><876></box><box><845><0><998><608></box><|im_end|>", "sec": 0.17}, "263860": {"text": "<ref>elephant</ref><box><0><124><472><998></box><box><405><194><998><998></box><|im_end|>", "sec": 0.18}, "367818": {"text": "<ref>horse</ref><box><222><126><848><890></box><|im_end|>", "sec": 0.12}, "448365": {"text": "<ref>person</ref><box><234><77><580><794></box><|im_end|>", "sec": 0.12}, "163640": {"text": "<ref>person</ref><box><134><294><452><998></box><box><475><354><598><682></box><box><698><298><950><1000></box><|im_end|>", "sec": 0.16}, "556158": {"text": "<ref>person</ref><box><325><225><594><677></box><|im_end|>", "sec": 0.12}, "80413": {"text": "<ref>teddy bear</ref><box><350><231><616><546></box><|im_end|>", "sec": 0.12}, "110359": {"text": "<ref>airplane</ref><box><342><342><658><888></box><|im_end|>", "sec": 0.12}, "99810": {"text": "<ref>donut</ref><box><396><817><474><895></box><box><662><829><752><964></box><box><728><898><822><997></box><box><750><787><846><907></box><box><808><853><900><985></box><|im_end|>", "sec": 0.3}, "147518": {"text": "<ref>toilet</ref><box><240><502><650><972></box><|im_end|>", "sec": 0.12}, "80659": {"text": "<ref>horse</ref><box><67><208><567><880></box><|im_end|>", "sec": 0.19}, "41635": {"text": "<ref>cow</ref><box><0><329><395><725></box><box><320><327><648><679></box><box><519><308><998><654></box><|im_end|>", "sec": 0.16}, "448448": {"text": "<ref>giraffe</ref><box><161><0><998><581></box><box><216><65><998><998></box><|im_end|>", "sec": 0.2}, "80273": {"text": "<ref>person</ref><box><266><106><594><979></box><|im_end|>", "sec": 0.12}, "166166": {"text": "<ref>chair</ref><box><0><325><248><997></box><|im_end|>", "sec": 0.12}, "24919": {"text": "<ref>elephant</ref><box><178><351><530><705></box><box><431><356><812><707></box><|im_end|>", "sec": 0.18}, "325347": {"text": "<ref>chair</ref><box><452><11><569><261></box><box><623><6><739><256></box><|im_end|>", "sec": 0.12}, "108026": {"text": "<ref>person</ref><box><175><0><998><998></box><|im_end|>", "sec": 0.12}, "14007": {"text": "<ref>cat</ref><box><0><70><480><998></box><|im_end|>", "sec": 0.19}, "328683": {"text": "<ref>parking meter</ref><box><344><50><608><934></box><|im_end|>", "sec": 0.15}, "427077": {"text": "<ref>person</ref><box><331><148><794><816></box><|im_end|>", "sec": 0.09}, "73702": {"text": "<ref>handbag</ref><box><625><531><998><898></box><|im_end|>", "sec": 0.12}, "357567": {"text": "<ref>toilet</ref><box><581><577><998><969></box><|im_end|>", "sec": 0.12}, "190756": {"text": "<ref>motorcycle</ref><box><184><256><769><883></box><|im_end|>", "sec": 0.12}, "311909": {"text": "<ref>bus</ref><box><0><94><988><906></box><|im_end|>", "sec": 0.12}, "19221": {"text": "<ref>person</ref><box><377><694><852><998></box><|im_end|>", "sec": 0.12}, "112626": {"text": "<ref>couch</ref><box><624><266><998><730></box><|im_end|>", "sec": 0.12}, "187249": {"text": "<ref>person</ref><box><211><262><589><662></box><box><400><260><716><665></box><|im_end|>", "sec": 0.14}, "267434": {"text": "<ref>cow</ref><box><59><446><214><894></box><box><152><427><398><952></box><box><436><412><559><758></box><box><527><460><638><744></box><box><627><448><716><706></box><box><661><429><770><752></box><box><741><473><816><719></box><box><792><456><998><694></box><|im_end|>", "sec": 0.3}, "422670": {"text": "<ref>person</ref><box><200><129><722><998></box><box><405><267><967><998></box><|im_end|>", "sec": 0.21}, "130566": {"text": "<ref>train</ref><box><28><272><905><738></box><|im_end|>", "sec": 0.12}, "365098": {"text": "<ref>boat</ref><box><70><230><1000><911></box><|im_end|>", "sec": 0.12}, "253386": {"text": "<ref>person</ref><box><0><0><166><997></box><box><614><0><730><186></box><box><830><0><998><997></box><|im_end|>", "sec": 0.22}, "470779": {"text": "<ref>person</ref><box><84><200><275><848></box><box><155><144><475><867></box><box><406><115><625><798></box><box><545><90><703><873></box><box><650><62><844><846></box><|im_end|>", "sec": 0.2}, "335328": {"text": "<ref>person</ref><box><109><520><416><669></box><box><658><344><963><519></box><|im_end|>", "sec": 0.15}, "161397": {"text": "<ref>vase</ref><box><134><580><372><762></box><|im_end|>", "sec": 0.2}, "433980": {"text": "<ref>cell phone</ref><box><208><578><408><852></box><|im_end|>", "sec": 0.12}, "80057": {"text": "<ref>teddy bear</ref><box><0><12><892><652></box><|im_end|>", "sec": 0.12}, "336265": {"text": "<ref>person</ref><box><504><473><569><575></box><|im_end|>", "sec": 0.12}, "133567": {"text": "<ref>train</ref><box><0><198><903><686></box><|im_end|>", "sec": 0.28}, "231549": {"text": "<ref>bed</ref><box><173><731><808><998></box><|im_end|>", "sec": 0.15}, "502336": {"text": "<ref>person</ref><box><181><564><227><693></box><box><216><694><289><911></box><box><223><581><252><691></box><box><264><671><261><911></box><box><267><669><311><911></box><box><302><671><359><911></box><box><478><643><606><969></box><box><948><607><998><887></box><|im_end|>", "sec": 0.42}, "468632": {"text": "<ref>person</ref><box><108><429><300><856></box><box><114><379><280><827></box><box><456><302><653><854></box><box><745><385><908><881></box><|im_end|>", "sec": 0.19}, "156292": {"text": "<ref>clock</ref><box><315><375><637><586></box><|im_end|>", "sec": 0.12}, "115885": {"text": "<ref>cat</ref><box><694><0><998><664></box><|im_end|>", "sec": 0.1}, "581615": {"text": "<ref>toilet</ref><box><299><600><682><998></box><|im_end|>", "sec": 0.13}, "556873": {"text": "<ref>cake</ref><box><239><523><593><816></box><|im_end|>", "sec": 0.12}, "575372": {"text": "<ref>traffic light</ref><box><191><794><238><923></box><box><417><348><472><546></box><box><636><154><705><396></box><box><948><796><998><933></box><|im_end|>", "sec": 0.19}, "394328": {"text": "<ref>toilet</ref><box><327><581><742><998></box><|im_end|>", "sec": 0.13}, "360943": {"text": "<ref>cat</ref><box><394><375><552><439></box><|im_end|>", "sec": 0.13}, "287545": {"text": "<ref>giraffe</ref><box><94><227><641><740></box><box><364><512><483><723></box><|im_end|>", "sec": 0.15}, "194506": {"text": "<ref>bear</ref><box><120><233><470><538></box><box><439><288><647><535></box><|im_end|>", "sec": 0.15}, "107087": {"text": "<ref>cat</ref><box><67><178><405><998></box><|im_end|>", "sec": 0.21}, "263474": {"text": "<ref>toilet</ref><box><38><316><800><977></box><|im_end|>", "sec": 0.13}, "407518": {"text": "<ref>bird</ref><box><583><208><867><888></box><|im_end|>", "sec": 0.12}, "31620": {"text": "<ref>person</ref><box><0><391><175><603></box><box><385><350><562><516></box><box><390><372><796><678></box><|im_end|>", "sec": 0.28}, "398237": {"text": "<ref>kite</ref><box><141><502><398><698></box><box><152><75><389><217></box><box><470><102><619><279></box><box><755><71><841><202></box><|im_end|>", "sec": 0.36}, "509403": {"text": "<ref>person</ref><box><564><138><750><873></box><|im_end|>", "sec": 0.21}, "292456": {"text": "<ref>person</ref><box><260><85><382><725></box><box><356><120><824><931></box><box><628><176><886><901></box><|im_end|>", "sec": 0.14}, "359833": {"text": "<ref>apple</ref><box><0><150><44><209></box><box><0><355><42><464></box><box><0><561><35><661></box><box><0><678><183><836></box><box><0><820><33><889></box><box><0><903><144><998></box><box><2><106><60><153></box><box><4><308><148><405></box><box><6><444><140><559></box><box><15><212><131><284></box><box><23><75><96><112></box><box><27><603><179><695></box><box><38><184><110><225></box><box><46><288><160><347></box><box><56><133><133><180></box><box><62><73><125><109></box><box><92><97><152><134></box><box><100><797><298><953></box><box><108><69><231><105></box><box><117><403><229><469></box><box><119><191><217><250></box><box><123><245><208><297></box><box><123><453><279><566></box><box><129><72><190><116></box><box><135><275><235><345></box><box><138><158><233><228></box><box><146><336><271><427></box><box><154><120><202><103></box><box><156><94><210><122></box><box><175><650><319><770></box><box><177><66><246><102></box><box><196><80><265><111></box><box><204><189><310><244></box><box><206><230><300><127></box><box><215><280><294><322></box><box><223><100><296><141></box><box><227><3><267><22></box><box><242><17><302><98></box><box><248><155><325><211></box><box><254><303><390><389></box><box><262><88><331><128></box><box><269><467><352><525></box><box><273><377><410><477></box><box><277><9><329><50></box><box><281><114><348><161></box><box><292><517><360><575></box><box><294><184><362><236></box><box><298><34><350><78></box><box><304><247><371><295></box><box><315><206><417><258></box><box><321><67><379><105></box><box><327><269><440><330></box><box><333><136><396><181></box><box><338><455><481><544></box><box><342><86><406><130></box><box><346><41><398><77></box><box><354><159><435><216></box><box><365><314><446><366></box><box><369><0><425><28></box><box><375><70><438><147></box><box><385><367><498><459></box><box><388><36><456><166></box><box><404><222><471><256></box><box><408><259><483><305></box><box><419><297><546><380></box><box><423><0><473><39></box><box><429><203><500>", "sec": 3.67}, "261982": {"text": "<ref>car</ref><box><0><16><551><344></box><|im_end|>", "sec": 0.12}, "429761": {"text": "<ref>person</ref><box><297><190><484><904></box><box><455><141><634><835></box><|im_end|>", "sec": 0.14}, "482719": {"text": "<ref>chair</ref><box><372><0><762><300></box><|im_end|>", "sec": 0.21}, "506178": {"text": "<ref>person</ref><box><176><184><803><998></box><|im_end|>", "sec": 0.1}, "131131": {"text": "<ref>tv</ref><box><88><187><876><863></box><|im_end|>", "sec": 0.13}, "68286": {"text": "<ref>bed</ref><box><38><146><858><997></box><|im_end|>", "sec": 0.11}, "67896": {"text": "<ref>clock</ref><box><258><104><756><790></box><|im_end|>", "sec": 0.13}, "297830": {"text": "<ref>dog</ref><box><318><88><919><948></box><|im_end|>", "sec": 0.13}, "398810": {"text": "<ref>cat</ref><box><444><302><998><866></box><|im_end|>", "sec": 0.2}, "569565": {"text": "<ref>truck</ref><box><181><433><706><745></box><|im_end|>", "sec": 0.12}, "161879": {"text": "<ref>person</ref><box><84><0><364><605></box><|im_end|>", "sec": 0.14}, "333069": {"text": "<ref>giraffe</ref><box><222><306><631><908></box><|im_end|>", "sec": 0.12}, "544306": {"text": "<ref>clock</ref><box><534><668><634><806></box><box><716><670><820><807></box><|im_end|>", "sec": 0.16}, "455555": {"text": "<ref>person</ref><box><191><182><716><858></box><box><723><86><978><438></box><|im_end|>", "sec": 0.16}, "377575": {"text": "<ref>dog</ref><box><141><270><642><947></box><|im_end|>", "sec": 0.12}, "157213": {"text": "<ref>elephant</ref><box><436><208><617><619></box><|im_end|>", "sec": 0.1}}}
|
rk3588/locate3b.py
ADDED
|
@@ -0,0 +1,301 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Portions of the decoding logic below (is_valid_box_frame, decode_bbox_avg, decode_ref, handle_pattern, the
|
| 2 |
+
# sampling and hybrid MTP/AR control flow) are ported from NVIDIA's LocateAnything-3B `generate_utils.py` and
|
| 3 |
+
# `modeling_locateanything.py`, Copyright (c) 2026, NVIDIA CORPORATION. Distributed under the NVIDIA License
|
| 4 |
+
# (see ../LICENSE): non-commercial research and evaluation use only. This file has been modified (ported to
|
| 5 |
+
# numpy + RKLLM/RKNN Lite).
|
| 6 |
+
"""LocateAnything-3B on Rock 5C: RKNN vision + RKLLM text with Parallel Box Decoding (PBD).
|
| 7 |
+
|
| 8 |
+
The RKLLM runtime cannot take a custom attention mask, so the 6-token PBD window is run with a *causal* mask (an
|
| 9 |
+
approximation of the bidirectional window the model was trained with). Window = accepted tokens + 5 <text_mask>;
|
| 10 |
+
the runtime reuses the KV of the common prefix between calls, so no explicit rollback is needed.
|
| 11 |
+
|
| 12 |
+
python locate3b.py IMAGE "Locate all the instances that matches the following description: person."
|
| 13 |
+
"""
|
| 14 |
+
import argparse
|
| 15 |
+
import ctypes
|
| 16 |
+
import os
|
| 17 |
+
import re
|
| 18 |
+
import sys
|
| 19 |
+
import time
|
| 20 |
+
|
| 21 |
+
import numpy as np
|
| 22 |
+
from PIL import Image
|
| 23 |
+
from rknnlite.api import RKNNLite
|
| 24 |
+
from tokenizers import Tokenizer
|
| 25 |
+
|
| 26 |
+
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
|
| 27 |
+
import rkllm_binding as rb # noqa: E402
|
| 28 |
+
|
| 29 |
+
BOX_START, BOX_END = 151668, 151669
|
| 30 |
+
REF_START, REF_END = 151672, 151673
|
| 31 |
+
COORD_START, COORD_END = 151677, 152677
|
| 32 |
+
NONE_ID, NULL_ID, IM_END_ID, MASK_ID = 4064, 152678, 151645, 151676
|
| 33 |
+
IMG_CONTEXT, IMG_START, IMG_END = 151665, 151666, 151667
|
| 34 |
+
N_FUT = 6
|
| 35 |
+
SIZE = 448
|
| 36 |
+
BASE = os.environ.get("LA3B_DIR", os.path.join(os.path.dirname(os.path.abspath(__file__)), "..")) + "/"
|
| 37 |
+
HEAD = ("<|im_start|>system\nYou are a helpful assistant.\n<|im_end|>\n<|im_start|>user\n<image 1><image>"
|
| 38 |
+
"{q}<|im_end|>\n<|im_start|>assistant\n")
|
| 39 |
+
|
| 40 |
+
|
| 41 |
+
class _LLM(rb.RKLLM):
|
| 42 |
+
last = None
|
| 43 |
+
|
| 44 |
+
def _callback(self, result, userdata, state):
|
| 45 |
+
r = result.contents
|
| 46 |
+
if state == rb.RUN_NORMAL and r.logits and r.lg_num_tokens > 0:
|
| 47 |
+
n, v = r.lg_num_tokens, r.vocab_size
|
| 48 |
+
_LLM.last = np.ctypeslib.as_array(ctypes.cast(r.logits, ctypes.POINTER(ctypes.c_float)), shape=(n, v)).copy()
|
| 49 |
+
elif state == rb.RUN_ERROR:
|
| 50 |
+
self._error = True
|
| 51 |
+
return 0
|
| 52 |
+
|
| 53 |
+
|
| 54 |
+
def softmax(x):
|
| 55 |
+
x = x - x.max(axis=-1, keepdims=True)
|
| 56 |
+
e = np.exp(x)
|
| 57 |
+
return e / e.sum(axis=-1, keepdims=True)
|
| 58 |
+
|
| 59 |
+
|
| 60 |
+
def sample_rows(lg, temperature, top_p, rng, cand=256):
|
| 61 |
+
"""Port of generate_utils.sample_tokens: temperature, top-p (on the full-vocab softmax), then sample per row.
|
| 62 |
+
Returns dense probs [rows, V] (zero outside the nucleus) and the sampled ids."""
|
| 63 |
+
if temperature <= 0:
|
| 64 |
+
probs = softmax(lg)
|
| 65 |
+
return probs, probs.argmax(axis=-1).tolist()
|
| 66 |
+
lg = lg / temperature
|
| 67 |
+
m = lg.max(axis=-1, keepdims=True)
|
| 68 |
+
logz = m[:, 0] + np.log(np.exp(lg - m).sum(axis=-1))
|
| 69 |
+
probs = np.zeros_like(lg)
|
| 70 |
+
ids = []
|
| 71 |
+
for r in range(lg.shape[0]):
|
| 72 |
+
row = lg[r]
|
| 73 |
+
top = np.argpartition(-row, cand)[:cand]
|
| 74 |
+
top = top[np.argsort(-row[top])]
|
| 75 |
+
pr = np.exp(row[top] - logz[r])
|
| 76 |
+
cum = np.cumsum(pr)
|
| 77 |
+
if top_p is not None and top_p < 1:
|
| 78 |
+
if cum[-1] < top_p: # nucleus wider than the candidate list: fall back to a full sort
|
| 79 |
+
top = np.argsort(-row)
|
| 80 |
+
pr = np.exp(row[top] - logz[r])
|
| 81 |
+
cum = np.cumsum(pr)
|
| 82 |
+
drop = cum > top_p
|
| 83 |
+
drop[1:] = drop[:-1].copy()
|
| 84 |
+
drop[0] = False
|
| 85 |
+
top, pr = top[~drop], pr[~drop]
|
| 86 |
+
pr = pr / pr.sum()
|
| 87 |
+
probs[r, top] = pr
|
| 88 |
+
ids.append(int(rng.choice(top, p=pr)))
|
| 89 |
+
return probs, ids
|
| 90 |
+
|
| 91 |
+
|
| 92 |
+
def topk(p, k):
|
| 93 |
+
idx = np.argsort(-p, axis=-1)[..., :k]
|
| 94 |
+
return np.take_along_axis(p, idx, axis=-1), idx
|
| 95 |
+
|
| 96 |
+
|
| 97 |
+
# ---- port of generate_utils.py (greedy, generation_mode="hybrid") ----------------------------------------------
|
| 98 |
+
def is_valid_box_frame(probs, start_thresh=0.7, end_thresh=0.2):
|
| 99 |
+
if probs[0, BOX_START] >= start_thresh:
|
| 100 |
+
if probs[1, NONE_ID] > 0.2 and probs[2, BOX_END] > 0.2 and probs[3, NULL_ID] > 0.1 and probs[4, NULL_ID] > 0.1:
|
| 101 |
+
return "empty_box"
|
| 102 |
+
if probs[5, [BOX_END, NULL_ID, IM_END_ID]].sum() >= end_thresh:
|
| 103 |
+
return "legal_box"
|
| 104 |
+
return "illegal_box"
|
| 105 |
+
|
| 106 |
+
|
| 107 |
+
def decode_bbox_avg(probs, keep_k=4):
|
| 108 |
+
kind = is_valid_box_frame(probs)
|
| 109 |
+
if kind == "empty_box":
|
| 110 |
+
return [BOX_START, NONE_ID, BOX_END, NULL_ID, NULL_ID, NULL_ID]
|
| 111 |
+
if kind == "illegal_box":
|
| 112 |
+
return None
|
| 113 |
+
pos_p, pos_i = topk(probs[1:5], keep_k)
|
| 114 |
+
mask = (pos_i >= COORD_START) & (pos_i <= COORD_END)
|
| 115 |
+
if not mask.any(axis=-1).all():
|
| 116 |
+
return None
|
| 117 |
+
first = mask.argmax(axis=-1)[:, None]
|
| 118 |
+
fp = np.take_along_axis(pos_p, first, axis=-1)[:, 0]
|
| 119 |
+
fi = np.take_along_axis(pos_i, first, axis=-1)[:, 0]
|
| 120 |
+
counts = mask.sum(axis=-1)
|
| 121 |
+
vmax = np.where(mask, pos_i, -999999).max(axis=-1)
|
| 122 |
+
vmin = np.where(mask, pos_i, 999999).min(axis=-1)
|
| 123 |
+
abnormal = (fp < 0.9) & (counts > 1) & ((vmax - vmin) > 60)
|
| 124 |
+
final = np.where(abnormal, 0, fi)
|
| 125 |
+
return [BOX_START] + final.tolist() + [BOX_END]
|
| 126 |
+
|
| 127 |
+
|
| 128 |
+
def decode_ref(probs, keep_k=5, start_thresh=0.6):
|
| 129 |
+
if probs[0, REF_START] < start_thresh:
|
| 130 |
+
return None
|
| 131 |
+
_, pos_i = topk(probs[1:], keep_k)
|
| 132 |
+
valid = ~((pos_i >= COORD_START) & (pos_i <= COORD_END))
|
| 133 |
+
if not valid.any(axis=-1).all():
|
| 134 |
+
return None
|
| 135 |
+
first = valid.argmax(axis=-1)[:, None]
|
| 136 |
+
return [REF_START] + np.take_along_axis(pos_i, first, axis=-1)[:, 0].tolist()
|
| 137 |
+
|
| 138 |
+
|
| 139 |
+
def handle_pattern(x0):
|
| 140 |
+
if x0[0] in (NULL_ID, IM_END_ID):
|
| 141 |
+
return "im_end", [IM_END_ID]
|
| 142 |
+
if x0[:2] == [BOX_START, NONE_ID]:
|
| 143 |
+
return "empty_box", [BOX_START, NONE_ID, BOX_END]
|
| 144 |
+
if x0[0] == BOX_START:
|
| 145 |
+
ix = 1
|
| 146 |
+
for c in x0[1:5]:
|
| 147 |
+
if COORD_START <= c <= COORD_END:
|
| 148 |
+
ix += 1
|
| 149 |
+
else:
|
| 150 |
+
break
|
| 151 |
+
if ix == 5 and x0[5] == BOX_END:
|
| 152 |
+
return "coord_box", x0
|
| 153 |
+
if ix == 3 and x0[3] == BOX_END:
|
| 154 |
+
return "point_box", x0[:4]
|
| 155 |
+
return "error_box", x0[:ix]
|
| 156 |
+
for i, t in enumerate(x0):
|
| 157 |
+
if t == NULL_ID:
|
| 158 |
+
x0 = x0[:i]
|
| 159 |
+
break
|
| 160 |
+
if len(x0) >= 2 and x0[-1] == x0[-2] == REF_END:
|
| 161 |
+
x0 = x0[:-1]
|
| 162 |
+
return "ref_object", x0
|
| 163 |
+
|
| 164 |
+
|
| 165 |
+
def iou(a, b):
|
| 166 |
+
ix = max(0, min(a[2], b[2]) - max(a[0], b[0]))
|
| 167 |
+
iy = max(0, min(a[3], b[3]) - max(a[1], b[1]))
|
| 168 |
+
inter = ix * iy
|
| 169 |
+
u = (a[2] - a[0]) * (a[3] - a[1]) + (b[2] - b[0]) * (b[3] - b[1]) - inter
|
| 170 |
+
return inter / u if u > 0 else 0.0
|
| 171 |
+
|
| 172 |
+
|
| 173 |
+
class Locator:
|
| 174 |
+
def __init__(self, llm=BASE + "LocateAnything-3B_LLM_RK3588_w8a8.rkllm", vit=BASE + "LocateAnything-3B_vision_RK3588.rknn",
|
| 175 |
+
tokenizer=BASE + "tokenizer.json"):
|
| 176 |
+
self.tok = Tokenizer.from_file(tokenizer)
|
| 177 |
+
self.rknn = RKNNLite(verbose=False)
|
| 178 |
+
assert self.rknn.load_rknn(vit) == 0, "load vision rknn failed"
|
| 179 |
+
assert self.rknn.init_runtime(core_mask=RKNNLite.NPU_CORE_0_1_2) == 0, "init vision runtime failed"
|
| 180 |
+
self.llm = _LLM("/usr/lib/librkllmrt.so", "1.3.0", llm, max_context_len=4096)
|
| 181 |
+
self.lib = self.llm.lib
|
| 182 |
+
self.steps = self.run_ms = 0
|
| 183 |
+
|
| 184 |
+
def encode_image(self, img):
|
| 185 |
+
img = img.convert("RGB").resize((SIZE, SIZE), Image.BICUBIC)
|
| 186 |
+
arr = np.asarray(img, dtype=np.uint8)[np.newaxis]
|
| 187 |
+
out = self.rknn.inference(inputs=[arr], data_format="nhwc")[0]
|
| 188 |
+
return np.ascontiguousarray(out.reshape(-1, out.shape[-1]), dtype=np.float32)
|
| 189 |
+
|
| 190 |
+
def _logits(self, prompt, emb):
|
| 191 |
+
_LLM.last = None
|
| 192 |
+
self.llm._error = False
|
| 193 |
+
inp = rb.Input130()
|
| 194 |
+
inp.role, inp.enable_thinking, inp.input_type = b"user", False, rb.INPUT_MULTIMODAL
|
| 195 |
+
mm = inp.multimodal_input
|
| 196 |
+
mm.prompt = prompt.encode()
|
| 197 |
+
img = mm.image
|
| 198 |
+
img.image_embed = emb.ctypes.data_as(ctypes.POINTER(ctypes.c_float))
|
| 199 |
+
img.n_image_tokens, img.n_image = emb.shape[0], 1
|
| 200 |
+
img.image_width, img.image_height = SIZE, SIZE
|
| 201 |
+
img.image_start, img.image_end, img.image_content = b"<img>", b"</img>", b"<IMG_CONTEXT>"
|
| 202 |
+
ip = rb.InferParam130(mode=2, keep_history=0, max_new_tokens=1)
|
| 203 |
+
t = time.time()
|
| 204 |
+
rc = self.lib.rkllm_run(self.llm.handle, ctypes.byref(inp), ctypes.byref(ip), None)
|
| 205 |
+
self.run_ms += (time.time() - t) * 1000
|
| 206 |
+
self.steps += 1
|
| 207 |
+
if rc != 0 or self.llm._error or _LLM.last is None:
|
| 208 |
+
raise RuntimeError(f"rkllm_run failed rc={rc}")
|
| 209 |
+
return _LLM.last
|
| 210 |
+
|
| 211 |
+
def locate(self, img, question, max_new=300, rep_penalty=1.1, max_boxes=100, dedupe_iou=0.85, verbose=False,
|
| 212 |
+
temperature=0.7, top_p=0.9, seed=0):
|
| 213 |
+
emb = self.encode_image(img)
|
| 214 |
+
rng = np.random.default_rng(seed)
|
| 215 |
+
head = HEAD.format(q=question)
|
| 216 |
+
seen = set(self.tok.encode(head.replace("<image>", ""), add_special_tokens=False).ids) | {IMG_CONTEXT, IMG_START, IMG_END}
|
| 217 |
+
gen, boxes, use_mtp, t0 = [], [], True, time.time()
|
| 218 |
+
self.steps = 0
|
| 219 |
+
self.run_ms = 0
|
| 220 |
+
n_ar = 0
|
| 221 |
+
while len(gen) < max_new:
|
| 222 |
+
text = self.tok.decode(gen, skip_special_tokens=False)
|
| 223 |
+
need = N_FUT if use_mtp else 1
|
| 224 |
+
lg = self._logits(head + text + ("<text_mask>" * (N_FUT - 1) if use_mtp else ""), emb)
|
| 225 |
+
if len(lg) < need:
|
| 226 |
+
raise RuntimeError(f"only {len(lg)} logits rows, need {need}")
|
| 227 |
+
lg = lg[-need:].copy()
|
| 228 |
+
if rep_penalty != 1.0:
|
| 229 |
+
idx = np.fromiter(seen, dtype=np.int64)
|
| 230 |
+
v = lg[:, idx]
|
| 231 |
+
lg[:, idx] = np.where(v > 0, v / rep_penalty, v * rep_penalty)
|
| 232 |
+
probs, x0 = sample_rows(lg, temperature, top_p, rng)
|
| 233 |
+
if use_mtp:
|
| 234 |
+
box = decode_bbox_avg(probs) or decode_ref(probs)
|
| 235 |
+
kind, toks = handle_pattern(box if box is not None else x0)
|
| 236 |
+
if kind == "error_box":
|
| 237 |
+
use_mtp = False
|
| 238 |
+
n_ar += 1
|
| 239 |
+
else:
|
| 240 |
+
t = x0[0]
|
| 241 |
+
toks = [t]
|
| 242 |
+
if t == BOX_END:
|
| 243 |
+
kind, use_mtp = "box_end_ar", True
|
| 244 |
+
elif COORD_START <= t <= COORD_END or t == NONE_ID:
|
| 245 |
+
kind = "coord_ar"
|
| 246 |
+
else:
|
| 247 |
+
kind = "im_end"
|
| 248 |
+
if kind in ("coord_box", "point_box"):
|
| 249 |
+
c = [x - COORD_START for x in toks[1:-1]]
|
| 250 |
+
if kind == "coord_box":
|
| 251 |
+
b = tuple(c) # printed order is <x1><y1><x2><y2>, 0-1000
|
| 252 |
+
if dedupe_iou and any(iou(b, o) > dedupe_iou for o in boxes):
|
| 253 |
+
gen.append(IM_END_ID)
|
| 254 |
+
break
|
| 255 |
+
boxes.append(b)
|
| 256 |
+
if len(boxes) >= max_boxes:
|
| 257 |
+
gen.extend(toks)
|
| 258 |
+
break
|
| 259 |
+
gen.extend(toks)
|
| 260 |
+
seen.update(toks)
|
| 261 |
+
if verbose:
|
| 262 |
+
print(f" step {self.steps:3d} {kind:10s} {self.tok.decode(toks, skip_special_tokens=False)}")
|
| 263 |
+
if kind == "im_end":
|
| 264 |
+
break
|
| 265 |
+
out = self.tok.decode(gen, skip_special_tokens=False)
|
| 266 |
+
return out, {"steps": self.steps, "total_s": round(time.time() - t0, 2), "npu_llm_s": round(self.run_ms / 1000, 2),
|
| 267 |
+
"ar_switches": n_ar, "tokens": len(gen)}
|
| 268 |
+
|
| 269 |
+
def close(self):
|
| 270 |
+
self.llm.close()
|
| 271 |
+
self.rknn.release()
|
| 272 |
+
|
| 273 |
+
|
| 274 |
+
BOX_RE = re.compile(r"<box><(\d+)><(\d+)><(\d+)><(\d+)></box>")
|
| 275 |
+
PT_RE = re.compile(r"<box><(\d+)><(\d+)></box>")
|
| 276 |
+
|
| 277 |
+
|
| 278 |
+
def to_pixels(text, w, h):
|
| 279 |
+
return ([(int(a) / 1000 * w, int(b) / 1000 * h, int(c) / 1000 * w, int(d) / 1000 * h) for a, b, c, d in BOX_RE.findall(text)],
|
| 280 |
+
[(int(a) / 1000 * w, int(b) / 1000 * h) for a, b in PT_RE.findall(text)])
|
| 281 |
+
|
| 282 |
+
|
| 283 |
+
if __name__ == "__main__":
|
| 284 |
+
ap = argparse.ArgumentParser()
|
| 285 |
+
ap.add_argument("image")
|
| 286 |
+
ap.add_argument("question", nargs="?", default="Locate all the instances that matches the following description: person.")
|
| 287 |
+
ap.add_argument("--max-new", type=int, default=300)
|
| 288 |
+
ap.add_argument("--rep", type=float, default=1.1)
|
| 289 |
+
ap.add_argument("--temperature", type=float, default=0.7)
|
| 290 |
+
ap.add_argument("--top-p", type=float, default=0.9)
|
| 291 |
+
ap.add_argument("--seed", type=int, default=0)
|
| 292 |
+
ap.add_argument("-v", "--verbose", action="store_true")
|
| 293 |
+
a = ap.parse_args()
|
| 294 |
+
loc = Locator()
|
| 295 |
+
im = Image.open(a.image)
|
| 296 |
+
t = time.time()
|
| 297 |
+
text, stats = loc.locate(im, a.question, a.max_new, a.rep, verbose=a.verbose, temperature=a.temperature, top_p=a.top_p, seed=a.seed)
|
| 298 |
+
print("ANSWER:", text)
|
| 299 |
+
print("STATS:", stats, "wall %.2fs" % (time.time() - t))
|
| 300 |
+
print("PIXELS:", to_pixels(text, *im.size))
|
| 301 |
+
loc.close()
|
rk3588/rkllm_binding.py
ADDED
|
@@ -0,0 +1,266 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""ctypes bindings for librkllmrt, covering both runtime ABIs in use on this board (1.2.3 and 1.3.0/1.3.1).
|
| 2 |
+
|
| 3 |
+
The two versions share function names but differ in RKLLMParam, the multimodal input layout, RKLLMInferParam and
|
| 4 |
+
rkllm_init's callback argument, so one process must only ever load one of them (see worker.py).
|
| 5 |
+
"""
|
| 6 |
+
import ctypes
|
| 7 |
+
import codecs
|
| 8 |
+
import threading
|
| 9 |
+
|
| 10 |
+
RUN_NORMAL, RUN_WAITING, RUN_FINISH, RUN_ERROR = 0, 1, 2, 3
|
| 11 |
+
INPUT_PROMPT, INPUT_TOKEN, INPUT_EMBED, INPUT_MULTIMODAL = 0, 1, 2, 3
|
| 12 |
+
INFER_GENERATE = 0
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
class ExtendParam(ctypes.Structure):
|
| 16 |
+
_fields_ = [("base_domain_id", ctypes.c_int32), ("embed_flash", ctypes.c_int8),
|
| 17 |
+
("enabled_cpus_num", ctypes.c_int8), ("enabled_cpus_mask", ctypes.c_uint32),
|
| 18 |
+
("n_batch", ctypes.c_uint8), ("use_cross_attn", ctypes.c_int8), ("reserved", ctypes.c_uint8 * 104)]
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
_SAMPLING_HEAD = [("model_path", ctypes.c_char_p), ("max_context_len", ctypes.c_int32),
|
| 22 |
+
("max_new_tokens", ctypes.c_int32), ("top_k", ctypes.c_int32), ("n_keep", ctypes.c_int32),
|
| 23 |
+
("top_p", ctypes.c_float), ("temperature", ctypes.c_float), ("repeat_penalty", ctypes.c_float),
|
| 24 |
+
("frequency_penalty", ctypes.c_float), ("presence_penalty", ctypes.c_float),
|
| 25 |
+
("mirostat", ctypes.c_int32), ("mirostat_tau", ctypes.c_float), ("mirostat_eta", ctypes.c_float),
|
| 26 |
+
("skip_special_token", ctypes.c_bool)]
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
class Param123(ctypes.Structure):
|
| 30 |
+
_fields_ = _SAMPLING_HEAD + [("is_async", ctypes.c_bool), ("img_start", ctypes.c_char_p),
|
| 31 |
+
("img_end", ctypes.c_char_p), ("img_content", ctypes.c_char_p),
|
| 32 |
+
("extend_param", ExtendParam)]
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
class Param130(ctypes.Structure):
|
| 36 |
+
_fields_ = _SAMPLING_HEAD + [("ignore_eos_token", ctypes.c_bool), ("is_async", ctypes.c_bool),
|
| 37 |
+
("extend_param", ExtendParam)]
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
class EmbedInput(ctypes.Structure):
|
| 41 |
+
_fields_ = [("embed", ctypes.POINTER(ctypes.c_float)), ("n_tokens", ctypes.c_size_t)]
|
| 42 |
+
|
| 43 |
+
|
| 44 |
+
class TokenInput(ctypes.Structure):
|
| 45 |
+
_fields_ = [("input_ids", ctypes.POINTER(ctypes.c_int32)), ("n_tokens", ctypes.c_size_t)]
|
| 46 |
+
|
| 47 |
+
|
| 48 |
+
class MultiModal123(ctypes.Structure):
|
| 49 |
+
_fields_ = [("prompt", ctypes.c_char_p), ("image_embed", ctypes.POINTER(ctypes.c_float)),
|
| 50 |
+
("n_image_tokens", ctypes.c_size_t), ("n_image", ctypes.c_size_t),
|
| 51 |
+
("image_width", ctypes.c_size_t), ("image_height", ctypes.c_size_t)]
|
| 52 |
+
|
| 53 |
+
|
| 54 |
+
class ImageInput130(ctypes.Structure):
|
| 55 |
+
_fields_ = [("image_embed", ctypes.POINTER(ctypes.c_float)), ("n_image_tokens", ctypes.c_size_t),
|
| 56 |
+
("n_image", ctypes.c_size_t), ("image_start", ctypes.c_char_p), ("image_end", ctypes.c_char_p),
|
| 57 |
+
("image_content", ctypes.c_char_p), ("image_width", ctypes.c_size_t),
|
| 58 |
+
("image_height", ctypes.c_size_t)]
|
| 59 |
+
|
| 60 |
+
|
| 61 |
+
class VideoInput130(ctypes.Structure):
|
| 62 |
+
_fields_ = [("video_embed", ctypes.POINTER(ctypes.c_float)), ("n_frame_tokens", ctypes.c_size_t),
|
| 63 |
+
("n_frame_per_video", ctypes.c_size_t), ("n_video", ctypes.c_size_t),
|
| 64 |
+
("video_start", ctypes.c_char_p), ("video_end", ctypes.c_char_p), ("video_content", ctypes.c_char_p),
|
| 65 |
+
("frame_width", ctypes.c_size_t), ("frame_height", ctypes.c_size_t)]
|
| 66 |
+
|
| 67 |
+
|
| 68 |
+
class AudioInput131(ctypes.Structure):
|
| 69 |
+
_fields_ = [("audio_embed", ctypes.POINTER(ctypes.c_float)), ("n_audio_tokens", ctypes.c_size_t),
|
| 70 |
+
("n_audio", ctypes.c_size_t), ("audio_start", ctypes.c_char_p), ("audio_end", ctypes.c_char_p),
|
| 71 |
+
("audio_content", ctypes.c_char_p)]
|
| 72 |
+
|
| 73 |
+
|
| 74 |
+
class MultiModal130(ctypes.Structure):
|
| 75 |
+
# 1.3.1 appended `audio`; 1.3.0 ignores the extra (zeroed) tail, so one layout serves both
|
| 76 |
+
_fields_ = [("prompt", ctypes.c_char_p), ("image", ImageInput130), ("video", VideoInput130),
|
| 77 |
+
("audio", AudioInput131)]
|
| 78 |
+
|
| 79 |
+
|
| 80 |
+
def _input_struct(mm):
|
| 81 |
+
class U(ctypes.Union):
|
| 82 |
+
_fields_ = [("prompt_input", ctypes.c_char_p), ("embed_input", EmbedInput), ("token_input", TokenInput),
|
| 83 |
+
("multimodal_input", mm)]
|
| 84 |
+
|
| 85 |
+
class Input(ctypes.Structure):
|
| 86 |
+
_anonymous_ = ("u",)
|
| 87 |
+
_fields_ = [("role", ctypes.c_char_p), ("enable_thinking", ctypes.c_bool), ("input_type", ctypes.c_int),
|
| 88 |
+
("u", U)]
|
| 89 |
+
return Input
|
| 90 |
+
|
| 91 |
+
|
| 92 |
+
Input123 = _input_struct(MultiModal123)
|
| 93 |
+
Input130 = _input_struct(MultiModal130)
|
| 94 |
+
|
| 95 |
+
|
| 96 |
+
class SamplingParam(ctypes.Structure):
|
| 97 |
+
_fields_ = [("top_k", ctypes.c_int32), ("top_p", ctypes.c_float), ("temperature", ctypes.c_float),
|
| 98 |
+
("repeat_penalty", ctypes.c_float), ("frequency_penalty", ctypes.c_float),
|
| 99 |
+
("presence_penalty", ctypes.c_float), ("mirostat", ctypes.c_int32), ("mirostat_tau", ctypes.c_float),
|
| 100 |
+
("mirostat_eta", ctypes.c_float)]
|
| 101 |
+
|
| 102 |
+
|
| 103 |
+
class InferParam123(ctypes.Structure):
|
| 104 |
+
_fields_ = [("mode", ctypes.c_int), ("lora_params", ctypes.c_void_p), ("prompt_cache_params", ctypes.c_void_p),
|
| 105 |
+
("keep_history", ctypes.c_int)]
|
| 106 |
+
|
| 107 |
+
|
| 108 |
+
class InferParam130(ctypes.Structure):
|
| 109 |
+
_fields_ = [("mode", ctypes.c_int), ("lora_params", ctypes.c_void_p), ("prompt_cache_params", ctypes.c_void_p),
|
| 110 |
+
("sampling_params", ctypes.POINTER(SamplingParam)), ("keep_history", ctypes.c_int),
|
| 111 |
+
("max_new_tokens", ctypes.c_int32)]
|
| 112 |
+
|
| 113 |
+
|
| 114 |
+
class PerfStat(ctypes.Structure):
|
| 115 |
+
_fields_ = [("prefill_time_ms", ctypes.c_float), ("prefill_tokens", ctypes.c_int),
|
| 116 |
+
("generate_time_ms", ctypes.c_float), ("generate_tokens", ctypes.c_int),
|
| 117 |
+
("memory_usage_mb", ctypes.c_float)]
|
| 118 |
+
|
| 119 |
+
|
| 120 |
+
class Result(ctypes.Structure):
|
| 121 |
+
_fields_ = [("text", ctypes.c_char_p), ("token_id", ctypes.c_int32),
|
| 122 |
+
("hidden_states", ctypes.c_void_p), ("embd_size", ctypes.c_int), ("hs_num_tokens", ctypes.c_int),
|
| 123 |
+
("logits", ctypes.c_void_p), ("vocab_size", ctypes.c_int), ("lg_num_tokens", ctypes.c_int),
|
| 124 |
+
("perf", PerfStat)]
|
| 125 |
+
|
| 126 |
+
|
| 127 |
+
ResultCallback = ctypes.CFUNCTYPE(ctypes.c_int, ctypes.POINTER(Result), ctypes.c_void_p, ctypes.c_int)
|
| 128 |
+
|
| 129 |
+
|
| 130 |
+
class Callback130(ctypes.Structure):
|
| 131 |
+
_fields_ = [("result_callback", ResultCallback), ("result_userdata", ctypes.c_void_p),
|
| 132 |
+
("tokenizer_callback", ctypes.c_void_p), ("tokenizer_userdata", ctypes.c_void_p),
|
| 133 |
+
("embed_callback", ctypes.c_void_p), ("embed_userdata", ctypes.c_void_p)]
|
| 134 |
+
|
| 135 |
+
|
| 136 |
+
IMG_START, IMG_END, IMG_CONTENT = b"<|vision_start|>", b"<|vision_end|>", b"<|image_pad|>"
|
| 137 |
+
|
| 138 |
+
|
| 139 |
+
class RKLLM:
|
| 140 |
+
"""One loaded model. Prompts are passed pre-rendered (chat template disabled), so requests are stateless."""
|
| 141 |
+
|
| 142 |
+
def __init__(self, lib_path, runtime, model_path, max_context_len=4096, max_new_tokens=1024,
|
| 143 |
+
top_k=1, top_p=0.9, temperature=0.8, repeat_penalty=1.1, embed_flash=False, img_tags=None):
|
| 144 |
+
"""embed_flash: read token embeddings from storage instead of RAM (needed for Gemma4-E2B, whose 7.4GB
|
| 145 |
+
file is mostly per-layer embeddings). img_tags: (start, end, content) image markers; Qwen-VL by default."""
|
| 146 |
+
self.v13 = runtime.startswith("1.3")
|
| 147 |
+
self.img_tags = tuple(t.encode() for t in img_tags) if img_tags else (IMG_START, IMG_END, IMG_CONTENT)
|
| 148 |
+
self.lib = lib = ctypes.CDLL(lib_path)
|
| 149 |
+
P = Param130 if self.v13 else Param123
|
| 150 |
+
lib.rkllm_createDefaultParam.restype = P
|
| 151 |
+
p = lib.rkllm_createDefaultParam()
|
| 152 |
+
p.model_path = model_path.encode()
|
| 153 |
+
p.max_context_len, p.max_new_tokens = max_context_len, max_new_tokens
|
| 154 |
+
p.top_k, p.top_p, p.temperature, p.repeat_penalty = top_k, top_p, temperature, repeat_penalty
|
| 155 |
+
p.skip_special_token = True
|
| 156 |
+
p.extend_param.base_domain_id = 1 # rk3588
|
| 157 |
+
p.extend_param.enabled_cpus_num = 4
|
| 158 |
+
p.extend_param.enabled_cpus_mask = 0xF0 # big cores 4-7
|
| 159 |
+
if embed_flash:
|
| 160 |
+
p.extend_param.embed_flash = 1
|
| 161 |
+
if not self.v13:
|
| 162 |
+
p.img_start, p.img_end, p.img_content = self.img_tags
|
| 163 |
+
self.max_new_tokens = max_new_tokens
|
| 164 |
+
|
| 165 |
+
self._on_text = None
|
| 166 |
+
self._perf = None
|
| 167 |
+
self._error = False
|
| 168 |
+
self._decoder = None
|
| 169 |
+
self._cb = ResultCallback(self._callback) # keep a reference: ctypes callbacks die with their Python object
|
| 170 |
+
self.handle = ctypes.c_void_p()
|
| 171 |
+
if self.v13:
|
| 172 |
+
self._cbs = Callback130(result_callback=self._cb)
|
| 173 |
+
lib.rkllm_init.argtypes = [ctypes.POINTER(ctypes.c_void_p), ctypes.POINTER(P), ctypes.POINTER(Callback130)]
|
| 174 |
+
ret = lib.rkllm_init(ctypes.byref(self.handle), ctypes.byref(p), ctypes.byref(self._cbs))
|
| 175 |
+
else:
|
| 176 |
+
lib.rkllm_init.argtypes = [ctypes.POINTER(ctypes.c_void_p), ctypes.POINTER(P), ResultCallback]
|
| 177 |
+
ret = lib.rkllm_init(ctypes.byref(self.handle), ctypes.byref(p), self._cb)
|
| 178 |
+
if ret != 0:
|
| 179 |
+
raise RuntimeError(f"rkllm_init failed ({ret}) for {model_path}")
|
| 180 |
+
|
| 181 |
+
lib.rkllm_set_chat_template.argtypes = [ctypes.c_void_p, ctypes.c_char_p, ctypes.c_char_p, ctypes.c_char_p]
|
| 182 |
+
lib.rkllm_set_chat_template(self.handle, b"", b"", b"")
|
| 183 |
+
lib.rkllm_run.argtypes = [ctypes.c_void_p, ctypes.c_void_p, ctypes.c_void_p, ctypes.c_void_p]
|
| 184 |
+
lib.rkllm_abort.argtypes = [ctypes.c_void_p]
|
| 185 |
+
lib.rkllm_destroy.argtypes = [ctypes.c_void_p]
|
| 186 |
+
|
| 187 |
+
def _callback(self, result, userdata, state):
|
| 188 |
+
if state == RUN_NORMAL:
|
| 189 |
+
raw = result.contents.text
|
| 190 |
+
if raw:
|
| 191 |
+
# tokens can end mid-UTF-8 sequence (CJK), so decode incrementally
|
| 192 |
+
text = self._decoder.decode(raw)
|
| 193 |
+
if text and self._on_text:
|
| 194 |
+
self._on_text(text)
|
| 195 |
+
elif state == RUN_FINISH:
|
| 196 |
+
perf = result.contents.perf
|
| 197 |
+
self._perf = {k: getattr(perf, k) for k, _ in PerfStat._fields_}
|
| 198 |
+
elif state == RUN_ERROR:
|
| 199 |
+
self._error = True
|
| 200 |
+
return 0
|
| 201 |
+
|
| 202 |
+
def generate(self, prompt, on_text, image_embeds=None, n_image_tokens=0, image_size=(0, 0),
|
| 203 |
+
max_new_tokens=None, sampling=None, abort_event=None):
|
| 204 |
+
"""Blocking generation. image_embeds: float32 C-contiguous array [n_images * n_tokens, dim]; prompt must
|
| 205 |
+
contain one '<image>' per image. sampling/max_new_tokens are honoured per request on runtime 1.3 only."""
|
| 206 |
+
self._on_text, self._perf, self._error = on_text, None, False
|
| 207 |
+
self._decoder = codecs.getincrementaldecoder("utf-8")(errors="replace")
|
| 208 |
+
Inp = Input130 if self.v13 else Input123
|
| 209 |
+
inp = Inp()
|
| 210 |
+
inp.role = b"user"
|
| 211 |
+
inp.enable_thinking = False
|
| 212 |
+
prompt_b = prompt.encode()
|
| 213 |
+
if image_embeds is not None:
|
| 214 |
+
inp.input_type = INPUT_MULTIMODAL
|
| 215 |
+
mm = inp.multimodal_input
|
| 216 |
+
mm.prompt = prompt_b
|
| 217 |
+
n_images = image_embeds.shape[0] // n_image_tokens
|
| 218 |
+
ptr = image_embeds.ctypes.data_as(ctypes.POINTER(ctypes.c_float))
|
| 219 |
+
img = mm.image if self.v13 else mm
|
| 220 |
+
img.image_embed, img.n_image_tokens, img.n_image = ptr, n_image_tokens, n_images
|
| 221 |
+
img.image_width, img.image_height = image_size
|
| 222 |
+
if self.v13:
|
| 223 |
+
img.image_start, img.image_end, img.image_content = self.img_tags
|
| 224 |
+
else:
|
| 225 |
+
inp.input_type = INPUT_PROMPT
|
| 226 |
+
inp.prompt_input = prompt_b
|
| 227 |
+
|
| 228 |
+
if self.v13:
|
| 229 |
+
ip = InferParam130(mode=INFER_GENERATE, keep_history=0, max_new_tokens=max_new_tokens or 0)
|
| 230 |
+
if sampling:
|
| 231 |
+
sp = SamplingParam(top_k=sampling.get("top_k", 1), top_p=sampling.get("top_p", 0.9),
|
| 232 |
+
temperature=sampling.get("temperature", 0.8),
|
| 233 |
+
repeat_penalty=sampling.get("repeat_penalty", 1.1), mirostat_tau=5.0,
|
| 234 |
+
mirostat_eta=0.1)
|
| 235 |
+
ip.sampling_params = ctypes.pointer(sp)
|
| 236 |
+
else:
|
| 237 |
+
ip = InferParam123(mode=INFER_GENERATE, keep_history=0)
|
| 238 |
+
|
| 239 |
+
# abort watcher: rkllm_abort must not be called from inside the result callback
|
| 240 |
+
done = threading.Event()
|
| 241 |
+
watcher = None
|
| 242 |
+
if abort_event is not None:
|
| 243 |
+
def watch():
|
| 244 |
+
while not done.is_set():
|
| 245 |
+
if abort_event.wait(0.05):
|
| 246 |
+
self.lib.rkllm_abort(self.handle)
|
| 247 |
+
return
|
| 248 |
+
watcher = threading.Thread(target=watch, daemon=True)
|
| 249 |
+
watcher.start()
|
| 250 |
+
try:
|
| 251 |
+
self.lib.rkllm_run(self.handle, ctypes.byref(inp), ctypes.byref(ip), None)
|
| 252 |
+
finally:
|
| 253 |
+
done.set()
|
| 254 |
+
if watcher:
|
| 255 |
+
watcher.join()
|
| 256 |
+
tail = self._decoder.decode(b"", final=True)
|
| 257 |
+
if tail and on_text:
|
| 258 |
+
on_text(tail)
|
| 259 |
+
if self._error:
|
| 260 |
+
raise RuntimeError("rkllm_run reported RKLLM_RUN_ERROR")
|
| 261 |
+
return self._perf or {}
|
| 262 |
+
|
| 263 |
+
def close(self):
|
| 264 |
+
if self.handle:
|
| 265 |
+
self.lib.rkllm_destroy(self.handle)
|
| 266 |
+
self.handle = ctypes.c_void_p()
|
tokenizer.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:f56587c1c7b4d69be60b018606b1bf2f90e46ca9d51fb2689090997281df7e40
|
| 3 |
+
size 11606727
|
tools/build_rknn.py
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Derived from NVIDIA LocateAnything-3B (modeling_vit.py / modeling_locateanything.py, Copyright (c) 2026 NVIDIA
|
| 2 |
+
# CORPORATION) under the NVIDIA License (see ../LICENSE); MoonViT is MIT-licensed by Moonshot AI. Modified.
|
| 3 |
+
import sys, os
|
| 4 |
+
from rknn.api import RKNN
|
| 5 |
+
onnx_path, out = sys.argv[1], sys.argv[2]
|
| 6 |
+
rknn = RKNN(verbose=False)
|
| 7 |
+
rknn.config(target_platform="rk3588", mean_values=[[127.5,127.5,127.5]], std_values=[[127.5,127.5,127.5]],
|
| 8 |
+
disable_rules=["_p_fuse_matmul_add_mul_softmax_matmul_to_sdpa","fuse_matmul_add_mul_softmax_matmul_to_sdpa"])
|
| 9 |
+
assert rknn.load_onnx(onnx_path, inputs=["pixel"], input_size_list=[[1,3,448,448]]) == 0, "load_onnx failed"
|
| 10 |
+
assert rknn.build(do_quantization=False) == 0, "build failed"
|
| 11 |
+
assert rknn.export_rknn(out) == 0, "export failed"
|
| 12 |
+
print("RKNN EXPORTED", out, os.path.getsize(out))
|
tools/convert_rkllm.py
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Generic Hugging Face text model -> RKLLM w8a8 for RK3588 (run on the 3090 WSL box).
|
| 2 |
+
|
| 3 |
+
python convert_rkllm.py MODEL_DIR OUT.rkllm [--max-context 4096] [--device cuda] [--fla]
|
| 4 |
+
|
| 5 |
+
--fla: import flash-linear-attention first so `rwkv7` (fla-hub checkpoints) is registered with transformers. The fla
|
| 6 |
+
pinned by requirements_rwkv7.txt also registers names (bitnet, ...) that transformers 5.8 now ships, which raises
|
| 7 |
+
"already used"; those are skipped.
|
| 8 |
+
"""
|
| 9 |
+
import argparse
|
| 10 |
+
import os
|
| 11 |
+
|
| 12 |
+
from rkllm.api import RKLLM
|
| 13 |
+
|
| 14 |
+
ap = argparse.ArgumentParser()
|
| 15 |
+
ap.add_argument("model_dir")
|
| 16 |
+
ap.add_argument("out")
|
| 17 |
+
ap.add_argument("--max-context", type=int, default=4096)
|
| 18 |
+
ap.add_argument("--device", default="cuda")
|
| 19 |
+
ap.add_argument("--dtype", default="w8a8")
|
| 20 |
+
ap.add_argument("--fla", action="store_true")
|
| 21 |
+
args = ap.parse_args()
|
| 22 |
+
if args.fla:
|
| 23 |
+
from transformers.models.auto import auto_factory, configuration_auto
|
| 24 |
+
|
| 25 |
+
def skip_taken(orig):
|
| 26 |
+
def register(self, key, value, exist_ok=False):
|
| 27 |
+
try:
|
| 28 |
+
orig(self, key, value, exist_ok=exist_ok)
|
| 29 |
+
except ValueError as e:
|
| 30 |
+
if "already" not in str(e):
|
| 31 |
+
raise
|
| 32 |
+
return register
|
| 33 |
+
|
| 34 |
+
configuration_auto._LazyConfigMapping.register = skip_taken(configuration_auto._LazyConfigMapping.register)
|
| 35 |
+
auto_factory._LazyAutoMapping.register = skip_taken(auto_factory._LazyAutoMapping.register)
|
| 36 |
+
import fla.models
|
| 37 |
+
import transformers
|
| 38 |
+
# rkllm looks the class up by its architectures[] name on the transformers module
|
| 39 |
+
transformers.RWKV7ForCausalLM = fla.models.RWKV7ForCausalLM
|
| 40 |
+
llm = RKLLM()
|
| 41 |
+
assert llm.load_huggingface(model=args.model_dir, device=args.device) == 0, "load failed"
|
| 42 |
+
assert llm.build(do_quantization=True, optimization_level=1, quantized_dtype=args.dtype, quantized_algorithm="normal",
|
| 43 |
+
target_platform="rk3588", num_npu_core=3, max_context=args.max_context) == 0, "build failed"
|
| 44 |
+
assert llm.export_rkllm(args.out) == 0, "export failed"
|
| 45 |
+
print("EXPORTED", args.out, os.path.getsize(args.out))
|
tools/eval_board.py
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import json, os, sys, time
|
| 2 |
+
HERE = os.path.dirname(os.path.abspath(__file__))
|
| 3 |
+
sys.path.insert(0, os.path.join(HERE, "..", "rk3588"))
|
| 4 |
+
EVAL = os.environ.get("EVAL_DIR", os.path.join(HERE, "eval"))
|
| 5 |
+
from PIL import Image
|
| 6 |
+
import locate3b as L
|
| 7 |
+
S = json.load(open(EVAL + "/eval_set.json"))
|
| 8 |
+
loc = L.Locator()
|
| 9 |
+
out = {}
|
| 10 |
+
t0 = time.time()
|
| 11 |
+
for k, s in enumerate(S):
|
| 12 |
+
img = Image.open(EVAL + "/" + s["file"])
|
| 13 |
+
q = "Locate all the instances that matches the following description: %s." % s["cat"]
|
| 14 |
+
t = time.time()
|
| 15 |
+
try:
|
| 16 |
+
text, st = loc.locate(img, q, max_new=400, rep_penalty=1.1, max_boxes=100, dedupe_iou=0.85, temperature=0.7, top_p=0.9, seed=0)
|
| 17 |
+
except Exception as e:
|
| 18 |
+
text, st = "ERROR %r" % e, {}
|
| 19 |
+
out[str(s["id"])] = {"text": text, "sec": round(time.time() - t, 2), "stats": st}
|
| 20 |
+
if k % 10 == 0:
|
| 21 |
+
print(k, "%.0fs" % (time.time() - t0), flush=True)
|
| 22 |
+
json.dump(out, open(EVAL + "/preds_board_sampled.json", "w"), ensure_ascii=False)
|
| 23 |
+
json.dump(out, open(EVAL + "/preds_board_sampled.json", "w"), ensure_ascii=False)
|
| 24 |
+
loc.close(); print("BOARD DONE", "%.0fs" % (time.time() - t0))
|
tools/extract_llm.py
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Derived from NVIDIA LocateAnything-3B (modeling_vit.py / modeling_locateanything.py, Copyright (c) 2026 NVIDIA
|
| 2 |
+
# CORPORATION) under the NVIDIA License (see ../LICENSE); MoonViT is MIT-licensed by Moonshot AI. Modified.
|
| 3 |
+
import json, shutil, os, torch
|
| 4 |
+
from safetensors import safe_open
|
| 5 |
+
from safetensors.torch import save_file
|
| 6 |
+
from transformers import Qwen2Config, Qwen2ForCausalLM
|
| 7 |
+
SRC="model"; DST="qwen25_3b_la"
|
| 8 |
+
os.makedirs(DST, exist_ok=True)
|
| 9 |
+
idx=json.load(open(f"{SRC}/model.safetensors.index.json"))["weight_map"]
|
| 10 |
+
llm={}; extra={}
|
| 11 |
+
files={}
|
| 12 |
+
for k,f in idx.items(): files.setdefault(f,[]).append(k)
|
| 13 |
+
for f,keys in files.items():
|
| 14 |
+
with safe_open(f"{SRC}/{f}","pt") as sf:
|
| 15 |
+
for k in keys:
|
| 16 |
+
if k.startswith("language_model."): llm[k[len("language_model."):]]=sf.get_tensor(k)
|
| 17 |
+
elif k.startswith("mlp1."): extra[k]=sf.get_tensor(k)
|
| 18 |
+
tied = torch.equal(llm["lm_head.weight"], llm["model.embed_tokens.weight"])
|
| 19 |
+
print("lm_head == embed_tokens:", tied, "| vocab rows:", llm["model.embed_tokens.weight"].shape)
|
| 20 |
+
cfg=json.load(open(f"{SRC}/config.json"))["text_config"]
|
| 21 |
+
qc=Qwen2Config(vocab_size=cfg["vocab_size"],hidden_size=cfg["hidden_size"],intermediate_size=cfg["intermediate_size"],
|
| 22 |
+
num_hidden_layers=cfg["num_hidden_layers"],num_attention_heads=cfg["num_attention_heads"],num_key_value_heads=cfg["num_key_value_heads"],
|
| 23 |
+
max_position_embeddings=cfg["max_position_embeddings"],rms_norm_eps=cfg["rms_norm_eps"],rope_theta=cfg["rope_theta"],
|
| 24 |
+
tie_word_embeddings=tied,use_sliding_window=False,sliding_window=None,bos_token_id=cfg["bos_token_id"],eos_token_id=cfg["eos_token_id"],torch_dtype="bfloat16")
|
| 25 |
+
qc.architectures=["Qwen2ForCausalLM"]
|
| 26 |
+
qc.save_pretrained(DST)
|
| 27 |
+
if tied: llm.pop("lm_head.weight")
|
| 28 |
+
save_file({k:v.contiguous() for k,v in llm.items()}, f"{DST}/model.safetensors", metadata={"format":"pt"})
|
| 29 |
+
save_file({k:v.contiguous() for k,v in extra.items()}, f"{DST}/mlp1.safetensors")
|
| 30 |
+
for f in ["vocab.json","merges.txt","tokenizer_config.json","added_tokens.json","special_tokens_map.json","generation_config.json"]:
|
| 31 |
+
shutil.copy(f"{SRC}/{f}", f"{DST}/{f}")
|
| 32 |
+
# sanity: reload as plain Qwen2 and compare to original LLM logits
|
| 33 |
+
m=Qwen2ForCausalLM.from_pretrained(DST, torch_dtype=torch.float32).eval()
|
| 34 |
+
ids=torch.randint(0,150000,(1,32))
|
| 35 |
+
with torch.no_grad(): lg=m(ids).logits
|
| 36 |
+
print("reloaded ok, logits", tuple(lg.shape), "finite:", torch.isfinite(lg).all().item())
|
| 37 |
+
torch.save({"ids":ids,"logits":lg}, "ref_logits_plain.pt")
|
tools/prep_coco_subset.py
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import json, random, collections, urllib.request, os
|
| 2 |
+
d = json.load(open("instances_val2017.json"))
|
| 3 |
+
cats = {c["id"]: c["name"] for c in d["categories"]}
|
| 4 |
+
imgs = {i["id"]: i for i in d["images"]}
|
| 5 |
+
by = collections.defaultdict(list)
|
| 6 |
+
for a in d["annotations"]:
|
| 7 |
+
if a["iscrowd"]: continue
|
| 8 |
+
by[a["image_id"]].append(a)
|
| 9 |
+
rng = random.Random(0); cand = []
|
| 10 |
+
for iid, anns in sorted(by.items()):
|
| 11 |
+
W, H = imgs[iid]["width"], imgs[iid]["height"]
|
| 12 |
+
cnt = collections.Counter(a["category_id"] for a in anns)
|
| 13 |
+
cid, n = cnt.most_common(1)[0]
|
| 14 |
+
g = [a for a in anns if a["category_id"] == cid]
|
| 15 |
+
if not (1 <= n <= 8): continue
|
| 16 |
+
if any(a["bbox"][2] * a["bbox"][3] < 32 * 32 for a in g): continue
|
| 17 |
+
boxes = [[a["bbox"][0]/W*1000, a["bbox"][1]/H*1000, (a["bbox"][0]+a["bbox"][2])/W*1000, (a["bbox"][1]+a["bbox"][3])/H*1000] for a in g]
|
| 18 |
+
cand.append({"id": iid, "file": "img/%012d.jpg" % iid, "cat": cats[cid], "n_gt": n, "boxes": boxes, "w": W, "h": H})
|
| 19 |
+
rng.shuffle(cand); sel = cand[:100]
|
| 20 |
+
for s in sel:
|
| 21 |
+
if not os.path.exists(s["file"]):
|
| 22 |
+
urllib.request.urlretrieve("http://images.cocodataset.org/val2017/%012d.jpg" % s["id"], s["file"])
|
| 23 |
+
json.dump(sel, open("eval_set.json", "w"))
|
| 24 |
+
print("candidates", len(cand), "selected", len(sel), "mean GT/img", sum(s["n_gt"] for s in sel)/len(sel))
|
| 25 |
+
print(collections.Counter(s["cat"] for s in sel).most_common(8))
|
tools/score_coco.py
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import json, re, sys, collections
|
| 2 |
+
BOX = re.compile(r"<box><(\d+)><(\d+)><(\d+)><(\d+)></box>")
|
| 3 |
+
def iou(a, b):
|
| 4 |
+
ix = max(0, min(a[2], b[2]) - max(a[0], b[0])); iy = max(0, min(a[3], b[3]) - max(a[1], b[1]))
|
| 5 |
+
i = ix * iy; u = (a[2]-a[0])*(a[3]-a[1]) + (b[2]-b[0])*(b[3]-b[1]) - i
|
| 6 |
+
return i / u if u > 0 else 0.0
|
| 7 |
+
def parse(text, dedupe=0.85, cap=30):
|
| 8 |
+
kept = []
|
| 9 |
+
for m in BOX.finditer(text):
|
| 10 |
+
b = tuple(int(x) for x in m.groups())
|
| 11 |
+
if b[2] <= b[0] or b[3] <= b[1]: continue
|
| 12 |
+
if dedupe and any(iou(b, o) > dedupe for o in kept): break
|
| 13 |
+
kept.append(b)
|
| 14 |
+
if len(kept) >= cap: break
|
| 15 |
+
return kept
|
| 16 |
+
def score(preds, S, thr=0.5, **kw):
|
| 17 |
+
tp = fp = fn = 0; ious = []; npred = []; stopped = 0; secs = []; exact = 0; n = 0
|
| 18 |
+
for s in S:
|
| 19 |
+
p = preds.get(str(s["id"]))
|
| 20 |
+
if p is None: continue
|
| 21 |
+
n += 1; secs.append(p["sec"]); stopped += ("<|im_end|>" in p["text"])
|
| 22 |
+
pb = parse(p["text"], **kw); npred.append(len(pb)); used = set()
|
| 23 |
+
for b in pb:
|
| 24 |
+
best, bj = 0, -1
|
| 25 |
+
for j, g in enumerate(s["boxes"]):
|
| 26 |
+
if j in used: continue
|
| 27 |
+
v = iou(b, g)
|
| 28 |
+
if v > best: best, bj = v, j
|
| 29 |
+
if best >= thr: tp += 1; used.add(bj); ious.append(best)
|
| 30 |
+
else: fp += 1
|
| 31 |
+
fn += len(s["boxes"]) - len(used); exact += (len(pb) == len(s["boxes"]) and len(used) == len(pb))
|
| 32 |
+
P = tp / (tp + fp) if tp + fp else 0; R = tp / (tp + fn) if tp + fn else 0
|
| 33 |
+
return {"n": n, "P": round(P, 3), "R": round(R, 3), "F1": round(2*P*R/(P+R), 3) if P+R else 0,
|
| 34 |
+
"mIoU(matched)": round(sum(ious)/len(ious), 3) if ious else 0, "pred/img": round(sum(npred)/n, 2),
|
| 35 |
+
"exact_imgs": exact, "sec/img": round(sum(secs)/n, 2)}
|
| 36 |
+
if __name__ == "__main__":
|
| 37 |
+
S = json.load(open(sys.argv[1])); files = sys.argv[2:]
|
| 38 |
+
allp = {}
|
| 39 |
+
for f in files:
|
| 40 |
+
d = json.load(open(f))
|
| 41 |
+
allp.update(d if all(isinstance(v, dict) and "text" not in v for v in d.values()) else {"board": d})
|
| 42 |
+
for name, preds in allp.items():
|
| 43 |
+
print("%-18s" % name, score(preds, S), "| F1@0.75", score(preds, S, thr=0.75)["F1"])
|
tools/vit_fixed.py
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Derived from NVIDIA LocateAnything-3B (modeling_vit.py / modeling_locateanything.py, Copyright (c) 2026 NVIDIA
|
| 2 |
+
# CORPORATION) under the NVIDIA License (see ../LICENSE); MoonViT is MIT-licensed by Moonshot AI. Modified.
|
| 3 |
+
import sys, math, torch, torch.nn as nn, torch.nn.functional as F
|
| 4 |
+
from safetensors import safe_open
|
| 5 |
+
GH = int(sys.argv[1]) if len(sys.argv) > 1 else 32 # patch grid (H/14, W/14)
|
| 6 |
+
GW = int(sys.argv[2]) if len(sys.argv) > 2 else 32
|
| 7 |
+
D, HEADS, HD, LAYERS, FF, P = 1152, 16, 72, 27, 4304, 14
|
| 8 |
+
MP = "./model"
|
| 9 |
+
|
| 10 |
+
def load():
|
| 11 |
+
w = {}
|
| 12 |
+
import json
|
| 13 |
+
idx = json.load(open(f"{MP}/model.safetensors.index.json"))["weight_map"]
|
| 14 |
+
files = sorted(set(idx.values()))
|
| 15 |
+
for f in files:
|
| 16 |
+
with safe_open(f"{MP}/{f}", "pt") as sf:
|
| 17 |
+
for k in sf.keys():
|
| 18 |
+
if k.startswith("vision_model.") or k.startswith("mlp1."):
|
| 19 |
+
w[k] = sf.get_tensor(k).float()
|
| 20 |
+
return w
|
| 21 |
+
|
| 22 |
+
def gelu_tanh(x):
|
| 23 |
+
return 0.5 * x * (1.0 + torch.tanh(math.sqrt(2.0 / math.pi) * (x + 0.044715 * x * x * x)))
|
| 24 |
+
|
| 25 |
+
class Block(nn.Module):
|
| 26 |
+
def __init__(s):
|
| 27 |
+
super().__init__()
|
| 28 |
+
s.norm0 = nn.LayerNorm(D); s.norm1 = nn.LayerNorm(D)
|
| 29 |
+
s.wqkv = nn.Linear(D, 3 * D); s.wo = nn.Linear(D, D)
|
| 30 |
+
s.fc0 = nn.Linear(D, FF); s.fc1 = nn.Linear(FF, D)
|
| 31 |
+
def forward(s, x, cos, sin): # x (1,N,D); cos/sin (1,N,1,36)
|
| 32 |
+
N = x.shape[1]
|
| 33 |
+
qkv = s.wqkv(s.norm0(x)).view(1, N, 3, HEADS, HD)
|
| 34 |
+
q, k, v = qkv[:, :, 0], qkv[:, :, 1], qkv[:, :, 2] # (1,N,H,HD)
|
| 35 |
+
def rot(t):
|
| 36 |
+
t = t.view(1, N, HEADS, HD // 2, 2)
|
| 37 |
+
r, i = t[..., 0], t[..., 1]
|
| 38 |
+
return torch.stack([r * cos - i * sin, r * sin + i * cos], dim=-1).view(1, N, HEADS, HD)
|
| 39 |
+
q, k = rot(q), rot(k)
|
| 40 |
+
q = q.permute(0, 2, 1, 3); k = k.permute(0, 2, 1, 3); v = v.permute(0, 2, 1, 3)
|
| 41 |
+
a = torch.softmax(torch.matmul(q, k.transpose(-1, -2)) * (1.0 / math.sqrt(HD)), dim=-1)
|
| 42 |
+
o = torch.matmul(a, v).permute(0, 2, 1, 3).reshape(1, N, D)
|
| 43 |
+
x = x + s.wo(o)
|
| 44 |
+
return x + s.fc1(gelu_tanh(s.fc0(s.norm1(x))))
|
| 45 |
+
|
| 46 |
+
class ViTFixed(nn.Module):
|
| 47 |
+
def __init__(s, w):
|
| 48 |
+
super().__init__()
|
| 49 |
+
N = GH * GW
|
| 50 |
+
s.proj = nn.Conv2d(3, D, P, P)
|
| 51 |
+
s.proj.weight.data = w["vision_model.patch_embed.proj.weight"]; s.proj.bias.data = w["vision_model.patch_embed.proj.bias"]
|
| 52 |
+
pe = w["vision_model.patch_embed.pos_emb.weight"] # (64,64,D)
|
| 53 |
+
if (GH, GW) != tuple(pe.shape[:2]):
|
| 54 |
+
pe = F.interpolate(pe.permute(2, 0, 1).unsqueeze(0), size=(GH, GW), mode="bicubic").squeeze(0).permute(1, 2, 0)
|
| 55 |
+
s.register_buffer("pos", pe.reshape(1, N, D).contiguous())
|
| 56 |
+
# 2D rope: angle[:,2i]=x*f_i, angle[:,2i+1]=y*f_i (x = column, y = row)
|
| 57 |
+
f = 1.0 / (10000 ** (torch.arange(0, HD, 4)[: HD // 4].float() / HD))
|
| 58 |
+
ys, xs = torch.meshgrid(torch.arange(GH).float(), torch.arange(GW).float(), indexing="ij")
|
| 59 |
+
xs, ys = xs.reshape(-1), ys.reshape(-1)
|
| 60 |
+
ang = torch.stack([torch.outer(xs, f), torch.outer(ys, f)], dim=-1).reshape(N, HD // 2)
|
| 61 |
+
s.register_buffer("cos", ang.cos().view(1, N, 1, HD // 2)); s.register_buffer("sin", ang.sin().view(1, N, 1, HD // 2))
|
| 62 |
+
s.blocks = nn.ModuleList([Block() for _ in range(LAYERS)])
|
| 63 |
+
for i, b in enumerate(s.blocks):
|
| 64 |
+
p = f"vision_model.encoder.blocks.{i}."
|
| 65 |
+
b.norm0.weight.data = w[p+"norm0.weight"]; b.norm0.bias.data = w[p+"norm0.bias"]
|
| 66 |
+
b.norm1.weight.data = w[p+"norm1.weight"]; b.norm1.bias.data = w[p+"norm1.bias"]
|
| 67 |
+
b.wqkv.weight.data = w[p+"wqkv.weight"]; b.wqkv.bias.data = w[p+"wqkv.bias"]
|
| 68 |
+
b.wo.weight.data = w[p+"wo.weight"]; b.wo.bias.data = w[p+"wo.bias"]
|
| 69 |
+
b.fc0.weight.data = w[p+"mlp.fc0.weight"]; b.fc0.bias.data = w[p+"mlp.fc0.bias"]
|
| 70 |
+
b.fc1.weight.data = w[p+"mlp.fc1.weight"]; b.fc1.bias.data = w[p+"mlp.fc1.bias"]
|
| 71 |
+
s.fln = nn.LayerNorm(D)
|
| 72 |
+
s.fln.weight.data = w["vision_model.encoder.final_layernorm.weight"]; s.fln.bias.data = w["vision_model.encoder.final_layernorm.bias"]
|
| 73 |
+
s.m0 = nn.LayerNorm(4 * D); s.m1 = nn.Linear(4 * D, 2048); s.m3 = nn.Linear(2048, 2048)
|
| 74 |
+
s.m0.weight.data = w["mlp1.0.weight"]; s.m0.bias.data = w["mlp1.0.bias"]
|
| 75 |
+
s.m1.weight.data = w["mlp1.1.weight"]; s.m1.bias.data = w["mlp1.1.bias"]
|
| 76 |
+
s.m3.weight.data = w["mlp1.3.weight"]; s.m3.bias.data = w["mlp1.3.bias"]
|
| 77 |
+
def forward(s, pixel): # (1,3,H,W), normalized with mean=std=0.5
|
| 78 |
+
x = s.proj(pixel).flatten(2).transpose(1, 2) + s.pos # (1,N,D), raster order
|
| 79 |
+
for b in s.blocks: x = b(x, s.cos, s.sin)
|
| 80 |
+
x = s.fln(x)
|
| 81 |
+
x = x.view(GH // 2, 2, GW // 2, 2, D).permute(0, 2, 1, 3, 4).reshape(1, (GH // 2) * (GW // 2), 4 * D)
|
| 82 |
+
x = s.m3(F.gelu(s.m1(s.m0(x))))
|
| 83 |
+
return x[0] # (N/4, 2048)
|
| 84 |
+
|
| 85 |
+
if __name__ == "__main__":
|
| 86 |
+
m = ViTFixed(load()).eval()
|
| 87 |
+
ref = torch.load("ref_vit.pt")
|
| 88 |
+
with torch.no_grad(): out = m(ref["pixel"])
|
| 89 |
+
r = ref["out"]
|
| 90 |
+
cos = F.cosine_similarity(out.flatten(), r.flatten(), dim=0).item()
|
| 91 |
+
print("shape", tuple(out.shape), "cos", round(cos, 6), "max|diff|", (out - r).abs().max().item(), "ref std", r.std().item())
|
| 92 |
+
if len(sys.argv) > 3 and sys.argv[3] == "export":
|
| 93 |
+
torch.onnx.export(m, ref["pixel"], f"out/vit_{GH*14}x{GW*14}.onnx", input_names=["pixel"], output_names=["embeds"], opset_version=17, do_constant_folding=True)
|
| 94 |
+
print("exported")
|