Add YOLOX Nano RKNN exports with upstream attribution
Browse files- .gitattributes +4 -0
- LICENSE +201 -0
- README.md +16 -0
- manifest.json +38 -0
- models/detect/yolox_nano/rk3576/fp16/metadata.yaml +90 -0
- models/detect/yolox_nano/rk3576/fp16/model.rknn +3 -0
- models/detect/yolox_nano/rk3576/int8/metadata.yaml +90 -0
- models/detect/yolox_nano/rk3576/int8/model.rknn +3 -0
- models/detect/yolox_nano/rk3588/fp16/metadata.yaml +90 -0
- models/detect/yolox_nano/rk3588/fp16/model.rknn +3 -0
- models/detect/yolox_nano/rk3588/int8/metadata.yaml +90 -0
- models/detect/yolox_nano/rk3588/int8/model.rknn +3 -0
- source/compile-yolox-nano.py +19 -0
- source/convert-official.py +194 -0
- source/yolox_nano.pth +3 -0
.gitattributes
CHANGED
|
@@ -33,3 +33,7 @@ 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 |
+
models/detect/yolox_nano/rk3576/fp16/model.rknn filter=lfs diff=lfs merge=lfs -text
|
| 37 |
+
models/detect/yolox_nano/rk3576/int8/model.rknn filter=lfs diff=lfs merge=lfs -text
|
| 38 |
+
models/detect/yolox_nano/rk3588/fp16/model.rknn filter=lfs diff=lfs merge=lfs -text
|
| 39 |
+
models/detect/yolox_nano/rk3588/int8/model.rknn filter=lfs diff=lfs merge=lfs -text
|
LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Apache License
|
| 2 |
+
Version 2.0, January 2004
|
| 3 |
+
http://www.apache.org/licenses/
|
| 4 |
+
|
| 5 |
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
| 6 |
+
|
| 7 |
+
1. Definitions.
|
| 8 |
+
|
| 9 |
+
"License" shall mean the terms and conditions for use, reproduction,
|
| 10 |
+
and distribution as defined by Sections 1 through 9 of this document.
|
| 11 |
+
|
| 12 |
+
"Licensor" shall mean the copyright owner or entity authorized by
|
| 13 |
+
the copyright owner that is granting the License.
|
| 14 |
+
|
| 15 |
+
"Legal Entity" shall mean the union of the acting entity and all
|
| 16 |
+
other entities that control, are controlled by, or are under common
|
| 17 |
+
control with that entity. For the purposes of this definition,
|
| 18 |
+
"control" means (i) the power, direct or indirect, to cause the
|
| 19 |
+
direction or management of such entity, whether by contract or
|
| 20 |
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
| 21 |
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
| 22 |
+
|
| 23 |
+
"You" (or "Your") shall mean an individual or Legal Entity
|
| 24 |
+
exercising permissions granted by this License.
|
| 25 |
+
|
| 26 |
+
"Source" form shall mean the preferred form for making modifications,
|
| 27 |
+
including but not limited to software source code, documentation
|
| 28 |
+
source, and configuration files.
|
| 29 |
+
|
| 30 |
+
"Object" form shall mean any form resulting from mechanical
|
| 31 |
+
transformation or translation of a Source form, including but
|
| 32 |
+
not limited to compiled object code, generated documentation,
|
| 33 |
+
and conversions to other media types.
|
| 34 |
+
|
| 35 |
+
"Work" shall mean the work of authorship, whether in Source or
|
| 36 |
+
Object form, made available under the License, as indicated by a
|
| 37 |
+
copyright notice that is included in or attached to the work
|
| 38 |
+
(an example is provided in the Appendix below).
|
| 39 |
+
|
| 40 |
+
"Derivative Works" shall mean any work, whether in Source or Object
|
| 41 |
+
form, that is based on (or derived from) the Work and for which the
|
| 42 |
+
editorial revisions, annotations, elaborations, or other modifications
|
| 43 |
+
represent, as a whole, an original work of authorship. For the purposes
|
| 44 |
+
of this License, Derivative Works shall not include works that remain
|
| 45 |
+
separable from, or merely link (or bind by name) to the interfaces of,
|
| 46 |
+
the Work and Derivative Works thereof.
|
| 47 |
+
|
| 48 |
+
"Contribution" shall mean any work of authorship, including
|
| 49 |
+
the original version of the Work and any modifications or additions
|
| 50 |
+
to that Work or Derivative Works thereof, that is intentionally
|
| 51 |
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
| 52 |
+
or by an individual or Legal Entity authorized to submit on behalf of
|
| 53 |
+
the copyright owner. For the purposes of this definition, "submitted"
|
| 54 |
+
means any form of electronic, verbal, or written communication sent
|
| 55 |
+
to the Licensor or its representatives, including but not limited to
|
| 56 |
+
communication on electronic mailing lists, source code control systems,
|
| 57 |
+
and issue tracking systems that are managed by, or on behalf of, the
|
| 58 |
+
Licensor for the purpose of discussing and improving the Work, but
|
| 59 |
+
excluding communication that is conspicuously marked or otherwise
|
| 60 |
+
designated in writing by the copyright owner as "Not a Contribution."
|
| 61 |
+
|
| 62 |
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
| 63 |
+
on behalf of whom a Contribution has been received by Licensor and
|
| 64 |
+
subsequently incorporated within the Work.
|
| 65 |
+
|
| 66 |
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
| 67 |
+
this License, each Contributor hereby grants to You a perpetual,
|
| 68 |
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
| 69 |
+
copyright license to reproduce, prepare Derivative Works of,
|
| 70 |
+
publicly display, publicly perform, sublicense, and distribute the
|
| 71 |
+
Work and such Derivative Works in Source or Object form.
|
| 72 |
+
|
| 73 |
+
3. Grant of Patent License. Subject to the terms and conditions of
|
| 74 |
+
this License, each Contributor hereby grants to You a perpetual,
|
| 75 |
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
| 76 |
+
(except as stated in this section) patent license to make, have made,
|
| 77 |
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
| 78 |
+
where such license applies only to those patent claims licensable
|
| 79 |
+
by such Contributor that are necessarily infringed by their
|
| 80 |
+
Contribution(s) alone or by combination of their Contribution(s)
|
| 81 |
+
with the Work to which such Contribution(s) was submitted. If You
|
| 82 |
+
institute patent litigation against any entity (including a
|
| 83 |
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
| 84 |
+
or a Contribution incorporated within the Work constitutes direct
|
| 85 |
+
or contributory patent infringement, then any patent licenses
|
| 86 |
+
granted to You under this License for that Work shall terminate
|
| 87 |
+
as of the date such litigation is filed.
|
| 88 |
+
|
| 89 |
+
4. Redistribution. You may reproduce and distribute copies of the
|
| 90 |
+
Work or Derivative Works thereof in any medium, with or without
|
| 91 |
+
modifications, and in Source or Object form, provided that You
|
| 92 |
+
meet the following conditions:
|
| 93 |
+
|
| 94 |
+
(a) You must give any other recipients of the Work or
|
| 95 |
+
Derivative Works a copy of this License; and
|
| 96 |
+
|
| 97 |
+
(b) You must cause any modified files to carry prominent notices
|
| 98 |
+
stating that You changed the files; and
|
| 99 |
+
|
| 100 |
+
(c) You must retain, in the Source form of any Derivative Works
|
| 101 |
+
that You distribute, all copyright, patent, trademark, and
|
| 102 |
+
attribution notices from the Source form of the Work,
|
| 103 |
+
excluding those notices that do not pertain to any part of
|
| 104 |
+
the Derivative Works; and
|
| 105 |
+
|
| 106 |
+
(d) If the Work includes a "NOTICE" text file as part of its
|
| 107 |
+
distribution, then any Derivative Works that You distribute must
|
| 108 |
+
include a readable copy of the attribution notices contained
|
| 109 |
+
within such NOTICE file, excluding those notices that do not
|
| 110 |
+
pertain to any part of the Derivative Works, in at least one
|
| 111 |
+
of the following places: within a NOTICE text file distributed
|
| 112 |
+
as part of the Derivative Works; within the Source form or
|
| 113 |
+
documentation, if provided along with the Derivative Works; or,
|
| 114 |
+
within a display generated by the Derivative Works, if and
|
| 115 |
+
wherever such third-party notices normally appear. The contents
|
| 116 |
+
of the NOTICE file are for informational purposes only and
|
| 117 |
+
do not modify the License. You may add Your own attribution
|
| 118 |
+
notices within Derivative Works that You distribute, alongside
|
| 119 |
+
or as an addendum to the NOTICE text from the Work, provided
|
| 120 |
+
that such additional attribution notices cannot be construed
|
| 121 |
+
as modifying the License.
|
| 122 |
+
|
| 123 |
+
You may add Your own copyright statement to Your modifications and
|
| 124 |
+
may provide additional or different license terms and conditions
|
| 125 |
+
for use, reproduction, or distribution of Your modifications, or
|
| 126 |
+
for any such Derivative Works as a whole, provided Your use,
|
| 127 |
+
reproduction, and distribution of the Work otherwise complies with
|
| 128 |
+
the conditions stated in this License.
|
| 129 |
+
|
| 130 |
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
| 131 |
+
any Contribution intentionally submitted for inclusion in the Work
|
| 132 |
+
by You to the Licensor shall be under the terms and conditions of
|
| 133 |
+
this License, without any additional terms or conditions.
|
| 134 |
+
Notwithstanding the above, nothing herein shall supersede or modify
|
| 135 |
+
the terms of any separate license agreement you may have executed
|
| 136 |
+
with Licensor regarding such Contributions.
|
| 137 |
+
|
| 138 |
+
6. Trademarks. This License does not grant permission to use the trade
|
| 139 |
+
names, trademarks, service marks, or product names of the Licensor,
|
| 140 |
+
except as required for reasonable and customary use in describing the
|
| 141 |
+
origin of the Work and reproducing the content of the NOTICE file.
|
| 142 |
+
|
| 143 |
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
| 144 |
+
agreed to in writing, Licensor provides the Work (and each
|
| 145 |
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
| 146 |
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
| 147 |
+
implied, including, without limitation, any warranties or conditions
|
| 148 |
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
| 149 |
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
| 150 |
+
appropriateness of using or redistributing the Work and assume any
|
| 151 |
+
risks associated with Your exercise of permissions under this License.
|
| 152 |
+
|
| 153 |
+
8. Limitation of Liability. In no event and under no legal theory,
|
| 154 |
+
whether in tort (including negligence), contract, or otherwise,
|
| 155 |
+
unless required by applicable law (such as deliberate and grossly
|
| 156 |
+
negligent acts) or agreed to in writing, shall any Contributor be
|
| 157 |
+
liable to You for damages, including any direct, indirect, special,
|
| 158 |
+
incidental, or consequential damages of any character arising as a
|
| 159 |
+
result of this License or out of the use or inability to use the
|
| 160 |
+
Work (including but not limited to damages for loss of goodwill,
|
| 161 |
+
work stoppage, computer failure or malfunction, or any and all
|
| 162 |
+
other commercial damages or losses), even if such Contributor
|
| 163 |
+
has been advised of the possibility of such damages.
|
| 164 |
+
|
| 165 |
+
9. Accepting Warranty or Additional Liability. While redistributing
|
| 166 |
+
the Work or Derivative Works thereof, You may choose to offer,
|
| 167 |
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
| 168 |
+
or other liability obligations and/or rights consistent with this
|
| 169 |
+
License. However, in accepting such obligations, You may act only
|
| 170 |
+
on Your own behalf and on Your sole responsibility, not on behalf
|
| 171 |
+
of any other Contributor, and only if You agree to indemnify,
|
| 172 |
+
defend, and hold each Contributor harmless for any liability
|
| 173 |
+
incurred by, or claims asserted against, such Contributor by reason
|
| 174 |
+
of your accepting any such warranty or additional liability.
|
| 175 |
+
|
| 176 |
+
END OF TERMS AND CONDITIONS
|
| 177 |
+
|
| 178 |
+
APPENDIX: How to apply the Apache License to your work.
|
| 179 |
+
|
| 180 |
+
To apply the Apache License to your work, attach the following
|
| 181 |
+
boilerplate notice, with the fields enclosed by brackets "{}"
|
| 182 |
+
replaced with your own identifying information. (Don't include
|
| 183 |
+
the brackets!) The text should be enclosed in the appropriate
|
| 184 |
+
comment syntax for the file format. We also recommend that a
|
| 185 |
+
file or class name and description of purpose be included on the
|
| 186 |
+
same "printed page" as the copyright notice for easier
|
| 187 |
+
identification within third-party archives.
|
| 188 |
+
|
| 189 |
+
Copyright (c) 2021-2022 Megvii Inc. All rights reserved.
|
| 190 |
+
|
| 191 |
+
Licensed under the Apache License, Version 2.0 (the "License");
|
| 192 |
+
you may not use this file except in compliance with the License.
|
| 193 |
+
You may obtain a copy of the License at
|
| 194 |
+
|
| 195 |
+
http://www.apache.org/licenses/LICENSE-2.0
|
| 196 |
+
|
| 197 |
+
Unless required by applicable law or agreed to in writing, software
|
| 198 |
+
distributed under the License is distributed on an "AS IS" BASIS,
|
| 199 |
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 200 |
+
See the License for the specific language governing permissions and
|
| 201 |
+
limitations under the License.
|
README.md
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
pipeline_tag: object-detection
|
| 4 |
+
tags:
|
| 5 |
+
- rknn
|
| 6 |
+
- rockchip
|
| 7 |
+
- yolox
|
| 8 |
+
---
|
| 9 |
+
|
| 10 |
+
# YOLOX Nano RKNN exports
|
| 11 |
+
|
| 12 |
+
YOLOX Nano FP16 and INT8 models for RK3576 and RK3588. Download `model.rknn` and `metadata.yaml` from the same directory under `models/detect/yolox_nano/<chip>/<precision>/`. The [manifest](manifest.json) records each model hash.
|
| 13 |
+
|
| 14 |
+
The [original YOLOX Nano checkpoint](https://github.com/Megvii-BaseDetection/YOLOX/releases/download/0.1.1rc0/yolox_nano.pth) is included under [source](tree/main/source). It was exported to ONNX with the [Rockchip YOLOX exporter](https://github.com/airockchip/YOLOX/tree/fc69c1e2ccb30fce7e18250bddc13a68090dca09) and compiled with the [Model Zoo YOLOX converter](https://github.com/airockchip/rknn_model_zoo/tree/837db8e992815ff8647eadb709f07067f4bc3a71/examples/yolox) using RKNN Toolkit2 2.3.2. The conversion changed the model format and quantized the INT8 variant.
|
| 15 |
+
|
| 16 |
+
YOLOX is from [Megvii-BaseDetection](https://github.com/Megvii-BaseDetection/YOLOX). The [Apache-2.0 license](LICENSE) applies to this distribution.
|
manifest.json
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[
|
| 2 |
+
{
|
| 3 |
+
"path": "models/detect/yolox_nano/rk3576/fp16",
|
| 4 |
+
"chip": "rk3576",
|
| 5 |
+
"precision": "fp16",
|
| 6 |
+
"onnx_sha256": "8f2c3337598150e82b4e4b4d3d1a20c1c4a56e9e0df0623ce95e330683aac309",
|
| 7 |
+
"sha256": "401a93a450699a3f3bdb1198c88598f05e8256685cb977ba4edbe956e749353c",
|
| 8 |
+
"toolkit_version": "2.5.0",
|
| 9 |
+
"zoo_commit": "837db8e992815ff8647eadb709f07067f4bc3a71"
|
| 10 |
+
},
|
| 11 |
+
{
|
| 12 |
+
"path": "models/detect/yolox_nano/rk3576/int8",
|
| 13 |
+
"chip": "rk3576",
|
| 14 |
+
"precision": "int8",
|
| 15 |
+
"onnx_sha256": "8f2c3337598150e82b4e4b4d3d1a20c1c4a56e9e0df0623ce95e330683aac309",
|
| 16 |
+
"sha256": "da807d26a734b46df2e51ab2d6b2629c04d5a92688b7ef4f6c63723221f6102f",
|
| 17 |
+
"toolkit_version": "2.5.0",
|
| 18 |
+
"zoo_commit": "837db8e992815ff8647eadb709f07067f4bc3a71"
|
| 19 |
+
},
|
| 20 |
+
{
|
| 21 |
+
"path": "models/detect/yolox_nano/rk3588/fp16",
|
| 22 |
+
"chip": "rk3588",
|
| 23 |
+
"precision": "fp16",
|
| 24 |
+
"onnx_sha256": "8f2c3337598150e82b4e4b4d3d1a20c1c4a56e9e0df0623ce95e330683aac309",
|
| 25 |
+
"sha256": "2323bc2ad1b1087f2f7abc8b51745cbe1170965bc81b2567819558b90ae4ef27",
|
| 26 |
+
"toolkit_version": "2.5.0",
|
| 27 |
+
"zoo_commit": "837db8e992815ff8647eadb709f07067f4bc3a71"
|
| 28 |
+
},
|
| 29 |
+
{
|
| 30 |
+
"path": "models/detect/yolox_nano/rk3588/int8",
|
| 31 |
+
"chip": "rk3588",
|
| 32 |
+
"precision": "int8",
|
| 33 |
+
"onnx_sha256": "8f2c3337598150e82b4e4b4d3d1a20c1c4a56e9e0df0623ce95e330683aac309",
|
| 34 |
+
"sha256": "4c5cc4cd4d45b60a63d5d65d6731c3465955d11d16d2dbc03427ff63b73d4036",
|
| 35 |
+
"toolkit_version": "2.5.0",
|
| 36 |
+
"zoo_commit": "837db8e992815ff8647eadb709f07067f4bc3a71"
|
| 37 |
+
}
|
| 38 |
+
]
|
models/detect/yolox_nano/rk3576/fp16/metadata.yaml
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
task: detect
|
| 2 |
+
batch: 1
|
| 3 |
+
channels: 3
|
| 4 |
+
imgsz:
|
| 5 |
+
- 416
|
| 6 |
+
- 416
|
| 7 |
+
names:
|
| 8 |
+
- person
|
| 9 |
+
- bicycle
|
| 10 |
+
- car
|
| 11 |
+
- motorcycle
|
| 12 |
+
- airplane
|
| 13 |
+
- bus
|
| 14 |
+
- train
|
| 15 |
+
- truck
|
| 16 |
+
- boat
|
| 17 |
+
- traffic light
|
| 18 |
+
- fire hydrant
|
| 19 |
+
- stop sign
|
| 20 |
+
- parking meter
|
| 21 |
+
- bench
|
| 22 |
+
- bird
|
| 23 |
+
- cat
|
| 24 |
+
- dog
|
| 25 |
+
- horse
|
| 26 |
+
- sheep
|
| 27 |
+
- cow
|
| 28 |
+
- elephant
|
| 29 |
+
- bear
|
| 30 |
+
- zebra
|
| 31 |
+
- giraffe
|
| 32 |
+
- backpack
|
| 33 |
+
- umbrella
|
| 34 |
+
- handbag
|
| 35 |
+
- tie
|
| 36 |
+
- suitcase
|
| 37 |
+
- frisbee
|
| 38 |
+
- skis
|
| 39 |
+
- snowboard
|
| 40 |
+
- sports ball
|
| 41 |
+
- kite
|
| 42 |
+
- baseball bat
|
| 43 |
+
- baseball glove
|
| 44 |
+
- skateboard
|
| 45 |
+
- surfboard
|
| 46 |
+
- tennis racket
|
| 47 |
+
- bottle
|
| 48 |
+
- wine glass
|
| 49 |
+
- cup
|
| 50 |
+
- fork
|
| 51 |
+
- knife
|
| 52 |
+
- spoon
|
| 53 |
+
- bowl
|
| 54 |
+
- banana
|
| 55 |
+
- apple
|
| 56 |
+
- sandwich
|
| 57 |
+
- orange
|
| 58 |
+
- broccoli
|
| 59 |
+
- carrot
|
| 60 |
+
- hot dog
|
| 61 |
+
- pizza
|
| 62 |
+
- donut
|
| 63 |
+
- cake
|
| 64 |
+
- chair
|
| 65 |
+
- couch
|
| 66 |
+
- potted plant
|
| 67 |
+
- bed
|
| 68 |
+
- dining table
|
| 69 |
+
- toilet
|
| 70 |
+
- tv
|
| 71 |
+
- laptop
|
| 72 |
+
- mouse
|
| 73 |
+
- remote
|
| 74 |
+
- keyboard
|
| 75 |
+
- cell phone
|
| 76 |
+
- microwave
|
| 77 |
+
- oven
|
| 78 |
+
- toaster
|
| 79 |
+
- sink
|
| 80 |
+
- refrigerator
|
| 81 |
+
- book
|
| 82 |
+
- clock
|
| 83 |
+
- vase
|
| 84 |
+
- scissors
|
| 85 |
+
- teddy bear
|
| 86 |
+
- hair drier
|
| 87 |
+
- toothbrush
|
| 88 |
+
target_platform: rk3576
|
| 89 |
+
coordinates: pixels
|
| 90 |
+
head: yolox
|
models/detect/yolox_nano/rk3576/fp16/model.rknn
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:401a93a450699a3f3bdb1198c88598f05e8256685cb977ba4edbe956e749353c
|
| 3 |
+
size 7281670
|
models/detect/yolox_nano/rk3576/int8/metadata.yaml
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
task: detect
|
| 2 |
+
batch: 1
|
| 3 |
+
channels: 3
|
| 4 |
+
imgsz:
|
| 5 |
+
- 416
|
| 6 |
+
- 416
|
| 7 |
+
names:
|
| 8 |
+
- person
|
| 9 |
+
- bicycle
|
| 10 |
+
- car
|
| 11 |
+
- motorcycle
|
| 12 |
+
- airplane
|
| 13 |
+
- bus
|
| 14 |
+
- train
|
| 15 |
+
- truck
|
| 16 |
+
- boat
|
| 17 |
+
- traffic light
|
| 18 |
+
- fire hydrant
|
| 19 |
+
- stop sign
|
| 20 |
+
- parking meter
|
| 21 |
+
- bench
|
| 22 |
+
- bird
|
| 23 |
+
- cat
|
| 24 |
+
- dog
|
| 25 |
+
- horse
|
| 26 |
+
- sheep
|
| 27 |
+
- cow
|
| 28 |
+
- elephant
|
| 29 |
+
- bear
|
| 30 |
+
- zebra
|
| 31 |
+
- giraffe
|
| 32 |
+
- backpack
|
| 33 |
+
- umbrella
|
| 34 |
+
- handbag
|
| 35 |
+
- tie
|
| 36 |
+
- suitcase
|
| 37 |
+
- frisbee
|
| 38 |
+
- skis
|
| 39 |
+
- snowboard
|
| 40 |
+
- sports ball
|
| 41 |
+
- kite
|
| 42 |
+
- baseball bat
|
| 43 |
+
- baseball glove
|
| 44 |
+
- skateboard
|
| 45 |
+
- surfboard
|
| 46 |
+
- tennis racket
|
| 47 |
+
- bottle
|
| 48 |
+
- wine glass
|
| 49 |
+
- cup
|
| 50 |
+
- fork
|
| 51 |
+
- knife
|
| 52 |
+
- spoon
|
| 53 |
+
- bowl
|
| 54 |
+
- banana
|
| 55 |
+
- apple
|
| 56 |
+
- sandwich
|
| 57 |
+
- orange
|
| 58 |
+
- broccoli
|
| 59 |
+
- carrot
|
| 60 |
+
- hot dog
|
| 61 |
+
- pizza
|
| 62 |
+
- donut
|
| 63 |
+
- cake
|
| 64 |
+
- chair
|
| 65 |
+
- couch
|
| 66 |
+
- potted plant
|
| 67 |
+
- bed
|
| 68 |
+
- dining table
|
| 69 |
+
- toilet
|
| 70 |
+
- tv
|
| 71 |
+
- laptop
|
| 72 |
+
- mouse
|
| 73 |
+
- remote
|
| 74 |
+
- keyboard
|
| 75 |
+
- cell phone
|
| 76 |
+
- microwave
|
| 77 |
+
- oven
|
| 78 |
+
- toaster
|
| 79 |
+
- sink
|
| 80 |
+
- refrigerator
|
| 81 |
+
- book
|
| 82 |
+
- clock
|
| 83 |
+
- vase
|
| 84 |
+
- scissors
|
| 85 |
+
- teddy bear
|
| 86 |
+
- hair drier
|
| 87 |
+
- toothbrush
|
| 88 |
+
target_platform: rk3576
|
| 89 |
+
coordinates: pixels
|
| 90 |
+
head: yolox
|
models/detect/yolox_nano/rk3576/int8/model.rknn
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:da807d26a734b46df2e51ab2d6b2629c04d5a92688b7ef4f6c63723221f6102f
|
| 3 |
+
size 6474682
|
models/detect/yolox_nano/rk3588/fp16/metadata.yaml
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
task: detect
|
| 2 |
+
batch: 1
|
| 3 |
+
channels: 3
|
| 4 |
+
imgsz:
|
| 5 |
+
- 416
|
| 6 |
+
- 416
|
| 7 |
+
names:
|
| 8 |
+
- person
|
| 9 |
+
- bicycle
|
| 10 |
+
- car
|
| 11 |
+
- motorcycle
|
| 12 |
+
- airplane
|
| 13 |
+
- bus
|
| 14 |
+
- train
|
| 15 |
+
- truck
|
| 16 |
+
- boat
|
| 17 |
+
- traffic light
|
| 18 |
+
- fire hydrant
|
| 19 |
+
- stop sign
|
| 20 |
+
- parking meter
|
| 21 |
+
- bench
|
| 22 |
+
- bird
|
| 23 |
+
- cat
|
| 24 |
+
- dog
|
| 25 |
+
- horse
|
| 26 |
+
- sheep
|
| 27 |
+
- cow
|
| 28 |
+
- elephant
|
| 29 |
+
- bear
|
| 30 |
+
- zebra
|
| 31 |
+
- giraffe
|
| 32 |
+
- backpack
|
| 33 |
+
- umbrella
|
| 34 |
+
- handbag
|
| 35 |
+
- tie
|
| 36 |
+
- suitcase
|
| 37 |
+
- frisbee
|
| 38 |
+
- skis
|
| 39 |
+
- snowboard
|
| 40 |
+
- sports ball
|
| 41 |
+
- kite
|
| 42 |
+
- baseball bat
|
| 43 |
+
- baseball glove
|
| 44 |
+
- skateboard
|
| 45 |
+
- surfboard
|
| 46 |
+
- tennis racket
|
| 47 |
+
- bottle
|
| 48 |
+
- wine glass
|
| 49 |
+
- cup
|
| 50 |
+
- fork
|
| 51 |
+
- knife
|
| 52 |
+
- spoon
|
| 53 |
+
- bowl
|
| 54 |
+
- banana
|
| 55 |
+
- apple
|
| 56 |
+
- sandwich
|
| 57 |
+
- orange
|
| 58 |
+
- broccoli
|
| 59 |
+
- carrot
|
| 60 |
+
- hot dog
|
| 61 |
+
- pizza
|
| 62 |
+
- donut
|
| 63 |
+
- cake
|
| 64 |
+
- chair
|
| 65 |
+
- couch
|
| 66 |
+
- potted plant
|
| 67 |
+
- bed
|
| 68 |
+
- dining table
|
| 69 |
+
- toilet
|
| 70 |
+
- tv
|
| 71 |
+
- laptop
|
| 72 |
+
- mouse
|
| 73 |
+
- remote
|
| 74 |
+
- keyboard
|
| 75 |
+
- cell phone
|
| 76 |
+
- microwave
|
| 77 |
+
- oven
|
| 78 |
+
- toaster
|
| 79 |
+
- sink
|
| 80 |
+
- refrigerator
|
| 81 |
+
- book
|
| 82 |
+
- clock
|
| 83 |
+
- vase
|
| 84 |
+
- scissors
|
| 85 |
+
- teddy bear
|
| 86 |
+
- hair drier
|
| 87 |
+
- toothbrush
|
| 88 |
+
target_platform: rk3588
|
| 89 |
+
coordinates: pixels
|
| 90 |
+
head: yolox
|
models/detect/yolox_nano/rk3588/fp16/model.rknn
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:2323bc2ad1b1087f2f7abc8b51745cbe1170965bc81b2567819558b90ae4ef27
|
| 3 |
+
size 3656902
|
models/detect/yolox_nano/rk3588/int8/metadata.yaml
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
task: detect
|
| 2 |
+
batch: 1
|
| 3 |
+
channels: 3
|
| 4 |
+
imgsz:
|
| 5 |
+
- 416
|
| 6 |
+
- 416
|
| 7 |
+
names:
|
| 8 |
+
- person
|
| 9 |
+
- bicycle
|
| 10 |
+
- car
|
| 11 |
+
- motorcycle
|
| 12 |
+
- airplane
|
| 13 |
+
- bus
|
| 14 |
+
- train
|
| 15 |
+
- truck
|
| 16 |
+
- boat
|
| 17 |
+
- traffic light
|
| 18 |
+
- fire hydrant
|
| 19 |
+
- stop sign
|
| 20 |
+
- parking meter
|
| 21 |
+
- bench
|
| 22 |
+
- bird
|
| 23 |
+
- cat
|
| 24 |
+
- dog
|
| 25 |
+
- horse
|
| 26 |
+
- sheep
|
| 27 |
+
- cow
|
| 28 |
+
- elephant
|
| 29 |
+
- bear
|
| 30 |
+
- zebra
|
| 31 |
+
- giraffe
|
| 32 |
+
- backpack
|
| 33 |
+
- umbrella
|
| 34 |
+
- handbag
|
| 35 |
+
- tie
|
| 36 |
+
- suitcase
|
| 37 |
+
- frisbee
|
| 38 |
+
- skis
|
| 39 |
+
- snowboard
|
| 40 |
+
- sports ball
|
| 41 |
+
- kite
|
| 42 |
+
- baseball bat
|
| 43 |
+
- baseball glove
|
| 44 |
+
- skateboard
|
| 45 |
+
- surfboard
|
| 46 |
+
- tennis racket
|
| 47 |
+
- bottle
|
| 48 |
+
- wine glass
|
| 49 |
+
- cup
|
| 50 |
+
- fork
|
| 51 |
+
- knife
|
| 52 |
+
- spoon
|
| 53 |
+
- bowl
|
| 54 |
+
- banana
|
| 55 |
+
- apple
|
| 56 |
+
- sandwich
|
| 57 |
+
- orange
|
| 58 |
+
- broccoli
|
| 59 |
+
- carrot
|
| 60 |
+
- hot dog
|
| 61 |
+
- pizza
|
| 62 |
+
- donut
|
| 63 |
+
- cake
|
| 64 |
+
- chair
|
| 65 |
+
- couch
|
| 66 |
+
- potted plant
|
| 67 |
+
- bed
|
| 68 |
+
- dining table
|
| 69 |
+
- toilet
|
| 70 |
+
- tv
|
| 71 |
+
- laptop
|
| 72 |
+
- mouse
|
| 73 |
+
- remote
|
| 74 |
+
- keyboard
|
| 75 |
+
- cell phone
|
| 76 |
+
- microwave
|
| 77 |
+
- oven
|
| 78 |
+
- toaster
|
| 79 |
+
- sink
|
| 80 |
+
- refrigerator
|
| 81 |
+
- book
|
| 82 |
+
- clock
|
| 83 |
+
- vase
|
| 84 |
+
- scissors
|
| 85 |
+
- teddy bear
|
| 86 |
+
- hair drier
|
| 87 |
+
- toothbrush
|
| 88 |
+
target_platform: rk3588
|
| 89 |
+
coordinates: pixels
|
| 90 |
+
head: yolox
|
models/detect/yolox_nano/rk3588/int8/model.rknn
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:4c5cc4cd4d45b60a63d5d65d6731c3465955d11d16d2dbc03427ff63b73d4036
|
| 3 |
+
size 2655162
|
source/compile-yolox-nano.py
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Compile the Rockchip-exported YOLOX Nano graph with the Model Zoo recipe."""
|
| 2 |
+
import argparse
|
| 3 |
+
from concurrent.futures import ThreadPoolExecutor
|
| 4 |
+
from pathlib import Path
|
| 5 |
+
import runpy
|
| 6 |
+
|
| 7 |
+
parser = argparse.ArgumentParser(description=__doc__)
|
| 8 |
+
parser.add_argument("--zoo", type=Path, required=True)
|
| 9 |
+
args = parser.parse_args()
|
| 10 |
+
root = Path(__file__).resolve().parent
|
| 11 |
+
official = runpy.run_path(str(root.parent.parent / "convert-official.py"))
|
| 12 |
+
source = "https://github.com/airockchip/YOLOX/blob/main/README_rkopt.md"
|
| 13 |
+
model = root / "onnx/yolox/yolox_nano.onnx"
|
| 14 |
+
asset = ("yolox", "yolox_nano", model, source)
|
| 15 |
+
with ThreadPoolExecutor(4) as pool:
|
| 16 |
+
jobs = [pool.submit(official["convert"], root, args.zoo.resolve(), asset, chip, precision)
|
| 17 |
+
for chip in ("rk3576", "rk3588") for precision in ("fp", "i8")]
|
| 18 |
+
for job in jobs:
|
| 19 |
+
print(job.result(), flush=True)
|
source/convert-official.py
ADDED
|
@@ -0,0 +1,194 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""Download the ONNX listed by Rockchip and invoke its unmodified converters."""
|
| 3 |
+
import argparse
|
| 4 |
+
import concurrent.futures
|
| 5 |
+
import hashlib
|
| 6 |
+
from importlib.metadata import version
|
| 7 |
+
import json
|
| 8 |
+
from pathlib import Path
|
| 9 |
+
import re
|
| 10 |
+
import shutil
|
| 11 |
+
import subprocess
|
| 12 |
+
import sys
|
| 13 |
+
import tempfile
|
| 14 |
+
import yaml
|
| 15 |
+
|
| 16 |
+
DETECTORS = ("yolov5", "yolov6", "yolov7", "yolov8", "yolov10", "yolo11",
|
| 17 |
+
"yolo26", "yolox", "ppyoloe", "yolo_world")
|
| 18 |
+
TASKS = ("yolov5_seg", "yolov8_seg", "yolov8_pose", "yolov8_obb")
|
| 19 |
+
SUPPLIED_ONNX = {
|
| 20 |
+
"yolo26n": "https://meta.zbox.filez.com/v/link/view/dddfdaa76107404a8a358673fa31a041",
|
| 21 |
+
"yolo26m": "https://meta.zbox.filez.com/v/link/view/198e90ee6bc94c71ad2002d5f9897ac4",
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
def inventory(zoo):
|
| 26 |
+
for family in (*DETECTORS, *TASKS):
|
| 27 |
+
readme = zoo / "examples" / family / "README.md"
|
| 28 |
+
urls = re.findall(r"\((https://[^)]+\.onnx)\)", readme.read_text())
|
| 29 |
+
assets = {Path(url).stem: url for url in urls}
|
| 30 |
+
if family in ("yolov8_pose", "yolov8_obb"):
|
| 31 |
+
assets = {name: url for name, url in assets.items() if "v5n-" in name or "v8n-" in name}
|
| 32 |
+
if family == "yolo26":
|
| 33 |
+
assets.update({"yolo26n": None, "yolo26m": None})
|
| 34 |
+
for name, url in assets.items():
|
| 35 |
+
yield family, name, url
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
def download(root, zoo, family, name, url):
|
| 39 |
+
destination = root / "onnx" / family / f"{name}.onnx"
|
| 40 |
+
destination.parent.mkdir(parents=True, exist_ok=True)
|
| 41 |
+
if not destination.is_file():
|
| 42 |
+
local = zoo / "examples" / family / "model" / destination.name
|
| 43 |
+
if not url and local.is_file():
|
| 44 |
+
shutil.copy2(local, destination)
|
| 45 |
+
elif url:
|
| 46 |
+
partial = destination.with_suffix(".part")
|
| 47 |
+
subprocess.run(["curl", "-fLsS", "--retry", "2", "--connect-timeout", "12",
|
| 48 |
+
"--max-time", "180", "-o", partial, url], check=True)
|
| 49 |
+
partial.replace(destination)
|
| 50 |
+
else:
|
| 51 |
+
raise FileNotFoundError(
|
| 52 |
+
f"Download {SUPPLIED_ONNX[name]} and save its ONNX as {destination}")
|
| 53 |
+
import onnx
|
| 54 |
+
onnx.load(str(destination), load_external_data=False)
|
| 55 |
+
return destination
|
| 56 |
+
|
| 57 |
+
|
| 58 |
+
def digest(path):
|
| 59 |
+
checksum = hashlib.sha256()
|
| 60 |
+
with path.open("rb") as stream:
|
| 61 |
+
for block in iter(lambda: stream.read(1024 * 1024), b""):
|
| 62 |
+
checksum.update(block)
|
| 63 |
+
return checksum.hexdigest()
|
| 64 |
+
|
| 65 |
+
|
| 66 |
+
def write_metadata(zoo, family, model, destination, chip):
|
| 67 |
+
if family == "yolo_world":
|
| 68 |
+
return
|
| 69 |
+
import onnx
|
| 70 |
+
inputs = onnx.load(str(model), load_external_data=False).graph.input
|
| 71 |
+
shape = [dim.dim_value for dim in inputs[0].type.tensor_type.shape.dim]
|
| 72 |
+
if len(shape) != 4 or shape[:2] != [1, 3] or min(shape[2:]) <= 0:
|
| 73 |
+
raise RuntimeError(f"Expected static NCHW RGB model, got {shape}")
|
| 74 |
+
assets = zoo / "examples" / family / "model"
|
| 75 |
+
labels = next(assets.glob("*labels_list.txt"))
|
| 76 |
+
tasks = {"yolov5_seg": "segment", "yolov8_seg": "segment",
|
| 77 |
+
"yolov8_pose": "pose", "yolov8_obb": "obb"}
|
| 78 |
+
task = tasks.get(family, "detect")
|
| 79 |
+
info = {
|
| 80 |
+
"task": task, "batch": 1, "channels": 3, "imgsz": shape[2:],
|
| 81 |
+
"names": [line.strip() for line in labels.read_text().splitlines() if line.strip()],
|
| 82 |
+
"target_platform": chip,
|
| 83 |
+
"coordinates": "pixels",
|
| 84 |
+
}
|
| 85 |
+
if family in ("yolov5", "yolov5_seg", "yolov7"):
|
| 86 |
+
values = [float(value) for value in next(assets.glob("anchors_*.txt")).read_text().split()]
|
| 87 |
+
info.update(head="anchored", anchors=[values[i:i + 6] for i in range(0, len(values), 6)])
|
| 88 |
+
if family == "yolox":
|
| 89 |
+
info["head"] = "yolox"
|
| 90 |
+
if family in ("yolov10", "yolo26"):
|
| 91 |
+
info["end2end"] = True
|
| 92 |
+
if task == "pose":
|
| 93 |
+
info["kpt_shape"] = [17, 3]
|
| 94 |
+
(destination / "metadata.yaml").write_text(yaml.safe_dump(info, sort_keys=False))
|
| 95 |
+
|
| 96 |
+
|
| 97 |
+
def convert(root, zoo, asset, chip, precision, refresh_metadata=False):
|
| 98 |
+
family, name, model, source = asset
|
| 99 |
+
destination = root / "rknn" / chip / family / name / precision
|
| 100 |
+
destination.mkdir(parents=True, exist_ok=True)
|
| 101 |
+
output = destination / "model.rknn"
|
| 102 |
+
receipt = destination / "conversion.json"
|
| 103 |
+
if not refresh_metadata and output.is_file() and receipt.is_file() and (
|
| 104 |
+
family == "yolo_world" or (destination / "metadata.yaml").is_file()):
|
| 105 |
+
return f"cached {family}/{name} {chip} {precision}"
|
| 106 |
+
work_root = root / "scratch"
|
| 107 |
+
work_root.mkdir(exist_ok=True)
|
| 108 |
+
with tempfile.TemporaryDirectory(dir=work_root, prefix=f"{name}-{chip}-{precision}-") as scratch:
|
| 109 |
+
# Keep the relative dataset and model paths expected by the official scripts.
|
| 110 |
+
tree = Path(scratch)
|
| 111 |
+
(tree / "datasets").symlink_to(zoo / "datasets")
|
| 112 |
+
example = tree / "examples" / family
|
| 113 |
+
example.mkdir(parents=True)
|
| 114 |
+
(example / "model").symlink_to(zoo / "examples" / family / "model")
|
| 115 |
+
working = example / "python"
|
| 116 |
+
shutil.copytree(zoo / "examples" / family / "python", working)
|
| 117 |
+
staged = destination / "model.partial.rknn"
|
| 118 |
+
commands = []
|
| 119 |
+
if family == "yolo_world":
|
| 120 |
+
subdir = "clip_text" if name == "clip_text" else "yolo_world"
|
| 121 |
+
script = f"{subdir}/convert.py"
|
| 122 |
+
commands.append([script, str(model), chip, precision, str(staged)])
|
| 123 |
+
elif family == "yolov8_pose":
|
| 124 |
+
if precision == "i8":
|
| 125 |
+
commands.append(["convert.py", str(model), chip, "i8", "1"])
|
| 126 |
+
commands.append(["convert.py", str(model), chip, "i8", "2", str(staged)])
|
| 127 |
+
else:
|
| 128 |
+
commands.append(["convert.py", str(model), chip, "fp", "1", str(staged)])
|
| 129 |
+
else:
|
| 130 |
+
commands.append(["convert.py", str(model), chip, precision, str(staged)])
|
| 131 |
+
if not output.is_file():
|
| 132 |
+
with (destination / "convert.log").open("w") as log:
|
| 133 |
+
for command in commands:
|
| 134 |
+
print(subprocess.list2cmdline(command), file=log, flush=True)
|
| 135 |
+
subprocess.run([sys.executable, *command], cwd=working,
|
| 136 |
+
stdout=log, stderr=subprocess.STDOUT, check=True)
|
| 137 |
+
if not staged.is_file() or not staged.stat().st_size:
|
| 138 |
+
raise RuntimeError("Converter did not produce an RKNN file")
|
| 139 |
+
staged.replace(output)
|
| 140 |
+
write_metadata(zoo, family, model, destination, chip)
|
| 141 |
+
receipt.write_text(json.dumps({
|
| 142 |
+
"source": source, "onnx_sha256": digest(model), "rknn_sha256": digest(output),
|
| 143 |
+
"commands": commands, "toolkit_python": sys.executable,
|
| 144 |
+
"toolkit_version": version("rknn-toolkit2"),
|
| 145 |
+
"zoo_commit": subprocess.check_output(
|
| 146 |
+
["git", "-C", str(zoo), "rev-parse", "HEAD"], text=True).strip(),
|
| 147 |
+
}, indent=2) + "\n")
|
| 148 |
+
return f"ok {family}/{name} {chip} {precision}"
|
| 149 |
+
|
| 150 |
+
|
| 151 |
+
def main():
|
| 152 |
+
parser = argparse.ArgumentParser(description=__doc__)
|
| 153 |
+
root = Path(__file__).resolve().parent
|
| 154 |
+
parser.add_argument("--zoo", type=Path, default=root.parent / "rknn_model_zoo",
|
| 155 |
+
help="Model Zoo checkout (default: ../rknn_model_zoo)")
|
| 156 |
+
parser.add_argument("--jobs", type=int, default=4)
|
| 157 |
+
parser.add_argument("--model", action="append", help="Limit the run to named variants")
|
| 158 |
+
parser.add_argument("--chip", choices=("rk3576", "rk3588"), action="append")
|
| 159 |
+
parser.add_argument("--precision", choices=("i8", "fp"), action="append")
|
| 160 |
+
parser.add_argument("--refresh-metadata", action="store_true")
|
| 161 |
+
args = parser.parse_args()
|
| 162 |
+
zoo = args.zoo.resolve()
|
| 163 |
+
inventory_rows = [item for item in inventory(zoo) if not args.model or item[1] in args.model]
|
| 164 |
+
failures = 0
|
| 165 |
+
with concurrent.futures.ThreadPoolExecutor(max_workers=6) as downloads, \
|
| 166 |
+
concurrent.futures.ThreadPoolExecutor(max_workers=args.jobs) as workers:
|
| 167 |
+
pending = {downloads.submit(download, root, zoo, *item): item for item in inventory_rows}
|
| 168 |
+
builds = {}
|
| 169 |
+
for future in concurrent.futures.as_completed(pending):
|
| 170 |
+
family, name, source = pending[future]
|
| 171 |
+
try:
|
| 172 |
+
model = future.result()
|
| 173 |
+
asset = family, name, model, source or SUPPLIED_ONNX.get(name) or str(model)
|
| 174 |
+
for chip in args.chip or ("rk3576", "rk3588"):
|
| 175 |
+
for precision in args.precision or ("i8", "fp"):
|
| 176 |
+
if name == "clip_text" and precision == "i8":
|
| 177 |
+
continue
|
| 178 |
+
job = workers.submit(convert, root, zoo, asset, chip, precision,
|
| 179 |
+
args.refresh_metadata)
|
| 180 |
+
builds[job] = family, name, chip, precision
|
| 181 |
+
except Exception as error:
|
| 182 |
+
print(f"asset failed {family}/{name}: {error}", flush=True)
|
| 183 |
+
failures += 1
|
| 184 |
+
for future in concurrent.futures.as_completed(builds):
|
| 185 |
+
try:
|
| 186 |
+
print(future.result(), flush=True)
|
| 187 |
+
except Exception as error:
|
| 188 |
+
print(f"build failed {' '.join(builds[future])}: {error}", flush=True)
|
| 189 |
+
failures += 1
|
| 190 |
+
return bool(failures)
|
| 191 |
+
|
| 192 |
+
|
| 193 |
+
if __name__ == "__main__":
|
| 194 |
+
raise SystemExit(main())
|
source/yolox_nano.pth
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:cd28f55fbbc1829f99d9ac9b38a16d259a22889739c8728ea877610201feff7b
|
| 3 |
+
size 7694953
|