classification
最后更新
depthai_nodes.node.parsers.classification类
ClassificationParser
classes 和 scores 属性的对象。classes 是按分数降序排列的类别列表。scores 是对应的分数列表。方法
init
Python
1def __init__(output_layer_name: str = '', classes: list[str] = None, is_softmax: bool = True):output_layer_name(str):与解析器相关的输出层的名称。classes(list[str]):用于与各自得分关联的类名列表。预期与神经网络的输出顺序相同。如果未提供,消息将只返回排序后的得分。is_softmax(bool):如果为 False,则使用 softmax 函数将得分转换为概率。
build
Python
1def build(head_config: dict[str, Any]) -> ClassificationParser:head_config(dict[str, Any]):解析器的头部配置。
ClassificationParser:设置了头部配置的解析器对象。
compute
Python
1def compute(scores: np.ndarray, *, is_softmax: bool = True) -> np.ndarray:注意
使用 depthai_nodes.node.parsers.utils.classification.compute_classification_scores;有关张量布局和验证详细信息,请参阅该帮助程序。
scores(np.ndarray):模型得分张量。is_softmax(bool):得分是否已包含概率。如果为 false,则应用 softmax。
np.ndarray:一维数组,每个类别一个得分。
emit
Python
1def emit(output: dai.NNData, scores: np.ndarray):dai.beta.Classifications 消息并将其发送到 out。复制源时间戳和序列号,并在存在时携带源图像转换。参数output(dai.NNData):携带张量和源时间戳、序列号以及可选图像转换的神经网络输出。scores(np.ndarray):与计算出的有效载荷对应的置信度得分。
extract
Python
1def extract(output: dai.NNData) -> np.ndarray:output(dai.NNData):携带张量和源时间戳、序列号以及可选图像转换的神经网络输出。
np.ndarray:展平的反量化类得分。当设置了非零类计数时,它们的计数必须与配置的类匹配。
ValueError:如果未配置输出名称且消息不包含恰好一个层,或者未满足配置的类要求。
run
Python
1def run(self):setClasses
Python
1def setClasses(classes: list[str]):classes(list[str]):用于与各自得分关联的类名列表。
setOutputLayerName
Python
1def setOutputLayerName(output_layer_name: str):output_layer_name(str):输出层的名称。
setSoftmax
Python
1def setSoftmax(is_softmax: bool):is_softmax(bool):如果为 False,解析器将使用 softmax 函数将得分转换为概率。