在 Deep Lake 中htype的参数

在 Deep Lake 中,htype(即 high-level type)用于定义张量的语义类型(如图像、标签、文本等),而每个 htype 可以通过一些参数进一步配置其行为和存储方式。


通用参数(适用于大多数 htype

这些参数可以与任意 htype 一起使用:

参数名 类型 默认值 说明
dtype str 或 numpy.dtype 自动推断 NumPy 数据类型(例如 'int64', 'float32'
sample_compression str None 压缩格式(如 'jpeg', 'png', 'gzip'
chunk_compression str None 整个 chunk 的压缩方式(用于非样本级数据)
max_shape tuple (None,) * ndim 最大形状(用于可变长度张量)
is_sequence bool False 是否为序列数据(如视频帧或文本序列)
is_link bool False 是否为链接张量(指向外部文件)

支持的 htype 及其专属参数

以下是一些常见 htype 的说明及其专属参数(如果有的话)。


image

用于图像数据。

参数 类型 默认值 说明
sample_compression str 'jpeg' 常见取值:'jpeg', 'png'
format str 'RGB' 图像颜色空间(如 'RGB', 'BGR', 'L'
ds.create_tensor("images", htype="image", sample_compression="jpeg", dtype="uint8")

video

用于视频数据(多帧图像)。

参数 类型 默认值 说明
sequence_length int None 视频帧数(固定长度时设置)
sample_compression str 'mp4' 支持 'mp4', 'avi', 'frame_sequence'
ds.create_tensor("videos", htype="video", sample_compression="mp4")

audio

音频波形数据。

参数 类型 默认值 说明
sample_rate int None 音频采样率(Hz)
format str 'PCM' 音频编码格式(如 'PCM', 'MP3'
ds.create_tensor("audios", htype="audio", sample_rate=44100, dtype="float32")

text

字符串文本数据。

参数 类型 默认值 说明
decode_method str 'utf-8' 解码方式
dtype str 'U' Unicode 字符串类型
ds.create_tensor("texts", htype="text")

json

JSON 格式结构化数据。

参数 类型 默认值 说明
dtype str 'O' 表示对象类型(Python dict)
ds.create_tensor("annotations", htype="json")

bbox

边界框坐标,用于目标检测任务。

参数 类型 默认值 说明
dtype str 'float32' 坐标类型
coords dict {} 指定坐标系统(如 {'x': 'rel', 'y': 'rel'}

支持的坐标形式:

  • "rel":相对坐标(范围 [0,1])
  • "px":像素坐标(绝对值)
ds.create_tensor("bboxes", htype="bbox", coords={"x": "rel", "y": "rel"})

bbox_3d

三维边界框。

参数 类型 默认值 说明
dtype str 'float32' 坐标类型
coords dict {} 三维坐标系统描述

class_label

分类标签。

参数 类型 默认值 说明
dtype str 'int64' 标签数据类型
class_names list[str] None 分类名称列表
ds.create_tensor("labels", htype="class_label", class_names=["cat", "dog"])

binary_mask

二值分割掩码。

参数 类型 默认值 说明
dtype str 'bool' 掩码值类型(True/False)
ds.create_tensor("masks_binary", htype="binary_mask")

segment_mask

多类别分割掩码。

参数 类型 默认值 说明
dtype str 'uint8' 每个像素是一个类别 ID
class_names list[str] None 分类名称列表
ds.create_tensor("masks_segment", htype="segment_mask", class_names=["background", "person", "car"])

point, point_3d

关键点坐标。

参数 类型 默认值 说明
dtype str 'float32' 坐标数据类型
coords dict {} 坐标系统描述(如 "rel", "px"
ds.create_tensor("keypoints", htype="point", coords={"x": "rel", "y": "rel"})

polygon

多边形坐标。

参数 类型 默认值 说明
dtype str 'float32' 坐标类型
coords dict {} 坐标系统描述

pose

姿态信息(如人体姿态估计)。

参数 类型 默认值 说明
dtype str 'float32' 坐标类型
keypoints list[str] None 关键点名称列表
ds.create_tensor("poses", htype="pose", keypoints=["left_eye", "right_eye", ...])

embedding

特征向量嵌入(如模型输出)。

参数 类型 默认值 说明
dtype str 'float32' 向量元素类型
dim int None 向量维度(可选)
ds.create_tensor("embeddings", htype="embedding", dim=512)

generic

通用张量类型,适用于没有预设语义的数据。

参数 类型 默认值 说明
dtype str 'float32' 默认类型,可更改
ds.create_tensor("data", htype="generic", dtype="float64")

optical_flow

光流数据(视频中物体运动矢量场)。

参数 类型 默认值 说明
dtype str 'float32' 矢量类型

depth

深度图数据(如 RGB-D 相机获取)。

参数 类型 默认值 说明
dtype str 'float32' 深度值类型
unit str 'meter' 单位(如 'mm', 'meter'

time_series

时间序列数据(如传感器数据)。

参数 类型 默认值 说明
dtype str 'float32' 数据类型
timestamp_unit str 'ms' 时间戳单位(如 's', 'ms'

link

指向外部资源(如 URL 或本地路径)。

参数 类型 默认值 说明
ref str None 外部资源引用(URL 或路径)
ds.create_tensor("links", htype="link", ref="https://example.com/data/")

你可能感兴趣的:(DeepLake,深度学习,pytorch,神经网络,机器学习)