dataverse-sdk 2.6.1__tar.gz → 2.8.0__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.
- dataverse_sdk-2.8.0/MANIFEST.in +2 -0
- {dataverse_sdk-2.6.1 → dataverse_sdk-2.8.0}/PKG-INFO +340 -7
- {dataverse_sdk-2.6.1 → dataverse_sdk-2.8.0}/README.md +339 -6
- {dataverse_sdk-2.6.1 → dataverse_sdk-2.8.0}/dataverse_sdk/__init__.py +18 -0
- {dataverse_sdk-2.6.1 → dataverse_sdk-2.8.0}/dataverse_sdk/apis/backend.py +42 -5
- {dataverse_sdk-2.6.1 → dataverse_sdk-2.8.0}/dataverse_sdk/client.py +548 -27
- {dataverse_sdk-2.6.1 → dataverse_sdk-2.8.0}/dataverse_sdk/schemas/api.py +63 -4
- {dataverse_sdk-2.6.1 → dataverse_sdk-2.8.0}/dataverse_sdk/schemas/client.py +152 -24
- dataverse_sdk-2.8.0/dataverse_sdk/schemas/common.py +202 -0
- {dataverse_sdk-2.6.1 → dataverse_sdk-2.8.0}/dataverse_sdk/utils/utils.py +27 -1
- {dataverse_sdk-2.6.1 → dataverse_sdk-2.8.0}/dataverse_sdk.egg-info/PKG-INFO +340 -7
- {dataverse_sdk-2.6.1 → dataverse_sdk-2.8.0}/dataverse_sdk.egg-info/SOURCES.txt +7 -1
- {dataverse_sdk-2.6.1 → dataverse_sdk-2.8.0}/setup.py +1 -1
- dataverse_sdk-2.8.0/tools/export_dataslice.py +118 -0
- dataverse_sdk-2.8.0/tools/export_dataslice_large.py +133 -0
- dataverse_sdk-2.8.0/tools/import_dataset_from_local.py +176 -0
- dataverse_sdk-2.8.0/tools/import_vqa_dataset.py +166 -0
- dataverse_sdk-2.8.0/tools/upload_videos_create_session.py +135 -0
- dataverse_sdk-2.6.1/dataverse_sdk/schemas/common.py +0 -81
- {dataverse_sdk-2.6.1 → dataverse_sdk-2.8.0}/dataverse_sdk/apis/__init__.py +0 -0
- {dataverse_sdk-2.6.1 → dataverse_sdk-2.8.0}/dataverse_sdk/apis/third_party.py +0 -0
- {dataverse_sdk-2.6.1 → dataverse_sdk-2.8.0}/dataverse_sdk/connections.py +0 -0
- {dataverse_sdk-2.6.1 → dataverse_sdk-2.8.0}/dataverse_sdk/constants.py +0 -0
- {dataverse_sdk-2.6.1 → dataverse_sdk-2.8.0}/dataverse_sdk/exceptions/__init__.py +0 -0
- {dataverse_sdk-2.6.1 → dataverse_sdk-2.8.0}/dataverse_sdk/exceptions/client.py +0 -0
- {dataverse_sdk-2.6.1 → dataverse_sdk-2.8.0}/dataverse_sdk/export/__init__.py +0 -0
- {dataverse_sdk-2.6.1 → dataverse_sdk-2.8.0}/dataverse_sdk/export/base.py +0 -0
- {dataverse_sdk-2.6.1 → dataverse_sdk-2.8.0}/dataverse_sdk/export/coco.py +0 -0
- {dataverse_sdk-2.6.1 → dataverse_sdk-2.8.0}/dataverse_sdk/export/constant.py +0 -0
- {dataverse_sdk-2.6.1 → dataverse_sdk-2.8.0}/dataverse_sdk/export/exporter.py +0 -0
- {dataverse_sdk-2.6.1 → dataverse_sdk-2.8.0}/dataverse_sdk/export/utils.py +0 -0
- {dataverse_sdk-2.6.1 → dataverse_sdk-2.8.0}/dataverse_sdk/export/visionai.py +0 -0
- {dataverse_sdk-2.6.1 → dataverse_sdk-2.8.0}/dataverse_sdk/export/vqa.py +0 -0
- {dataverse_sdk-2.6.1 → dataverse_sdk-2.8.0}/dataverse_sdk/export/yolo.py +0 -0
- {dataverse_sdk-2.6.1 → dataverse_sdk-2.8.0}/dataverse_sdk/schemas/__init__.py +0 -0
- {dataverse_sdk-2.6.1 → dataverse_sdk-2.8.0}/dataverse_sdk/schemas/format.py +0 -0
- {dataverse_sdk-2.6.1 → dataverse_sdk-2.8.0}/dataverse_sdk/utils/__init__.py +0 -0
- {dataverse_sdk-2.6.1 → dataverse_sdk-2.8.0}/dataverse_sdk.egg-info/dependency_links.txt +0 -0
- {dataverse_sdk-2.6.1 → dataverse_sdk-2.8.0}/dataverse_sdk.egg-info/requires.txt +0 -0
- {dataverse_sdk-2.6.1 → dataverse_sdk-2.8.0}/dataverse_sdk.egg-info/top_level.txt +0 -0
- {dataverse_sdk-2.6.1 → dataverse_sdk-2.8.0}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: dataverse-sdk
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.8.0
|
|
4
4
|
Summary: Dataverse SDK For Python
|
|
5
5
|
Home-page:
|
|
6
6
|
Author: LinkerVision
|
|
@@ -32,8 +32,10 @@ Use Dataverse-SDK for Python to help you to interact with the Dataverse platform
|
|
|
32
32
|
- Get Project by project-id
|
|
33
33
|
- Create Dataset from your AWS storage or local
|
|
34
34
|
- Get Dataset by dataset-id
|
|
35
|
+
- Create Dataslice from a whole dataset, or look one up by name
|
|
35
36
|
- List models for your selected project-id
|
|
36
37
|
- Get and download your model
|
|
38
|
+
- Convert a model to ONNX/TensorRT and read the convert record's metrics
|
|
37
39
|
|
|
38
40
|
[Package (PyPi)](https://pypi.org/project/dataverse-sdk/) | [Source code](https://github.com/linkervision/dataverse-sdk)
|
|
39
41
|
|
|
@@ -104,9 +106,14 @@ The following sections provide examples for the most common DataVerse tasks incl
|
|
|
104
106
|
* [Create Dataset](#create-dataset)
|
|
105
107
|
* [List Dataset](#list-and-get-dataset)
|
|
106
108
|
* [List Dataslices](#list-and-get-dataslices)
|
|
109
|
+
* [Get Dataslice by Name](#get-dataslice-by-name)
|
|
110
|
+
* [Create Dataslice from Dataset](#create-dataslice-from-dataset)
|
|
107
111
|
* [Export Dataslice](#export-dataslice-and-download)
|
|
108
112
|
* [List Models](#list-models)
|
|
109
113
|
* [Get and Download Model](#get-model)
|
|
114
|
+
* [Get Convert Model File](#get-convert-model-file)
|
|
115
|
+
* [Convert Model to ONNX/TRT](#convert-model-to-onnxtrt)
|
|
116
|
+
* [Retrieve Convert Record](#retrieve-convert-record-and-its-metrics)
|
|
110
117
|
* [Create VQA Project](#create-vqa-project)
|
|
111
118
|
* [Edit VQA Ontology](#edit-vqa-ontology)
|
|
112
119
|
* [Get Question List](#get-question-list)
|
|
@@ -199,9 +206,9 @@ project = client.create_project(name="Sample project", ontology=ontology, sensor
|
|
|
199
206
|
|
|
200
207
|
| Argument name | Type/Options | Default | Description |
|
|
201
208
|
| :--- | :--- | :--- | :--- |
|
|
202
|
-
| name | str |
|
|
203
|
-
| ontology | Ontology |
|
|
204
|
-
| sensors | list[Sensor] |
|
|
209
|
+
| name | str | *-- | name of your project |
|
|
210
|
+
| ontology | Ontology | *-- | the Ontology basemodel data of current project |
|
|
211
|
+
| sensors | list[Sensor] | *-- | the list of Sensor basemodel data of your project |
|
|
205
212
|
| project_tag | ProjectTag | None | your project tags |
|
|
206
213
|
| description | str | None | your project description |
|
|
207
214
|
|
|
@@ -445,6 +452,87 @@ dataslice_data = client.get_dataslice(dataslice_id=504)
|
|
|
445
452
|
|
|
446
453
|
```
|
|
447
454
|
|
|
455
|
+
### Get Dataslice by Name
|
|
456
|
+
|
|
457
|
+
Dataslice names are unique across the site, so a name identifies exactly one dataslice.
|
|
458
|
+
|
|
459
|
+
```Python
|
|
460
|
+
dataslice = client.get_dataslice_by_name(project_id=101, dataslice_name="my-dataslice")
|
|
461
|
+
# OR from the project object
|
|
462
|
+
project = client.get_project(project_id=101)
|
|
463
|
+
dataslice = project.get_dataslice_by_name(dataslice_name="my-dataslice")
|
|
464
|
+
|
|
465
|
+
dataslice.id
|
|
466
|
+
dataslice.status # DataSliceStatus
|
|
467
|
+
dataslice.image_count
|
|
468
|
+
```
|
|
469
|
+
|
|
470
|
+
`DataSliceStatus`: `CREATING`, `CREATING_FAIL`, `READY`, `ANNOTATION_UPDATING`,
|
|
471
|
+
`IQA_UPDATING`, `TAGGING_UPDATING`, `DELETING`.
|
|
472
|
+
|
|
473
|
+
`image_count` and `pcd_count` read the per-type datarow counts in `dataslice.metadata`.
|
|
474
|
+
Which of them carries a number follows the slice's own `type`:
|
|
475
|
+
|
|
476
|
+
| `dataslice.type` | `image_count` | `pcd_count` |
|
|
477
|
+
| -------------------- | ------------- | ----------- |
|
|
478
|
+
| `image` | images | `None` |
|
|
479
|
+
| `pcd` | `None` | pcds |
|
|
480
|
+
| `frame` / `sequence` | images | pcds |
|
|
481
|
+
|
|
482
|
+
The last row is the fused camera-plus-lidar case, where both are counted and both can be
|
|
483
|
+
non-zero. `None` means "this slice holds no datarow of that type", never zero.
|
|
484
|
+
|
|
485
|
+
`get_dataslice` and `get_dataslice_by_name` return `metadata`; `list_dataslices` answers
|
|
486
|
+
with plain dicts carrying only `id`, `name` and `file_count` — the slice's image and pcd
|
|
487
|
+
datarows counted together.
|
|
488
|
+
|
|
489
|
+
This is the only method that takes a name: everything downstream — `convert_model`
|
|
490
|
+
included — takes ids, so this is how a name becomes one.
|
|
491
|
+
|
|
492
|
+
Raises `ValueError` when the project holds no dataslice of that name.
|
|
493
|
+
|
|
494
|
+
### Create Dataslice from Dataset
|
|
495
|
+
|
|
496
|
+
`create_dataslice_from_dataset` turns a whole dataset into a dataslice — the equivalent of
|
|
497
|
+
opening it in Data Visualization and hitting **Save Data Slice** without narrowing the
|
|
498
|
+
selection. It is **asynchronous**: the returned dataslice starts out `creating` with no
|
|
499
|
+
file count, and turns `ready` once the datarows are in.
|
|
500
|
+
|
|
501
|
+
```Python
|
|
502
|
+
dataslice = client.create_dataslice_from_dataset(
|
|
503
|
+
project_id=101,
|
|
504
|
+
dataset_id=5,
|
|
505
|
+
dataslice_name="whole-dataset-slice",
|
|
506
|
+
)
|
|
507
|
+
# OR from the project object
|
|
508
|
+
dataslice = project.create_dataslice_from_dataset(
|
|
509
|
+
dataset_id=5, dataslice_name="whole-dataset-slice"
|
|
510
|
+
)
|
|
511
|
+
|
|
512
|
+
# Poll until it settles
|
|
513
|
+
import time
|
|
514
|
+
|
|
515
|
+
from dataverse_sdk import DataSliceStatus
|
|
516
|
+
|
|
517
|
+
SETTLED = (DataSliceStatus.READY, DataSliceStatus.CREATING_FAIL)
|
|
518
|
+
while dataslice.status not in SETTLED:
|
|
519
|
+
time.sleep(10)
|
|
520
|
+
dataslice = client.get_dataslice(dataslice_id=dataslice.id)
|
|
521
|
+
print(dataslice.status, dataslice.image_count) # "ready" 11
|
|
522
|
+
```
|
|
523
|
+
|
|
524
|
+
A convert record polls the same way through `get_convert_record`, with
|
|
525
|
+
`ConvertRecordStatus.READY` and `ConvertRecordStatus.FAILED` as its settled states.
|
|
526
|
+
|
|
527
|
+
| Argument name | Type | Default | Description |
|
|
528
|
+
| -------------- | ---- | ------- | -------------------------------------------------- |
|
|
529
|
+
| project_id | int | *-- | Project the dataset belongs to |
|
|
530
|
+
| dataset_id | int | *-- | Every datarow of this dataset goes into the slice |
|
|
531
|
+
| dataslice_name | str | *-- | Must be unused **site-wide** |
|
|
532
|
+
| description | str | None | |
|
|
533
|
+
|
|
534
|
+
`*--`: required argument without default
|
|
535
|
+
|
|
448
536
|
### Export Dataslice and Download
|
|
449
537
|
```Python
|
|
450
538
|
# Trigger export and get export record id
|
|
@@ -454,6 +542,12 @@ client.download_export_dataslice_data(dataslice_id=504, export_record_id=export_
|
|
|
454
542
|
|
|
455
543
|
```
|
|
456
544
|
|
|
545
|
+
> **Note:** Direct export via `export_dataslice` is limited to 1,000 records. For
|
|
546
|
+
> dataslices exceeding this limit, use
|
|
547
|
+
> [`tools/export_dataslice_large.py`](tools/export_dataslice_large.py) instead
|
|
548
|
+
> (see [Export Large Dataslice and download files](#export-large-dataslice-and-download-files)),
|
|
549
|
+
> which exports the dataslice in batches.
|
|
550
|
+
|
|
457
551
|
|
|
458
552
|
### List Models
|
|
459
553
|
|
|
@@ -470,6 +564,16 @@ project = client.get_project(project_id=1)
|
|
|
470
564
|
models = project.list_models()
|
|
471
565
|
```
|
|
472
566
|
|
|
567
|
+
Each model carries a `status`, which is what a listing is usually narrowed by:
|
|
568
|
+
|
|
569
|
+
```Python
|
|
570
|
+
from dataverse_sdk import MLModelStatus
|
|
571
|
+
|
|
572
|
+
ready = [model for model in models if model.status == MLModelStatus.READY]
|
|
573
|
+
```
|
|
574
|
+
|
|
575
|
+
`MLModelStatus`: `PROCESSING`, `READY`, `DELETING`.
|
|
576
|
+
|
|
473
577
|
#### Filtering by Model Type
|
|
474
578
|
|
|
475
579
|
You can filter models by type using strings or lists of strings. The SDK supports multiple model types:
|
|
@@ -501,7 +605,7 @@ models = client.list_models(
|
|
|
501
605
|
|
|
502
606
|
| Argument name | Type/Options | Default | Description |
|
|
503
607
|
| ------------- | ----------------------------------------------------------------- | ------------------- | ------------------------ |
|
|
504
|
-
| project_id | int |
|
|
608
|
+
| project_id | int | *-- | The project ID |
|
|
505
609
|
| client_alias | str | None | The client alias |
|
|
506
610
|
| type | "trained", "byom", "uploaded", list["trained", "byom", "uploaded] | ["trained", "byom"] | Model types to filter by |
|
|
507
611
|
|
|
@@ -532,6 +636,235 @@ status, label_file_path = model_record.get_label_file(save_path="./labels.txt",
|
|
|
532
636
|
status, onnx_model_path = model_record.get_onnx_model_file(save_path="./model.onnx", timeout=6000)
|
|
533
637
|
```
|
|
534
638
|
|
|
639
|
+
### Get Convert Model File
|
|
640
|
+
|
|
641
|
+
The `get_convert_model_file` method will download one of the stored artifacts of a convert record, selected by the `file_type` argument.
|
|
642
|
+
|
|
643
|
+
```Python
|
|
644
|
+
from dataverse_sdk import ConvertModelFileType
|
|
645
|
+
|
|
646
|
+
# Method 1: Using client
|
|
647
|
+
status, save_path = client.get_convert_model_file(
|
|
648
|
+
convert_record_id=5,
|
|
649
|
+
file_type=ConvertModelFileType.TRITON,
|
|
650
|
+
client_alias=client.alias,
|
|
651
|
+
)
|
|
652
|
+
|
|
653
|
+
# Method 2: Using convert record object
|
|
654
|
+
model_record = model.get_convert_record(convert_record_id=5)
|
|
655
|
+
status, save_path = model_record.get_convert_model_file(file_type=ConvertModelFileType.TRITON)
|
|
656
|
+
```
|
|
657
|
+
|
|
658
|
+
#### Available File Types
|
|
659
|
+
|
|
660
|
+
| Enum Value | String Value | File downloaded | Available when | Default `save_path` |
|
|
661
|
+
| ----------------------------------- | ----------------- | ---------------------------------------------------------------------- | ---------------------- | ------------------------- |
|
|
662
|
+
| `ConvertModelFileType.TRITON` | `"triton"` | Triton bundle (`.zip`) | always | `./triton.zip` |
|
|
663
|
+
| `ConvertModelFileType.MODEL` | `"model"` | Main artifact: `model.onnx` (format=onnx) or `trt.engine` (format=trt) | always | `./converted_model` |
|
|
664
|
+
| `ConvertModelFileType.RAW_ONNX` | `"raw_onnx"` | Intermediate onnx (fp16: `trt.onnx`; D-FINE int8: fp32 `model.onnx`) | format=trt | `./raw.onnx` |
|
|
665
|
+
| `ConvertModelFileType.CALIB_CACHE` | `"calib_cache"` | `trt_int8_calib.cache` (int8 scale table) | D-FINE + int8 only | `./trt_int8_calib.cache` |
|
|
666
|
+
|
|
667
|
+
When `save_path` is omitted, the filename is resolved in this order:
|
|
668
|
+
|
|
669
|
+
1. The name the server supplies in the response's `Content-Disposition` header — this is the artifact's real stored filename (e.g. `ptq.engine`, `triton_model.zip`), so it already reflects the convert format and precision.
|
|
670
|
+
2. The **Default `save_path`** in the table above, used only when the server sends no usable filename.
|
|
671
|
+
|
|
672
|
+
Pass an explicit `save_path` whenever you need a predictable location — it always takes precedence over the server's name.
|
|
673
|
+
|
|
674
|
+
#### Input Arguments
|
|
675
|
+
|
|
676
|
+
| Argument name | Type/Options | Default | Description |
|
|
677
|
+
| ----------------- | -------------------------------------------------------------- | ----------------------------- | -------------------------------------------------------------------- |
|
|
678
|
+
| convert_record_id | int | *-- | The convert record to download from |
|
|
679
|
+
| file_type | ConvertModelFileType, "triton", "model", "raw_onnx", "calib_cache" | ConvertModelFileType.TRITON | Which artifact to download |
|
|
680
|
+
| save_path | str | None | Local path to write the file; when omitted the server's filename is used (see above) |
|
|
681
|
+
| timeout | int | 3000 | Maximum timeout of the request |
|
|
682
|
+
| permission | str | "" | Sets the `X-Request-Source` header; pass the caller's permission source if required |
|
|
683
|
+
| client | DataverseClient | None | Client instance; if omitted, `client_alias` must be given |
|
|
684
|
+
| client_alias | str | None | Registered client alias; required when `client` is None |
|
|
685
|
+
|
|
686
|
+
`*--`: required argument without default
|
|
687
|
+
|
|
688
|
+
#### Return
|
|
689
|
+
|
|
690
|
+
`tuple[bool, str]` — `(status, save_path)`. `status` is `False` if the download failed, and `save_path` is the path that was written to.
|
|
691
|
+
|
|
692
|
+
<br>
|
|
693
|
+
|
|
694
|
+
|
|
695
|
+
### Convert Model to ONNX/TRT
|
|
696
|
+
|
|
697
|
+
`convert_model` starts a model conversion. It is **asynchronous**: the call returns the
|
|
698
|
+
ids of the created convert records, and the conversion itself finishes later.
|
|
699
|
+
|
|
700
|
+
```Python
|
|
701
|
+
from dataverse_sdk import ConvertFormat, ConvertPrecision, QuantizationMethod
|
|
702
|
+
|
|
703
|
+
# Method 1: Using client -- model 6418 is a YOLOv9, which is NMS-based
|
|
704
|
+
record_ids = client.convert_model(
|
|
705
|
+
model_id=6418,
|
|
706
|
+
name="onnx-fp16",
|
|
707
|
+
target_dataslice_id=504, # ids only; see Get Dataslice by Name
|
|
708
|
+
model_type=ConvertFormat.ONNX,
|
|
709
|
+
data_type=ConvertPrecision.FP16,
|
|
710
|
+
confidence_score=10,
|
|
711
|
+
nms_threshold=50,
|
|
712
|
+
client_alias=client.alias,
|
|
713
|
+
)
|
|
714
|
+
|
|
715
|
+
# Method 2: Using the model object -- model 7201 is a D-FINE, which is NMS-free
|
|
716
|
+
model = client.get_model(model_id=7201, client_alias=client.alias)
|
|
717
|
+
record_ids = model.convert(
|
|
718
|
+
name="trt-int8-ptq",
|
|
719
|
+
target_dataslice_id=504,
|
|
720
|
+
model_type=ConvertFormat.TRT,
|
|
721
|
+
data_type=ConvertPrecision.INT8,
|
|
722
|
+
quantizations=[QuantizationMethod.PTQ],
|
|
723
|
+
quantize_dataslice_id=508,
|
|
724
|
+
)
|
|
725
|
+
```
|
|
726
|
+
|
|
727
|
+
#### Input Arguments
|
|
728
|
+
|
|
729
|
+
| Argument name | Type/Options | Default | Description |
|
|
730
|
+
| ------------------ | ------------------------------------- | --------- | ------------------------------------------------------------------------------- |
|
|
731
|
+
| model_id | int | *-- | The source model to convert |
|
|
732
|
+
| name | str | *-- | Convert record name; must be unused **under this model** |
|
|
733
|
+
| target_dataslice_id| int | *-- | Dataslice the converted model is evaluated on |
|
|
734
|
+
| model_type | ConvertFormat \| str | *-- | Target format |
|
|
735
|
+
| data_type | ConvertPrecision \| str | *-- | Numeric precision; `fp32` is D-FINE only |
|
|
736
|
+
| confidence_score | int | 10 | Confidence threshold, 10-90 |
|
|
737
|
+
| iou | int | 50 | IoU threshold, 1-99 |
|
|
738
|
+
| topk | int | None | 50-300; 300 for D-FINE, 100 for every other structure |
|
|
739
|
+
| main_obj_low | int | 1024 | Main object size lower bound |
|
|
740
|
+
| main_obj_high | int | 9216 | Main object size upper bound |
|
|
741
|
+
| resolution_width | int | None | Defaults to the source model's own resolution |
|
|
742
|
+
| resolution_height | int | None | Defaults to the source model's own resolution |
|
|
743
|
+
| nms_threshold | int | None | 10-90; required for every structure except D-FINE |
|
|
744
|
+
| nms_class_agnostic | bool | None | **Rejected for D-FINE** |
|
|
745
|
+
| machine_type | str | None | |
|
|
746
|
+
| quantize_dataslice_id | int | None | Calibration dataslice; has to be given together with `quantizations` |
|
|
747
|
+
| quantizations | list[QuantizationMethod \| str] | None | Exactly one method; **required for `int8`, rejected for every other `data_type`**; only `PTQ` is supported for D-FINE |
|
|
748
|
+
| model_structure | ModelStructure \| str | None | The source model's architecture; sets the topk default and the D-FINE rules. Read back from the model when omitted |
|
|
749
|
+
|
|
750
|
+
`*--`: required argument without default
|
|
751
|
+
|
|
752
|
+
Every enum below is a `str` enum, so the member and its plain string are interchangeable:
|
|
753
|
+
|
|
754
|
+
| Enum | Members | Strings |
|
|
755
|
+
| -------------------- | ------------------------------------------------ | ------------------------------------------------------------------------------------------- |
|
|
756
|
+
| `ConvertFormat` | `ONNX`, `TRT` | `"onnx"`, `"trt"` |
|
|
757
|
+
| `ConvertPrecision` | `FP32`, `FP16`, `INT8` | `"fp32"`, `"fp16"`, `"int8"` |
|
|
758
|
+
| `QuantizationMethod` | `PTQ`, `QAT_TRAIN`, `QAT_DISTILL` | `"ptq"`, `"qat_train"`, `"qat_distill"` |
|
|
759
|
+
| `ModelStructure` | `YOLOV9_C`, `YOLOV9_E`, `YOLOV9_S` | `"yolov9-c"`, `"yolov9-e"`, `"yolov9-s"` |
|
|
760
|
+
| | `DFINE_N`, `DFINE_S`, `DFINE_M`, `DFINE_L`, `DFINE_X` | `"dfine-n"`, `"dfine-s"`, `"dfine-m"`, `"dfine-l"`, `"dfine-x"` |
|
|
761
|
+
|
|
762
|
+
`convert_model`, `get_convert_record`, `get_convert_record_by_name` and
|
|
763
|
+
`list_convert_records` are static methods, so they need `client_alias` (or `client`)
|
|
764
|
+
passed in; without either they raise `ValueError`. The dataslice methods above are
|
|
765
|
+
instance methods and fall back to the client's own alias.
|
|
766
|
+
|
|
767
|
+
Supported resolutions are `640x480`, `640x640`, `1024x576`, `1024x768` and `1024x1024`; an unsupported one raises `APIValidationError` without sending the request.
|
|
768
|
+
|
|
769
|
+
The server decides the rest, so these can change; at the time of writing:
|
|
770
|
+
|
|
771
|
+
| `model_structure` | `data_type` | `model_type` | `quantizations` |
|
|
772
|
+
| ----------------- | ----------- | --------------- | --------------------------------- |
|
|
773
|
+
| yolov9 | `fp16` | `onnx` or `trt` | none |
|
|
774
|
+
| yolov9 | `int8` | `trt` | `ptq`, `qat_train`, `qat_distill` |
|
|
775
|
+
| D-FINE | `fp32` | `onnx` | none |
|
|
776
|
+
| D-FINE | `fp16` | `trt` | none |
|
|
777
|
+
| D-FINE | `int8` | `trt` | `ptq` |
|
|
778
|
+
|
|
779
|
+
`int8` must carry exactly one quantization method and every other `data_type` must
|
|
780
|
+
carry none -- that holds for both families, so a yolov9 `int8` convert without
|
|
781
|
+
`quantizations` raises `APIValidationError` instead of reaching the backend. The
|
|
782
|
+
method itself is what differs: D-FINE's `int8` only takes `ptq`, while yolov9 takes
|
|
783
|
+
any of the three. A structure the SDK does not know is left to the server.
|
|
784
|
+
|
|
785
|
+
#### Return
|
|
786
|
+
|
|
787
|
+
`list[int]` — ids of the created convert records, one per quantization method. The
|
|
788
|
+
backend takes only one quantization method for now, so today the list always holds
|
|
789
|
+
exactly one id.
|
|
790
|
+
|
|
791
|
+
#### Keeping it to one request
|
|
792
|
+
|
|
793
|
+
Both dataslices are given by id, so the only extra request left is the read-back of the
|
|
794
|
+
source model — and passing `model_structure` **together with both resolutions** skips
|
|
795
|
+
that too, which is what `model.convert()` does with the three it already holds. Chaining
|
|
796
|
+
from objects you already have is therefore the cheapest form:
|
|
797
|
+
|
|
798
|
+
```Python
|
|
799
|
+
model = client.get_model(model_id=6418, client_alias=client.alias)
|
|
800
|
+
dataslice = project.get_dataslice_by_name("my-eval-dataslice")
|
|
801
|
+
|
|
802
|
+
record_ids = model.convert(
|
|
803
|
+
name="onnx-fp16",
|
|
804
|
+
target_dataslice_id=dataslice.id,
|
|
805
|
+
model_type=ConvertFormat.ONNX,
|
|
806
|
+
data_type=ConvertPrecision.FP16,
|
|
807
|
+
nms_threshold=50,
|
|
808
|
+
)
|
|
809
|
+
|
|
810
|
+
record = client.get_convert_record(convert_record_id=record_ids[0], client_alias=client.alias)
|
|
811
|
+
record.status
|
|
812
|
+
```
|
|
813
|
+
|
|
814
|
+
<br>
|
|
815
|
+
|
|
816
|
+
|
|
817
|
+
### Retrieve Convert Record and its Metrics
|
|
818
|
+
|
|
819
|
+
A convert name is only unique **per source model** — two models may each own a record
|
|
820
|
+
called `onnx-fp16` — so a lookup by name takes the model alongside it.
|
|
821
|
+
|
|
822
|
+
```Python
|
|
823
|
+
# By id
|
|
824
|
+
record = client.get_convert_record(convert_record_id=2212, client_alias=client.alias)
|
|
825
|
+
|
|
826
|
+
# By name, under a given model
|
|
827
|
+
record = client.get_convert_record_by_name(
|
|
828
|
+
model_id=6418, convert_name="onnx-fp16", client_alias=client.alias
|
|
829
|
+
)
|
|
830
|
+
# OR from the model object
|
|
831
|
+
model = client.get_model(model_id=6418, client_alias=client.alias)
|
|
832
|
+
record = model.get_convert_record_by_name(convert_name="onnx-fp16")
|
|
833
|
+
|
|
834
|
+
record.status # ConvertRecordStatus
|
|
835
|
+
record.id
|
|
836
|
+
record.model_type # "onnx" / "trt" -- reads configuration["format"]
|
|
837
|
+
record.data_type # "fp32"/"fp16"/"int8" -- reads configuration["precision"]
|
|
838
|
+
record.f1_score # and .precision, .recall, .map_5_95
|
|
839
|
+
```
|
|
840
|
+
|
|
841
|
+
`record.configuration` carries every other convert setting. The four metrics read as
|
|
842
|
+
`0.0` until the conversion finishes, and `None` when the server did not return them at all
|
|
843
|
+
— mind that `record.precision` is one of them, and the precision the model was converted
|
|
844
|
+
at is `record.data_type`.
|
|
845
|
+
|
|
846
|
+
Looking a record up by name, filtering a listing, and reading the ids back from
|
|
847
|
+
`convert_model` all need a Dataverse recent enough to serialise them; against an older
|
|
848
|
+
site the SDK falls back to filtering the full listing itself.
|
|
849
|
+
|
|
850
|
+
#### List Convert Records
|
|
851
|
+
|
|
852
|
+
```Python
|
|
853
|
+
# Every convert record in a project
|
|
854
|
+
records = client.list_convert_records(project_id=1992, client_alias=client.alias)
|
|
855
|
+
# OR
|
|
856
|
+
records = project.list_convert_records()
|
|
857
|
+
|
|
858
|
+
# Narrow by model / name / status
|
|
859
|
+
records = client.list_convert_records(
|
|
860
|
+
model_id=6418, status="ready", client_alias=client.alias
|
|
861
|
+
)
|
|
862
|
+
# OR
|
|
863
|
+
records = model.list_convert_records(status="ready")
|
|
864
|
+
```
|
|
865
|
+
|
|
866
|
+
<br>
|
|
867
|
+
|
|
535
868
|
|
|
536
869
|
### Create VQA Project
|
|
537
870
|
|
|
@@ -555,8 +888,8 @@ project = client.create_vqa_project(name="vqa-project", sensor_name="camera1", o
|
|
|
555
888
|
|
|
556
889
|
| Argument name | Type/Options | Default | Description |
|
|
557
890
|
| :--- | :--- | :--- | :--- |
|
|
558
|
-
| name | str |
|
|
559
|
-
| sensor_name | str |
|
|
891
|
+
| name | str | *-- | name of your project |
|
|
892
|
+
| sensor_name | str | *-- | the camera sensor name |
|
|
560
893
|
| ontology_name | str | *-- | the ontology name |
|
|
561
894
|
| question_answer| list[QuestionClass] | *-- | your question/answer_type. `QuestionClass.answer_type` valid values: `boolean`, `option`, `number`, `text` |
|
|
562
895
|
| description | str | None | your project description |
|