属性
会话元信息。全部来自容器头或明文探测,用户零配置。只读属性从 meta() 派生;头里缺的字段为 None / 0 / 空列表,不编默认 640/80/17。
调用代价:读会话缓存的头信息,微秒级。会话已关闭再调抛 InternalError。
属性
| 属性 | 类型 | 说明 |
|---|---|---|
| task | str | None | detect / classify / segment / pose / ocr / anomaly。缺席为 None,不编 detect |
| labels | list[str] | 类别标签。缺席或非数组则为空列表 |
| input_width | int | 模型输入宽。未知为 0 |
| input_height | int | 模型输入高。未知为 0 |
| channels | int | 模型输入通道数。未知为 0 |
| layout | str | None | 张量布局。先读 input.layout,再读顶层 layout |
| payload_kind | str | None | onnx / trt-engine / openvino / rknn / paddle |
| provider_id | str | None | 实际选中的 Provider ID(不是 prefer 入参) |
| encrypted | bool | 是否容器会话。明文模型为 False |
JSON 路径映射见 类型 · 会话元信息。标准字段表见 元数据。
查询
meta()
def meta(self) -> dict
读会话元信息,返回 JSON 对象。
返回值:
dict— schema 见 类型 · 会话元信息
备注
首次向 native 取一次并缓存。内容:task / labels / 输入宽高与通道 / Layout / Mean / Std / PayloadKind / 实际选中的 Provider / 是否容器 / 授权摘要(去敏,含试用剩余次数)。
示例:
print(s.meta())
task
@property
def task(self) -> str | None
任务短名。缺席为 None,不编 detect。
返回值:
str | None—detect/classify/segment/pose/ocr/anomaly
labels
@property
def labels(self) -> list[str]
类别标签列表。缺席或非数组则为空列表。
返回值:
list[str]— 类别名,声明序即 id 序
input_width
@property
def input_width(self) -> int
模型输入宽。未知为 0。
返回值:
int— 像素;未知为0
input_height
@property
def input_height(self) -> int
模型输入高。未知为 0。
返回值:
int— 像素;未知为0
channels
@property
def channels(self) -> int
模型输入通道数。未知为 0。
返回值:
int— 通道数;未知为0
layout
@property
def layout(self) -> str | None
张量布局。先读 input.layout,没有再读顶层 layout。
返回值:
str | None— 如NCHW/NHWC。缺席为None,不编NCHW
payload_kind
@property
def payload_kind(self) -> str | None
载荷类型。
返回值:
str | None—onnx/trt-engine/openvino/rknn/paddle
备注
Paddle 是运行时载荷。rknn 只在 linux-arm64;Windows 打开即 UnsupportedPayloadError。
provider_id
@property
def provider_id(self) -> str | None
实际选中的 Provider ID(不是 prefer_provider 入参)。
返回值:
str | None— 如onnx-cuda/onnx-cpu
encrypted
@property
def encrypted(self) -> bool
是否加密容器会话。明文模型为 False。
返回值:
bool— 容器会话为True