modelconv 0.1.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. modelconv-0.1.1/LICENSE +201 -0
  2. modelconv-0.1.1/PKG-INFO +357 -0
  3. modelconv-0.1.1/README.md +319 -0
  4. modelconv-0.1.1/modelconv.egg-info/PKG-INFO +357 -0
  5. modelconv-0.1.1/modelconv.egg-info/SOURCES.txt +63 -0
  6. modelconv-0.1.1/modelconv.egg-info/dependency_links.txt +1 -0
  7. modelconv-0.1.1/modelconv.egg-info/entry_points.txt +2 -0
  8. modelconv-0.1.1/modelconv.egg-info/requires.txt +22 -0
  9. modelconv-0.1.1/modelconv.egg-info/top_level.txt +5 -0
  10. modelconv-0.1.1/modelconverter/__init__.py +12 -0
  11. modelconv-0.1.1/modelconverter/__main__.py +499 -0
  12. modelconv-0.1.1/modelconverter/packages/__init__.py +7 -0
  13. modelconv-0.1.1/modelconverter/packages/base_benchmark.py +123 -0
  14. modelconv-0.1.1/modelconverter/packages/base_exporter.py +195 -0
  15. modelconv-0.1.1/modelconverter/packages/base_inferer.py +89 -0
  16. modelconv-0.1.1/modelconverter/packages/getters.py +73 -0
  17. modelconv-0.1.1/modelconverter/packages/hailo/exporter.py +252 -0
  18. modelconv-0.1.1/modelconverter/packages/hailo/inferer.py +71 -0
  19. modelconv-0.1.1/modelconverter/packages/multistage_exporter.py +139 -0
  20. modelconv-0.1.1/modelconverter/packages/rvc2/benchmark.py +164 -0
  21. modelconv-0.1.1/modelconverter/packages/rvc2/exporter.py +287 -0
  22. modelconv-0.1.1/modelconverter/packages/rvc2/inferer.py +31 -0
  23. modelconv-0.1.1/modelconverter/packages/rvc3/benchmark.py +78 -0
  24. modelconv-0.1.1/modelconverter/packages/rvc3/exporter.py +169 -0
  25. modelconv-0.1.1/modelconverter/packages/rvc3/inferer.py +3 -0
  26. modelconv-0.1.1/modelconverter/packages/rvc4/benchmark.py +168 -0
  27. modelconv-0.1.1/modelconverter/packages/rvc4/exporter.py +223 -0
  28. modelconv-0.1.1/modelconverter/packages/rvc4/inferer.py +68 -0
  29. modelconv-0.1.1/modelconverter/utils/__init__.py +52 -0
  30. modelconv-0.1.1/modelconverter/utils/calibration_data.py +91 -0
  31. modelconv-0.1.1/modelconverter/utils/config.py +786 -0
  32. modelconv-0.1.1/modelconverter/utils/constants.py +20 -0
  33. modelconv-0.1.1/modelconverter/utils/docker_utils.py +120 -0
  34. modelconv-0.1.1/modelconverter/utils/exceptions.py +24 -0
  35. modelconv-0.1.1/modelconverter/utils/filesystem_utils.py +74 -0
  36. modelconv-0.1.1/modelconverter/utils/image.py +117 -0
  37. modelconv-0.1.1/modelconverter/utils/nn_archive.py +183 -0
  38. modelconv-0.1.1/modelconverter/utils/onnx_tools.py +125 -0
  39. modelconv-0.1.1/modelconverter/utils/subprocess.py +69 -0
  40. modelconv-0.1.1/modelconverter/utils/types.py +182 -0
  41. modelconv-0.1.1/pyproject.toml +57 -0
  42. modelconv-0.1.1/requirements-bench.txt +2 -0
  43. modelconv-0.1.1/requirements-dev.txt +3 -0
  44. modelconv-0.1.1/requirements.txt +11 -0
  45. modelconv-0.1.1/setup.cfg +4 -0
  46. modelconv-0.1.1/tests/__init__.py +0 -0
  47. modelconv-0.1.1/tests/conftest.py +211 -0
  48. modelconv-0.1.1/tests/test_packages/__init__.py +0 -0
  49. modelconv-0.1.1/tests/test_packages/common.py +154 -0
  50. modelconv-0.1.1/tests/test_packages/metrics/__init__.py +6 -0
  51. modelconv-0.1.1/tests/test_packages/metrics/base_metric.py +24 -0
  52. modelconv-0.1.1/tests/test_packages/metrics/mnist_metric.py +50 -0
  53. modelconv-0.1.1/tests/test_packages/metrics/resnet_metric.py +51 -0
  54. modelconv-0.1.1/tests/test_packages/metrics/yolov6_metric.py +267 -0
  55. modelconv-0.1.1/tests/test_packages/onnx_inferer.py +20 -0
  56. modelconv-0.1.1/tests/test_packages/test_cross_format_export.py +39 -0
  57. modelconv-0.1.1/tests/test_packages/test_hailo.py +37 -0
  58. modelconv-0.1.1/tests/test_packages/test_rvc2.py +89 -0
  59. modelconv-0.1.1/tests/test_packages/test_rvc3.py +55 -0
  60. modelconv-0.1.1/tests/test_packages/test_rvc4.py +38 -0
  61. modelconv-0.1.1/tests/test_utils/__init__.py +0 -0
  62. modelconv-0.1.1/tests/test_utils/test_config.py +651 -0
  63. modelconv-0.1.1/tests/test_utils/test_filesystem.py +75 -0
  64. modelconv-0.1.1/tests/test_utils/test_image.py +116 -0
  65. modelconv-0.1.1/tests/test_utils/test_subprocess.py +32 -0
