# types

Python API: `hubai_sdk.utils.types`

模型元数据和转换配置使用的枚举。

服务 API 通常直接接受这些枚举。它们的 `value` 是发送到 HubAI 的拼写，而 `name` 用于一些列表过滤器。使用
[Target](/cloud/hubai/model-registry/hubai-sdk/hubai-sdk-api-reference/utils/types.md) 选择转换硬件，使用
[ModelType](/cloud/hubai/model-registry/hubai-sdk/hubai-sdk-api-reference/utils/types.md) 描述现有工件。

## 类

### DataType

支持的模型格式共享的张量元素类型。

#### 方法

##### as_nn_archive_dtype

```python
def as_nn_archive_dtype(self) -> str:
```

将此数据类型转换为 NN Archive 数据类型拼写。

##### as_numpy_dtype

```python
def as_numpy_dtype(self) -> np.dtype:
```

将此数据类型转换为相应的 NumPy 数据类型。

##### as_openvino_dtype

```python
def as_openvino_dtype(self) -> str:
```

将此数据类型转换为相应的 OpenVINO 数据类型。

##### as_snpe_dtype

```python
def as_snpe_dtype(self) -> str:
```

将此数据类型转换为相应的 SNPE 数据类型。

##### from_dlc_dtype

```python
def from_dlc_dtype(dtype: str) -> DataType:
```

从 SNPE DLC 数据类型名称创建
[DataType](/cloud/hubai/model-registry/hubai-sdk/hubai-sdk-api-reference/utils/types.md)。

##### from_ir_ie_dtype

```python
def from_ir_ie_dtype(dtype: str) -> DataType:
```

从 OpenVINO IR 数据类型字符串创建
[DataType](/cloud/hubai/model-registry/hubai-sdk/hubai-sdk-api-reference/utils/types.md)。

##### from_ir_runtime_dtype

```python
def from_ir_runtime_dtype(dtype: str) -> DataType:
```

从 OpenVINO 运行时数据类型字符串创建
[DataType](/cloud/hubai/model-registry/hubai-sdk/hubai-sdk-api-reference/utils/types.md)。

##### from_numpy_dtype

```python
def from_numpy_dtype(dtype: np.dtype) -> DataType:
```

从 NumPy 数据类型创建
[DataType](/cloud/hubai/model-registry/hubai-sdk/hubai-sdk-api-reference/utils/types.md)。

##### from_onnx_dtype

```python
def from_onnx_dtype(dtype: int) -> DataType:
```

从 ONNX 张量数据类型值创建
[DataType](/cloud/hubai/model-registry/hubai-sdk/hubai-sdk-api-reference/utils/types.md)。

##### from_tensorflow_dtype

```python
def from_tensorflow_dtype(dtype: int) -> DataType:
```

从 TFLite 张量数据类型值创建
[DataType](/cloud/hubai/model-registry/hubai-sdk/hubai-sdk-api-reference/utils/types.md)。

#### 属性

##### BOOLEAN

##### FLOAT16

##### FLOAT32

##### FLOAT64

##### FXP16

##### FXP32

##### FXP64

##### FXP8

##### INT16

##### INT32

##### INT4

##### INT64

##### INT8

##### STRING

##### UFXP16

##### UFXP32

##### UFXP64

##### UFXP8

##### UINT16

##### UINT32

##### UINT64

##### UINT8

### Encoding

图像张量和预处理的通道顺序。

#### 属性

##### BGR

##### GRAY

##### NONE

##### RGB

### InputFileType

支持的源模型容器或框架格式。

#### 方法

##### from_path

```python
def from_path(path: str | Path) -> InputFileType:
```

从模型路径后缀推断输入文件类型。

#### 属性

##### DLC

##### HAR

##### IR

##### ONNX

##### PYTORCH

##### TFLITE

### ModelType

HubAI 模型实例存储的工件类型。

#### 方法

##### from_suffix

```python
def from_suffix(suffix: str) -> ModelType:
```

从文件后缀推断模型类型。

#### 属性

##### HAILO

##### IR

##### ONNX

##### PYTORCH

##### RVC2

##### RVC3

##### RVC4

##### TFLITE

### PotDevice

OpenVINO 训练后优化工具使用的目标设备。

#### 属性

##### ANY

##### VPU

### ResizeMethod

将图像尺寸调整为模型输入的策略。

#### 属性

##### CROP

##### PAD

##### RESIZE

### Target

托管转换接受的硬件系列。

#### 属性

##### HAILO

##### RVC2

##### RVC3

##### RVC4
