hubai-sdk 0.0.2__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.
- hubai_sdk-0.0.2/PKG-INFO +493 -0
- hubai_sdk-0.0.2/README.md +461 -0
- hubai_sdk-0.0.2/examples/conversion/rvc2.py +41 -0
- hubai_sdk-0.0.2/examples/conversion/rvc2_legacy.py +40 -0
- hubai_sdk-0.0.2/examples/conversion/rvc4_fp16.py +40 -0
- hubai_sdk-0.0.2/examples/conversion/rvc4_int8.py +42 -0
- hubai_sdk-0.0.2/examples/conversion/yolo.py +46 -0
- hubai_sdk-0.0.2/examples/instances.py +53 -0
- hubai_sdk-0.0.2/examples/models.py +56 -0
- hubai_sdk-0.0.2/examples/variants.py +49 -0
- hubai_sdk-0.0.2/hubai_sdk/__init__.py +5 -0
- hubai_sdk-0.0.2/hubai_sdk/__main__.py +103 -0
- hubai_sdk-0.0.2/hubai_sdk/hubai_client.py +57 -0
- hubai_sdk-0.0.2/hubai_sdk/services/__init__.py +0 -0
- hubai_sdk-0.0.2/hubai_sdk/services/convert.py +813 -0
- hubai_sdk-0.0.2/hubai_sdk/services/instances.py +581 -0
- hubai_sdk-0.0.2/hubai_sdk/services/models.py +409 -0
- hubai_sdk-0.0.2/hubai_sdk/services/variants.py +302 -0
- hubai_sdk-0.0.2/hubai_sdk/typing.py +68 -0
- hubai_sdk-0.0.2/hubai_sdk/utils/__init__.py +3 -0
- hubai_sdk-0.0.2/hubai_sdk/utils/config.py +616 -0
- hubai_sdk-0.0.2/hubai_sdk/utils/constants.py +20 -0
- hubai_sdk-0.0.2/hubai_sdk/utils/environ.py +96 -0
- hubai_sdk-0.0.2/hubai_sdk/utils/filesystem_utils.py +76 -0
- hubai_sdk-0.0.2/hubai_sdk/utils/general.py +78 -0
- hubai_sdk-0.0.2/hubai_sdk/utils/hub.py +394 -0
- hubai_sdk-0.0.2/hubai_sdk/utils/hub_requests.py +113 -0
- hubai_sdk-0.0.2/hubai_sdk/utils/hubai_models.py +1842 -0
- hubai_sdk-0.0.2/hubai_sdk/utils/layout.py +30 -0
- hubai_sdk-0.0.2/hubai_sdk/utils/metadata.py +143 -0
- hubai_sdk-0.0.2/hubai_sdk/utils/nn_archive.py +208 -0
- hubai_sdk-0.0.2/hubai_sdk/utils/sdk_models.py +10 -0
- hubai_sdk-0.0.2/hubai_sdk/utils/subprocess.py +108 -0
- hubai_sdk-0.0.2/hubai_sdk/utils/telemetry.py +273 -0
- hubai_sdk-0.0.2/hubai_sdk/utils/types.py +273 -0
- hubai_sdk-0.0.2/hubai_sdk.egg-info/PKG-INFO +493 -0
- hubai_sdk-0.0.2/hubai_sdk.egg-info/SOURCES.txt +54 -0
- hubai_sdk-0.0.2/hubai_sdk.egg-info/dependency_links.txt +1 -0
- hubai_sdk-0.0.2/hubai_sdk.egg-info/entry_points.txt +2 -0
- hubai_sdk-0.0.2/hubai_sdk.egg-info/requires.txt +16 -0
- hubai_sdk-0.0.2/hubai_sdk.egg-info/top_level.txt +6 -0
- hubai_sdk-0.0.2/pyproject.toml +126 -0
- hubai_sdk-0.0.2/requirements-dev.txt +3 -0
- hubai_sdk-0.0.2/requirements.txt +11 -0
- hubai_sdk-0.0.2/scripts/fix_nullable.py +40 -0
- hubai_sdk-0.0.2/setup.cfg +4 -0
- hubai_sdk-0.0.2/tests/__init__.py +0 -0
- hubai_sdk-0.0.2/tests/conftest.py +81 -0
- hubai_sdk-0.0.2/tests/test_conversion/__init__.py +0 -0
- hubai_sdk-0.0.2/tests/test_conversion/test_rvc2.py +26 -0
- hubai_sdk-0.0.2/tests/test_conversion/test_rvc2_legacy.py +28 -0
- hubai_sdk-0.0.2/tests/test_conversion/test_rvc4_fp16.py +27 -0
- hubai_sdk-0.0.2/tests/test_conversion/test_rvc4_int8.py +28 -0
- hubai_sdk-0.0.2/tests/test_instances.py +74 -0
- hubai_sdk-0.0.2/tests/test_models.py +48 -0
- hubai_sdk-0.0.2/tests/test_variants.py +55 -0
hubai_sdk-0.0.2/PKG-INFO
ADDED
|
@@ -0,0 +1,493 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: hubai-sdk
|
|
3
|
+
Version: 0.0.2
|
|
4
|
+
Summary: SDK for HubAI.
|
|
5
|
+
Author-email: Luxonis <support@luxonis.com>
|
|
6
|
+
Maintainer-email: Luxonis <support@luxonis.com>
|
|
7
|
+
Project-URL: repository, https://github.com/luxonis/hubai-sdk
|
|
8
|
+
Project-URL: issues, https://github.com/luxonis/hubai-sdk/issues
|
|
9
|
+
Keywords: ml,onnx,openvino,nn,ai,embedded
|
|
10
|
+
Classifier: Development Status :: 4 - Beta
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
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.10
|
|
16
|
+
Description-Content-Type: text/markdown
|
|
17
|
+
Requires-Dist: luxonis-ml[data,nn_archive]
|
|
18
|
+
Requires-Dist: keyring
|
|
19
|
+
Requires-Dist: requests
|
|
20
|
+
Requires-Dist: cyclopts
|
|
21
|
+
Requires-Dist: loguru
|
|
22
|
+
Requires-Dist: rich
|
|
23
|
+
Requires-Dist: packaging
|
|
24
|
+
Requires-Dist: onnx
|
|
25
|
+
Requires-Dist: psutil
|
|
26
|
+
Requires-Dist: pillow
|
|
27
|
+
Requires-Dist: posthog
|
|
28
|
+
Provides-Extra: dev
|
|
29
|
+
Requires-Dist: openapi-python-client; extra == "dev"
|
|
30
|
+
Requires-Dist: pytest; extra == "dev"
|
|
31
|
+
Requires-Dist: pre-commit; extra == "dev"
|
|
32
|
+
|
|
33
|
+
# HubAI SDK
|
|
34
|
+
|
|
35
|
+
Python SDK for interacting with Luxonis HubAI - a platform for managing, converting, and deploying machine learning models for Luxonis OAK devices. If you want to convert models locally, check out [modelconverter](https://github.com/luxonis/modelconverter) instead.
|
|
36
|
+
|
|
37
|
+
## ✨ Features
|
|
38
|
+
|
|
39
|
+
- **Model Management**: Create, list, update, and delete HubAI models
|
|
40
|
+
- **Variant Management**: Manage HubAI model variants and versions
|
|
41
|
+
- **Instance Management**: Create and manage HubAI model instances
|
|
42
|
+
- **Model Conversion**: Convert HubAI models to various formats including:
|
|
43
|
+
- RVC2
|
|
44
|
+
- RVC3
|
|
45
|
+
- RVC4
|
|
46
|
+
- Hailo
|
|
47
|
+
- **CLI Tools**: Command-line interface for all operations
|
|
48
|
+
- **Type Safety**: Full type hints for better developer experience
|
|
49
|
+
|
|
50
|
+
## 📦 Installation
|
|
51
|
+
|
|
52
|
+
Install the package using pip:
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
pip install hubai-sdk
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Or install from source:
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
git clone https://github.com/luxonis/hubai-sdk.git
|
|
62
|
+
cd hubai-sdk
|
|
63
|
+
pip install -e .
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## 📋 Requirements
|
|
67
|
+
|
|
68
|
+
- Python 3.10 or higher
|
|
69
|
+
- Valid Luxonis HubAI API key - you can get it from [HubAI Team Settings](https://hub.luxonis.com/team-settings)
|
|
70
|
+
|
|
71
|
+
## 🔐 Authentication
|
|
72
|
+
|
|
73
|
+
### Get Your API Key
|
|
74
|
+
|
|
75
|
+
1. Visit [HubAI Team Settings](https://hub.luxonis.com/team-settings)
|
|
76
|
+
1. Generate or copy your API key
|
|
77
|
+
|
|
78
|
+
### Set API Key
|
|
79
|
+
|
|
80
|
+
You can authenticate in several ways:
|
|
81
|
+
|
|
82
|
+
**Option 1: Environment Variable**
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
export HUBAI_API_KEY="your-api-key-here"
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
This will store the API key in your environment variable and will be used by the SDK automatically. It is valid for the current session only.
|
|
89
|
+
|
|
90
|
+
**Option 2: CLI Login**
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
hubai login
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
This will open a browser to generate a new API key and prompt you to enter it, which will be securely stored. Use `hubai login --relogin` to relogin with different API key or `hubai logout` to logout.
|
|
97
|
+
|
|
98
|
+
**Option 3: Pass API Key Directly**
|
|
99
|
+
|
|
100
|
+
```python
|
|
101
|
+
from hubai_sdk import HubAIClient
|
|
102
|
+
|
|
103
|
+
client = HubAIClient(api_key="your-api-key-here")
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
## 🚀 Quick Start
|
|
107
|
+
|
|
108
|
+
### Python SDK Usage
|
|
109
|
+
|
|
110
|
+
```python
|
|
111
|
+
import os
|
|
112
|
+
from hubai_sdk import HubAIClient
|
|
113
|
+
|
|
114
|
+
# Initialize client
|
|
115
|
+
api_key = os.getenv("HUBAI_API_KEY")
|
|
116
|
+
client = HubAIClient(api_key=api_key)
|
|
117
|
+
|
|
118
|
+
# List all models
|
|
119
|
+
models = client.models.list_models()
|
|
120
|
+
print(f"Found {len(models)} models")
|
|
121
|
+
|
|
122
|
+
# Get a specific model
|
|
123
|
+
model = client.models.get_model(models[0].id)
|
|
124
|
+
print(f"Model: {model.name}")
|
|
125
|
+
|
|
126
|
+
# Convert a model to RVC2 format
|
|
127
|
+
response = client.convert.RVC2(
|
|
128
|
+
path="/path/to/your/model.onnx",
|
|
129
|
+
name="my-converted-model"
|
|
130
|
+
)
|
|
131
|
+
|
|
132
|
+
print(f"Converted model downloaded to: {response.downloaded_path}")
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
## 🛠️ Services
|
|
136
|
+
|
|
137
|
+
The SDK provides four main services accessible through the `HubAIClient`:
|
|
138
|
+
|
|
139
|
+
### 🤖 Models Service (`client.models`)
|
|
140
|
+
|
|
141
|
+
Manage ML models in HubAI.
|
|
142
|
+
|
|
143
|
+
```python
|
|
144
|
+
# List models
|
|
145
|
+
models = client.models.list_models(
|
|
146
|
+
tasks=["OBJECT_DETECTION"],
|
|
147
|
+
is_public=True,
|
|
148
|
+
limit=10
|
|
149
|
+
)
|
|
150
|
+
|
|
151
|
+
# Get model by ID or slug
|
|
152
|
+
model = client.models.get_model("model-id-or-slug")
|
|
153
|
+
|
|
154
|
+
# Create a new model
|
|
155
|
+
new_model = client.models.create_model(
|
|
156
|
+
name="my-model",
|
|
157
|
+
license_type="MIT",
|
|
158
|
+
is_public=False,
|
|
159
|
+
description="My awesome model",
|
|
160
|
+
tasks=["OBJECT_DETECTION"]
|
|
161
|
+
)
|
|
162
|
+
|
|
163
|
+
# Update a model
|
|
164
|
+
updated_model = client.models.update_model(
|
|
165
|
+
model_id,
|
|
166
|
+
license_type="Apache 2.0",
|
|
167
|
+
description="Updated description"
|
|
168
|
+
)
|
|
169
|
+
|
|
170
|
+
# Delete a model
|
|
171
|
+
client.models.delete_model(model_id)
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
### 🔄 Variants Service (`client.variants`)
|
|
175
|
+
|
|
176
|
+
Manage model variants and versions.
|
|
177
|
+
|
|
178
|
+
```python
|
|
179
|
+
# List variants (optionally filtered by model)
|
|
180
|
+
variants = client.variants.list_variants(model_id="model-id")
|
|
181
|
+
|
|
182
|
+
# Get variant by ID
|
|
183
|
+
variant = client.variants.get_variant("variant-id")
|
|
184
|
+
|
|
185
|
+
# Create a new variant
|
|
186
|
+
new_variant = client.variants.create_variant(
|
|
187
|
+
name="my-variant",
|
|
188
|
+
model_id="model-id",
|
|
189
|
+
variant_version="1.0.0",
|
|
190
|
+
description="First version"
|
|
191
|
+
)
|
|
192
|
+
|
|
193
|
+
# Delete a variant
|
|
194
|
+
client.variants.delete_variant("variant-id")
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
### 📦 Instances Service (`client.instances`)
|
|
198
|
+
|
|
199
|
+
Manage model instances (specific configurations of variants).
|
|
200
|
+
|
|
201
|
+
```python
|
|
202
|
+
# Create an instance
|
|
203
|
+
instance = client.instances.create_instance(
|
|
204
|
+
name="my-instance",
|
|
205
|
+
variant_id="variant-id",
|
|
206
|
+
model_type=ModelType.ONNX,
|
|
207
|
+
input_shape=[1, 3, 288, 512]
|
|
208
|
+
)
|
|
209
|
+
|
|
210
|
+
# Upload a file to instance
|
|
211
|
+
client.instances.upload_file("/path/to/nn_archive.tar.xz", instance.id)
|
|
212
|
+
|
|
213
|
+
# Get instance config
|
|
214
|
+
config = client.instances.get_config(instance.id)
|
|
215
|
+
|
|
216
|
+
# Download instance
|
|
217
|
+
downloaded_path = client.instances.download_instance(instance.id)
|
|
218
|
+
|
|
219
|
+
# Delete instance
|
|
220
|
+
client.instances.delete_instance(instance.id)
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
### ⚡ Conversion Service (`client.convert`)
|
|
224
|
+
|
|
225
|
+
Convert models to various formats.
|
|
226
|
+
|
|
227
|
+
#### RVC2 Conversion
|
|
228
|
+
|
|
229
|
+
Convert models for Luxonis OAK devices:
|
|
230
|
+
|
|
231
|
+
```python
|
|
232
|
+
response = client.convert.RVC2(
|
|
233
|
+
path="/path/to/model.onnx",
|
|
234
|
+
name="converted-model",
|
|
235
|
+
compress_to_fp16=True,
|
|
236
|
+
number_of_shaves=8,
|
|
237
|
+
superblob=True
|
|
238
|
+
)
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
#### RVC4 Conversion
|
|
242
|
+
|
|
243
|
+
Convert models to Qualcomm SNPE format:
|
|
244
|
+
|
|
245
|
+
```python
|
|
246
|
+
response = client.convert.RVC4(
|
|
247
|
+
path="/path/to/model.onnx",
|
|
248
|
+
name="converted-model",
|
|
249
|
+
target_precision="INT8",
|
|
250
|
+
use_per_channel_quantization=True,
|
|
251
|
+
htp_socs=["sm8550"]
|
|
252
|
+
)
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
#### Generic Conversion
|
|
256
|
+
|
|
257
|
+
Convert to any supported target:
|
|
258
|
+
|
|
259
|
+
```python
|
|
260
|
+
from hubai_sdk.utils.types import Target
|
|
261
|
+
|
|
262
|
+
response = client.convert.convert(
|
|
263
|
+
target=Target.RVC2, # or Target.RVC4, Target.HAILO, etc.
|
|
264
|
+
path="/path/to/model.onnx",
|
|
265
|
+
name="converted-model",
|
|
266
|
+
target_precision="INT8",
|
|
267
|
+
input_shape=[1, 3, 288, 512]
|
|
268
|
+
)
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
## 💻 CLI Usage
|
|
272
|
+
|
|
273
|
+
The SDK also provides a command-line interface:
|
|
274
|
+
|
|
275
|
+
```bash
|
|
276
|
+
# Login
|
|
277
|
+
hubai login
|
|
278
|
+
|
|
279
|
+
# List models
|
|
280
|
+
hubai model ls
|
|
281
|
+
|
|
282
|
+
# Get model info
|
|
283
|
+
hubai model info <model-id-or-slug>
|
|
284
|
+
|
|
285
|
+
# Create a model
|
|
286
|
+
hubai model create "my-model" --license-type MIT --tasks OBJECT_DETECTION
|
|
287
|
+
|
|
288
|
+
# Convert a model
|
|
289
|
+
hubai convert RVC2 --path /path/to/model.onnx --name "my-model"
|
|
290
|
+
|
|
291
|
+
# List variants
|
|
292
|
+
hubai variant ls
|
|
293
|
+
|
|
294
|
+
# List instances
|
|
295
|
+
hubai instance ls
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
For more CLI options, use the `--help` flag:
|
|
299
|
+
|
|
300
|
+
```bash
|
|
301
|
+
hubai --help
|
|
302
|
+
hubai model --help
|
|
303
|
+
hubai convert --help
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
## 📚 Examples
|
|
307
|
+
|
|
308
|
+
See the `examples/` directory for more detailed usage examples:
|
|
309
|
+
|
|
310
|
+
- **`examples/models.py`**: Model management operations
|
|
311
|
+
- **`examples/variants.py`**: Variant management operations
|
|
312
|
+
- **`examples/instances.py`**: Instance management and file operations
|
|
313
|
+
- **`examples/conversion/`**: Model conversion examples for different formats
|
|
314
|
+
|
|
315
|
+
## Migration from `blobconverter`
|
|
316
|
+
|
|
317
|
+
[BlobConverter](https://pypi.org/project/blobconverter/) is our previous library for converting models to the BLOB format usable with `RVC2` and `RVC3` devices. This library is being replaced by `modelconverter` and `HubAI SDK`, which eventually become the only supported way of converting models in the future.
|
|
318
|
+
|
|
319
|
+
`blobconverter` is still available and can be used for conversion, but we recommend using `HubAI SDK` for new projects. The API of `HUBAI SDK` is similar to that of `blobconverter`, but there are some differences in the parameters and the way the conversion is done.
|
|
320
|
+
|
|
321
|
+
`blobconverter` offers several functions for converting models from different frameworks, such as `from_onnx`, `from_openvino`, and `from_tf`. These functions are now replaced by the `convert.RVC2` (or `convert.RVC3`) function in `HubAI SDK`, which takes a single argument `path` that specifies the path to the model file.
|
|
322
|
+
|
|
323
|
+
The following table shows the mapping between the parameters of `blobconverter` and `HUBAI SDK`. The parameters are grouped by their purpose. The first column shows the parameters of `blobconverter`, the second column shows the equivalent parameters in `HubAI SDK`, and the third column contains additional notes.
|
|
324
|
+
|
|
325
|
+
| `blobconverter` | `HubAI SDK` | Notes |
|
|
326
|
+
| ------------------ | ------------------- | --------------------------------------------------------------------------------------------------------- |
|
|
327
|
+
| `model` | `path` | The model file path. |
|
|
328
|
+
| `xml` | `path` | The XML file path. Only for conversion from OpenVINO IR |
|
|
329
|
+
| `bin` | `opts["input_bin"]` | The BIN file path. Only for conversion from OpenVINO IR. See the [example](#conversion-from-openvino-ir). |
|
|
330
|
+
| `version` | `tool_version` | The version of the conversion tool. |
|
|
331
|
+
| `data_type` | `target_precision` | The precision of the model. |
|
|
332
|
+
| `shaves` | `number_of_shaves` | The number of shaves to use. |
|
|
333
|
+
| `optimizer_params` | `mo_args` | The arguments to pass to the model optimizer. |
|
|
334
|
+
| `compile_params` | `compile_tool_args` | The arguments to pass to the BLOB compiler. |
|
|
335
|
+
|
|
336
|
+
By default, `HubAI SDK` has `superblob` enabled which is only supported on DepthAI v3. If you want to convert a model to legacy RVC2 format (blob), you can pass `superblob=False` to the `convert.RVC2` function.
|
|
337
|
+
|
|
338
|
+
### Simple Conversion
|
|
339
|
+
|
|
340
|
+
**Simple ONNX conversion using `blobconverter`**
|
|
341
|
+
|
|
342
|
+
```python
|
|
343
|
+
|
|
344
|
+
import blobconverter
|
|
345
|
+
|
|
346
|
+
blob = blobconverter.from_onnx(
|
|
347
|
+
model="resnet18.onnx",
|
|
348
|
+
)
|
|
349
|
+
```
|
|
350
|
+
|
|
351
|
+
**Equivalent code using `HubAI SDK`**
|
|
352
|
+
|
|
353
|
+
```python
|
|
354
|
+
response = client.convert.RVC2(
|
|
355
|
+
path="resnet18.onnx",
|
|
356
|
+
)
|
|
357
|
+
|
|
358
|
+
blob = response.downloaded_path
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
### Conversion from OpenVINO IR
|
|
362
|
+
|
|
363
|
+
**`blobconverter` example**
|
|
364
|
+
|
|
365
|
+
```python
|
|
366
|
+
import blobconverter
|
|
367
|
+
|
|
368
|
+
blob = blobconverter.from_openvino(
|
|
369
|
+
xml="resnet18.xml",
|
|
370
|
+
bin="resnet18.bin",
|
|
371
|
+
)
|
|
372
|
+
```
|
|
373
|
+
|
|
374
|
+
**`HubAI SDK` example**
|
|
375
|
+
|
|
376
|
+
```python
|
|
377
|
+
# When the XML and BIN files are at the same location,
|
|
378
|
+
# only the XML needs to be specified
|
|
379
|
+
response = client.convert.RVC2("resnet18.xml")
|
|
380
|
+
blob = response.downloaded_path
|
|
381
|
+
|
|
382
|
+
# Otherwise, the BIN file can be specified using
|
|
383
|
+
# the `opts` parameter
|
|
384
|
+
response = client.convert.RVC2(
|
|
385
|
+
path="resnet18.xml",
|
|
386
|
+
opts={
|
|
387
|
+
"input_bin": "resnet18.bin",
|
|
388
|
+
}
|
|
389
|
+
)
|
|
390
|
+
blob = response.downloaded_path
|
|
391
|
+
```
|
|
392
|
+
|
|
393
|
+
### Conversion from `tflite`
|
|
394
|
+
|
|
395
|
+
> [!WARNING]
|
|
396
|
+
> `HubAI` online conversion does not support conversion from frozen PB files, only TFLITE files are supported.
|
|
397
|
+
|
|
398
|
+
`blobconverter`
|
|
399
|
+
|
|
400
|
+
```python
|
|
401
|
+
|
|
402
|
+
import blobconverter
|
|
403
|
+
|
|
404
|
+
blob = blobconverter.from_tf(
|
|
405
|
+
frozen_pb="resnet18.tflite",
|
|
406
|
+
)
|
|
407
|
+
```
|
|
408
|
+
|
|
409
|
+
**Equivalent code using `HubAI SDK`**
|
|
410
|
+
|
|
411
|
+
```python
|
|
412
|
+
response = client.convert.RVC2(
|
|
413
|
+
path="resnet18.tflite",
|
|
414
|
+
|
|
415
|
+
)
|
|
416
|
+
|
|
417
|
+
blob = response.downloaded_path
|
|
418
|
+
```
|
|
419
|
+
|
|
420
|
+
### Advanced Parameters
|
|
421
|
+
|
|
422
|
+
**`blobconverter.from_onnx` with advanced parameters**
|
|
423
|
+
|
|
424
|
+
```python
|
|
425
|
+
import blobconverter
|
|
426
|
+
|
|
427
|
+
blob = blobconverter.from_onnx(
|
|
428
|
+
model="resnet18.onnx",
|
|
429
|
+
data_type="FP16",
|
|
430
|
+
version="2021.4",
|
|
431
|
+
shaves=6,
|
|
432
|
+
optimizer_params=[
|
|
433
|
+
"--mean_values=[127.5,127.5,127.5]",
|
|
434
|
+
"--scale_values=[255,255,255]",
|
|
435
|
+
],
|
|
436
|
+
compile_params=["-ip U8"],
|
|
437
|
+
|
|
438
|
+
)
|
|
439
|
+
```
|
|
440
|
+
|
|
441
|
+
**Equivalent code using `HubAI SDK`**
|
|
442
|
+
|
|
443
|
+
```python
|
|
444
|
+
response = client.convert.RVC2(
|
|
445
|
+
path="resnet18.onnx",
|
|
446
|
+
target_precision="FP16",
|
|
447
|
+
tool_version="2021.4.0",
|
|
448
|
+
number_of_shaves=6,
|
|
449
|
+
mo_args=[
|
|
450
|
+
"mean_values=[127.5,127.5,127.5]",
|
|
451
|
+
"scale_values=[255,255,255]"
|
|
452
|
+
],
|
|
453
|
+
compile_tool_args=["-ip", "U8"],
|
|
454
|
+
)
|
|
455
|
+
|
|
456
|
+
blob = response.downloaded_path
|
|
457
|
+
```
|
|
458
|
+
|
|
459
|
+
### `Caffe` Conversion
|
|
460
|
+
|
|
461
|
+
Conversion from the `Caffe` framework is not supported.
|
|
462
|
+
|
|
463
|
+
## 📄 All Available Parameters
|
|
464
|
+
|
|
465
|
+
See the [All available parameters](docs/available_parameters.md) file for all available parameters during conversion.
|
|
466
|
+
|
|
467
|
+
## 🔨 Development
|
|
468
|
+
|
|
469
|
+
### Setup Development Environment
|
|
470
|
+
|
|
471
|
+
```bash
|
|
472
|
+
git clone https://github.com/luxonis/hubai-sdk.git
|
|
473
|
+
cd hubai-sdk
|
|
474
|
+
python -m venv venv
|
|
475
|
+
source venv/bin/activate # On Windows: venv\Scripts\activate
|
|
476
|
+
pip install -e ".[dev]"
|
|
477
|
+
```
|
|
478
|
+
|
|
479
|
+
## 🤝 Contributing
|
|
480
|
+
|
|
481
|
+
Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
|
|
482
|
+
|
|
483
|
+
## 💬 Support
|
|
484
|
+
|
|
485
|
+
- **Issues**: [GitHub Issues](https://github.com/luxonis/hubai-sdk/issues)
|
|
486
|
+
- **Email**: support@luxonis.com
|
|
487
|
+
- **Documentation**: [HubAI Platform](https://docs.luxonis.com)
|
|
488
|
+
|
|
489
|
+
## 🔗 Links
|
|
490
|
+
|
|
491
|
+
- **Repository**: [https://github.com/luxonis/hubai-sdk](https://github.com/luxonis/hubai-sdk)
|
|
492
|
+
- **HubAI Platform**: [https://hub.luxonis.com](https://hub.luxonis.com)
|
|
493
|
+
- **Luxonis**: [https://luxonis.com](https://luxonis.com)
|