yolo
最后更新
depthai_nodes.node.parsers.yolo类
YOLOComputeInputs
YOLOExtendedParser.extract() 创建并由 compute() 消费。字段对应于 depthai_nodes.node.parsers.utils.yolo.compute_yolo_detections 的参数。可选的姿态和掩码字段仅在选定的模型模式下填充。即使数据类字段不能重新分配,数组内容仍然可变。属性
anchors
conf_threshold
input_shape
iou_threshold
keypoint_edges
keypoint_label_names
kpts_outputs
label_names
layer_names
mask_conf
masks_outputs_values
max_det
n_classes
n_keypoints
outputs_values
protos_len
protos_output
strides
subtype
v26_mask_coeffs
v26_pose_kpts
v26_protos
YOLOExtendedParser
Note
发出
dai.ImgDetections 消息。dai.ImgDetections 消息包含边界框、标签、标签名称、置信度分数以及检测对象的关键点或掩码和原型。方法
init
Python
1def __init__(conf_threshold: float = 0.5, n_classes: int = 1, label_names: list[str] | None = None, iou_threshold: float = 0.5, mask_conf: float = 0.5, n_keypoints: int = 17, max_det: int = 300, anchors: list[list[list[float]]] | None = None, subtype: str = '', keypoint_label_names: list[str] | None = None, keypoint_edges: list[tuple[int, int]] | None = None):conf_threshold(float): 检测的置信度阈值n_classes(int): 模型中的类别数量label_names(list[str] | None): 类别的名称iou_threshold(float): 交并比阈值mask_conf(float): 掩码置信度阈值n_keypoints(int): 模型中的关键点数量max_det(int): 要保留的最大检测数量。anchors(list[list[list[float]]] | None): YOLO 模型的锚点subtype(str): YOLO 模型的版本keypoint_label_names(list[str] | None): 关键点的标签keypoint_edges(list[tuple[int, int]] | None): 关键点的连接对。示例:[(0,1), (1,2), (2,3), (3,0)] 表示关键点 0 连接到关键点 1,关键点 1 连接到关键点 2,依此类推。
build
Python
1def build(head_config: dict[str, Any]):head_config(dict[str, Any]): 解析器的头部配置。
YOLOExtendedParser: 设置了头部配置的解析器对象。
compute
Python
1def compute(inputs: YOLOComputeInputs) -> dict[str, Any]:Note
inputs(YOLOComputeInputs):extract()返回的张量和配置包。
dict[str, Any]: 包含mode(0 检测,1 姿态,2 分割)、归一化的bboxes、scores、labels、label_names、keypoints、keypoints_scores、keypoint_label_names、keypoint_edges和masks的字典。框使用中心 XY/宽度/高度。分割掩码包含 int16 检测索引和 -1 背景;其他模式的掩码返回None。
emit
Python
1def emit(output: dai.NNData, payload: dict[str, Any]):dai.ImgDetections 消息并将其发送到 out。复制源时间戳和序列号,并在存在时携带源图像转换。参数output(dai.NNData): 携带张量和源时间戳、序列号以及可选图像转换的神经网络输出。payload(dict[str, Any]):compute()返回的字典,包含模式特定的框、分数、标签、关键点和掩码。
extract
Python
1def extract(output: dai.NNData) -> YOLOComputeInputs:output(dai.NNData): 携带张量和源时间戳、序列号以及可选图像转换的神经网络输出。
YOLOComputeInputs: 一个YOLOComputeInputs包,包含反量化张量、解析的图像几何、步幅和当前解析器设置。
ValueError: 如果 YOLO26 没有配置的输入形状,或者头部步幅无法解析。
run
Python
1def run(self):setAnchors
Python
1def setAnchors(anchors: list[list[list[float]]]):anchors(list[list[list[float]]]): YOLO 模型的锚点。
setConfidenceThreshold
Python
1def setConfidenceThreshold(threshold: float):threshold(float): 检测对象的置信度分数阈值。
setIouThreshold
Python
1def setIouThreshold(iou_threshold: float):iou_threshold(float): 交并比阈值。
setKeypointEdges
Python
1def setKeypointEdges(keypoint_edges: list[tuple[int, int]]):keypoint_edges(list[tuple[int, int]]): 关键点的边缘。
setKeypointLabelNames
Python
1def setKeypointLabelNames(keypoint_label_names: list[str]):keypoint_label_names(list[str]): 关键点的标签。
setLabelNames
Python
1def setLabelNames(label_names: list[str]):label_names(list[str]): 类别的名称。
setMaskConfidence
Python
1def setMaskConfidence(mask_conf: float):mask_conf(float): 掩码置信度阈值。
setNumClasses
Python
1def setNumClasses(n_classes: int):n_classes(int): 模型中的类别数量。
setNumKeypoints
Python
1def setNumKeypoints(n_keypoints: int):n_keypoints(int): 模型中的关键点数量。
setOutputLayerNames
Python
1def setOutputLayerNames(output_layer_names: list[str]):output_layer_names(list[str]): 解析器的输出层名称。
setStrides
Python
1def setStrides(strides: list[int] | tuple[int, ...]):strides(list[int] | tuple[int, ...]): YOLO 输出头部的步幅。
setSubtype
Python
1def setSubtype(subtype: str):subtype(str): YOLO 模型的子类型。
属性
anchors
conf_threshold
input_shape
iou_threshold
keypoint_edges
[(0, 1), (1, 2)] 将关键点 0 连接到 1,将 1 连接到 2。