@@ -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 [yyyy] [name of copyright owner]
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.
@@ -0,0 +1,357 @@
1
+ Metadata-Version: 2.1
2
+ Name: modelconv
3
+ Version: 0.1.1
4
+ Summary: Converter for neural models into various formats.
5
+ Author-email: Luxonis <support@luxonis.com>
6
+ Maintainer-email: Luxonis <support@luxonis.com>
7
+ Project-URL: repository, https://github.com/luxonis/modelconverter
8
+ Project-URL: issues, https://github.com/luxonis/modelconverter/issues
9
+ Keywords: ml,onnx,openvino,nn,ai,embedded
10
+ Classifier: Development Status :: 4 - Beta
11
+ Classifier: Programming Language :: Python :: 3.8
12
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
13
+ Classifier: Topic :: Scientific/Engineering :: Image Processing
14
+ Classifier: Topic :: Scientific/Engineering :: Image Recognition
15
+ Requires-Python: >=3.8
16
+ Description-Content-Type: text/markdown
17
+ License-File: LICENSE
18
+ Requires-Dist: Pillow
19
+ Requires-Dist: PyYAML
20
+ Requires-Dist: gcsfs
21
+ Requires-Dist: luxonis-ml[data,nn_archive]>=0.2.2
22
+ Requires-Dist: onnx
23
+ Requires-Dist: onnxruntime
24
+ Requires-Dist: onnxsim
25
+ Requires-Dist: s3fs
26
+ Requires-Dist: s3transfer
27
+ Requires-Dist: typer
28
+ Requires-Dist: docker
29
+ Provides-Extra: bench
30
+ Requires-Dist: depthai; extra == "bench"
31
+ Requires-Dist: pandas; extra == "bench"
32
+ Provides-Extra: dev
33
+ Requires-Dist: pre-commit==3.2.1; extra == "dev"
34
+ Requires-Dist: pytest-cov>=4.1.0; extra == "dev"
35
+ Requires-Dist: docker-squash>=1.1.0; extra == "dev"
36
+ Requires-Dist: depthai; extra == "dev"
37
+ Requires-Dist: pandas; extra == "dev"
38
+
39
+ # ModelConverter - Compilation Library
40
+
41
+ [![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
42
+ [![PyPI](https://img.shields.io/pypi/v/luxonis-ml?label=pypi%20package)](https://pypi.org/project/modelconverter/)
43
+ [![PyPI - Downloads](https://img.shields.io/pypi/dm/luxonis-ml)](https://pypi.org/project/modelconverter/)
44
+
45
+ [![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
46
+ [![Docformatter](https://img.shields.io/badge/%20formatter-docformatter-fedcba.svg)](https://github.com/PyCQA/docformatter)
47
+ [![Black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
48
+
49
+ Convert your **ONNX** models to a format compatible with any generation of Luxonis camera using the **Model Compilation Library**.
50
+
51
+ ## Status
52
+
53
+ | Package | Test | Deploy |
54
+ | --------- | ----------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------- |
55
+ | **RVC2** | ![RVC2 Tests](https://github.com/luxonis/modelconverter/actions/workflows/rvc2_test.yaml/badge.svg) | ![RVC2 Push](https://github.com/luxonis/modelconverter/actions/workflows/rvc2_publish.yaml/badge.svg) |
56
+ | **RVC3** | ![RVC3 Tests](https://github.com/luxonis/modelconverter/actions/workflows/rvc3_test.yaml/badge.svg) | ![RVC3 Push](https://github.com/luxonis/modelconverter/actions/workflows/rvc3_publish.yaml/badge.svg) |
57
+ | **RVC4** | ![RVC4 Tests](https://github.com/luxonis/modelconverter/actions/workflows/rvc4_test.yaml/badge.svg) | ![RVC4 Push](https://github.com/luxonis/modelconverter/actions/workflows/rvc4_publish.yaml/badge.svg) |
58
+ | **Hailo** | ![Hailo Tests](https://github.com/luxonis/modelconverter/actions/workflows/hailo_test.yaml/badge.svg) | ![Hailo Push](https://github.com/luxonis/modelconverter/actions/workflows/hailo_publish.yaml/badge.svg) |
59
+
60
+ ## Table of Contents
61
+
62
+ - [MLOps - Compilation Library](#mlops---compilation-library)
63
+ - [Table of Contents](#table-of-contents)
64
+ - [Installation](#installation)
65
+ - [GPU Support](#gpu-support)
66
+ - [Running ModelConverter](#running-modelconverter)
67
+ - [Sharing Files](#sharing-files)
68
+ - [Usage](#usage)
69
+ - [Examples](#examples)
70
+ - [Multi-Stage Conversion](#multi-stage-conversion)
71
+ - [Interactive Mode](#interactive-mode)
72
+ - [Calibration Data](#calibration-data)
73
+ - [Inference](#inference)
74
+ - [Inference Example](#inference-example)
75
+ - [Benchmarking](#benchmarking)
76
+
77
+ ## Installation
78
+
79
+ ### Before You Begin
80
+
81
+ `ModelConverter` is in an experimental public beta stage. Some parts might change in the future.
82
+
83
+ To build the images, you need to download additional packages depending on the selected target.
84
+
85
+ **RVC2 and RVC3**
86
+
87
+ Requires `openvino_2022_3_vpux_drop_patched.tar.gz` to be present in `docker/extra_packages`.
88
+ You can download the archive [here](https://drive.google.com/file/d/1IXtYi1Mwpsg3pr5cDXlEHdSUZlwJRTVP/view?usp=share_link).
89
+
90
+ **RVC4**
91
+
92
+ Requires `snpe.zip` archive to be present in `docker/extra_packages`. You can download an archive with the current version [here](https://softwarecenter.qualcomm.com/api/download/software/qualcomm_neural_processing_sdk/v2.23.0.24.06.24.zip). You only need to rename it to `snpe.zip` and place it in the `docker/extra_packages` directory.
93
+
94
+ **HAILO**
95
+
96
+ Requires `hailo_ai_sw_suite_2024-04:1` docker image to be present on the system. You can download the image from the [Hailo website](https://developer.hailo.ai/developer-zone/sw-downloads/).
97
+
98
+ ### Building the Image
99
+
100
+ 1. Ensure `docker` is installed on your machine. If not, refer to the installation guide [here](https://docs.docker.com/engine/install/).
101
+
102
+ 1. Install the modelconverter package. You can install it from PyPI using the following command:
103
+
104
+ ```bash
105
+ pip install modelconv
106
+
107
+ ```
108
+
109
+ 1. Build the docker image:
110
+
111
+ ```bash
112
+ docker build -f docker/<package>/Dockerfile.public -t luxonis/modelconverter-<package>:latest .
113
+ ```
114
+
115
+ This will also install the `modelconverter` CLI. For usage instructions, see `modelconverter --help`.
116
+
117
+ ### GPU Support
118
+
119
+ To enable GPU acceleration for `hailo` conversion, install the [Nvidia Container Toolkit](https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/install-guide.html#docker).
120
+
121
+ ## Running ModelConverter
122
+
123
+ Configuration for the conversion predominantly relies on a `yaml` config file. For reference, see [defaults.yaml](shared_with_container/configs/defaults.yaml) and other examples located in the [shared_with_container/configs](shared_with_container/configs) directory.
124
+
125
+ However, you have the flexibility to modify specific settings without altering the config file itself. This is done using command line arguments. You provide the arguments in the form of `key value` pairs. For better understanding, see [Examples](#examples).
126
+
127
+ ### Sharing Files
128
+
129
+ When using the supplied `docker-compose.yaml`, the `shared_with_container` directory facilitates file sharing between the host and container. This directory is mounted as `/app/shared_with_container/` inside the container. You can place your models, calibration data, and config files here. The directory structure is:
130
+
131
+ ```txt
132
+ shared_with_container/
133
+
134
+ ├── calibration_data/
135
+ │ └── <calibration data will be downloaded here>
136
+
137
+ ├── configs/
138
+ │ ├── resnet18.yaml
139
+ │ └── <configs will be downloaded here>
140
+
141
+ ├── models/
142
+ │ ├── resnet18.onnx
143
+ │ └── <models will be downloaded here>
144
+
145
+ └── outputs/
146
+ └── <output_dir_name>
147
+ ├── resnet18.onnx
148
+ ├── resnet18.dlc
149
+ ├── logs.txt
150
+ ├── config.yaml
151
+ └── intermediate_outputs/
152
+ └── <intermediate files generated during the conversion>
153
+ ```
154
+
155
+ While adhering to this structure is not mandatory as long as the files are visible inside the container, it is advised to keep the files organized.
156
+
157
+ The converter first searches for files exactly at the provided path. If not found, it searches relative to `/app/shared_with_container/`.
158
+
159
+ The `output_dir_name` can be specified in the config file. If such a directory already exists, the `output_dir_name` will be appended with the current date and time. If not specified, the `output_dir_name` will be autogenerated in the following format: `<model_name>_to_<target>_<date>_<time>`.
160
+
161
+ ### Usage
162
+
163
+ You can run the built image either manually using the `docker run` command or using the `modelconverter` CLI.
164
+
165
+ 1. Set your credentials as environment variables (if required):
166
+
167
+ ```bash
168
+ export AWS_SECRET_ACCESS_KEY=<your_aws_secret_access_key>
169
+ export AWS_ACCESS_KEY_ID=<your_aws_access_key_id>
170
+ export AWS_S3_ENDPOINT_URL=<your_aws_s3_endpoint_url>
171
+ ```
172
+
173
+ 1. If `shared_with_container` directory doesn't exist on your host, create it.
174
+
175
+ 1. Without remote files, place the model, config, and calibration data in the respective directories (refer [Sharing Files](#sharing-files)).
176
+
177
+ 1. Execute the conversion:
178
+
179
+ - If using the `docker run` command:
180
+ ```bash
181
+ docker run --rm -it \
182
+ -v $(pwd)/shared_with_container:/app/shared_with_container/ \
183
+ -e AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY \
184
+ -e AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID \
185
+ -e AWS_S3_ENDPOINT_URL=$AWS_S3_ENDPOINT_URL \
186
+ luxonis/modelconverter-<package>:latest \
187
+ convert <target> \
188
+ --path <s3_url_or_path> [ config overrides ]
189
+ ```
190
+ - If using the `modelconverter` CLI:
191
+ ```bash
192
+ modelconverter convert <target> --path <s3_url_or_path> [ config overrides ]
193
+ ```
194
+ - If using `docker-compose`:
195
+ ```bash
196
+ docker compose run <target> convert <target> ...
197
+ ```
198
+
199
+ ### Examples
200
+
201
+ Use `resnet18.yaml` config, but override `calibration.path`:
202
+
203
+ ```bash
204
+ modelconverter convert rvc4 --path configs/resnet18.yaml \
205
+ calibration.path s3://path/to/calibration_data
206
+ ```
207
+
208
+ Override inputs and outputs with command line arguments:
209
+
210
+ ```bash
211
+ modelconverter convert rvc3 --path configs/resnet18.yaml \
212
+ inputs.0.name input_1 \
213
+ inputs.0.shape "[1,3,256,256]" \
214
+ outputs.0.name output_0
215
+ ```
216
+
217
+ Specify all options via the command line without a config file:
218
+
219
+ ```bash
220
+ modelconverter convert rvc2 input_model models/yolov6n.onnx \
221
+ scale_values "[255,255,255]" \
222
+ reverse_input_channels True \
223
+ shape "[1,3,256,256]" \
224
+ outputs.0.name out_0 \
225
+ outputs.1.name out_1 \
226
+ outputs.2.name out_2
227
+ ```
228
+
229
+ ## Multi-Stage Conversion
230
+
231
+ The converter supports multi-stage conversion. This means conversion of multiple
232
+ models where the output of one model is the input to another model. For mulit-stage
233
+ conversion you must specify the `stages` section in the config file, see [defaults.yaml](shared_with_container/configs/defaults.yaml)
234
+ and [multistage.yaml](shared_with_container/configs/multistage.yaml) for reference.
235
+
236
+ The output directory structure would be (assuming RVC4 conversion):
237
+
238
+ ```txt
239
+ output_path/
240
+ ├── config.yaml
241
+ ├── modelconverter.log
242
+ ├── stage_name1
243
+ │ ├── config.yaml
244
+ │ ├── intermediate_outputs/
245
+ │ ├── model1.onnx
246
+ │ └── model1.dlc
247
+ └── stage_name2
248
+ ├── config.yaml
249
+ ├── intermediate_outputs/
250
+ ├── model2.onnx
251
+ └── model2.dlc
252
+ ```
253
+
254
+ ## Interactive Mode
255
+
256
+ Run the container interactively without any post-target arguments:
257
+
258
+ ```bash
259
+ modelconverter shell rvc4
260
+ ```
261
+
262
+ Inside, you'll find all the necessary tools for manual conversion.
263
+ The `modelconverter` CLI is available inside the container as well.
264
+
265
+ ## Calibration Data
266
+
267
+ Calibration data can be a mix of images (`.jpg`, `.png`, `.jpeg`) and `.npy`, `.raw` files.
268
+ Image files will be loaded and converted to the format specified in the config.
269
+ No conversion is performed for `.npy` or `.raw` files, the files are used as provided.
270
+ **NOTE for RVC4**: `RVC4` expects images to be provided in `NHWC` layout. If you provide the calibration data in a form of `.npy` or `.raw` format, you need to make sure they have the correct layout.
271
+
272
+ ## Inference
273
+
274
+ A basic support for inference. To run the inference, use `modelconverter infer <target> <args>`.
275
+ For usage instructions, see `modelconverter infer --help`.
276
+
277
+ The input files must be provided in a specific directory structure.
278
+
279
+ ```txt
280
+ input_path/
281
+ ├── <name of first input node>
282
+ │ ├── 0.npy
283
+ │ ├── 1.npy
284
+ │ └── ...
285
+ ├── <name of second input node>
286
+ │ ├── 0.npy
287
+ │ ├── 1.npy
288
+ │ └── ...
289
+ ├── ...
290
+ └── <name of last input node>
291
+ ├── 0.npy
292
+ ├── 1.npy
293
+ └── ...
294
+ ```
295
+
296
+ **Note**: The numpy files are sent to the model with no preprocessing, so they must be provided in the correct format and shape.
297
+
298
+ The output files are then saved in a similar structure.
299
+
300
+ ### Inference Example
301
+
302
+ For `yolov6n` model, the input directory structure would be:
303
+
304
+ ```txt
305
+ input_path/
306
+ └── images
307
+ ├── 0.npy
308
+ ├── 1.npy
309
+ └── ...
310
+ ```
311
+
312
+ To run the inference, use:
313
+
314
+ ```bash
315
+ modelconverter infer rvc4 \
316
+ --model_path <path_to_model.dlc> \
317
+ --dest <dest> \
318
+ --input_path <input_path>
319
+ --path <path_to_config.yaml>
320
+ ```
321
+
322
+ The output directory structure would be:
323
+
324
+ ```txt
325
+ output_path/
326
+ ├── output1_yolov6r2
327
+ │ ├── 0.npy
328
+ │ ├── 1.npy
329
+ │ └── ...
330
+ ├── output2_yolov6r2
331
+ │ └── <outputs>
332
+ └── output3_yolov6r2
333
+ └── <outputs>
334
+ ```
335
+
336
+ ## Benchmarking
337
+
338
+ The ModelConverter additionally supports benchmarking of converted models.
339
+
340
+ To install the package with the benchmarking dependencies, use:
341
+
342
+ ```bash
343
+ pip install modelconv[bench]
344
+ ```
345
+
346
+ To run the benchmark, use `modelconverter benchmark <target> <args>`.
347
+
348
+ For usage instructions, see `modelconverter benchmark --help`.
349
+
350
+ **Example:**
351
+
352
+ ```bash
353
+ modelconverter benchmark rvc3 --model-path <path_to_model.xml>
354
+ ```
355
+
356
+ The command prints a table with the benchmark results to the console and
357
+ optionally saves the results to a `.csv` file.