classification
最后更新
depthai_nodes.message.creators.classificationFunctions
create_classification_message
Python
1def create_classification_message(classes: list[str], scores: np.ndarray | list) -> dai.beta.Classifications:classes(list[str]): 非空的类名列表。scores(np.ndarray | list): 与classes对应的浮点概率。值必须介于 0 和 1 之间,并且在 0.1 的绝对容差内总和为 1。接受可以展平为每个类一个概率的列表或数组。
dai.beta.Classifications: 包含排序后的类名和分数的原生分类消息。分数相同的类保留其输入顺序。
ValueError: 如果类或分数为空、类型不受支持、长度不同或分数不是有效的浮点概率。
create_classification_sequence_message
Python
1def create_classification_sequence_message(classes: list[str], scores: np.ndarray | list, ignored_indexes: list[int] | None = None, remove_duplicates: bool = False, concatenate_classes: bool = False) -> dai.beta.Classifications:classes(list[str]): 类名,由scores的列索引。scores(np.ndarray | list): 形状为(sequence_length, n_classes)的数组或嵌套列表。每行必须包含介于 0 和 1 之间的概率,并且在 0.01 的绝对容差内总和为 1。ignored_indexes(list[int] | None): 要省略的类索引,例如填充或背景类。remove_duplicates(bool): 在过滤忽略的索引之前,删除相邻的重复获胜类。concatenate_classes(bool): 如果所有选定的类名最多只有一个字符,则将它们连接成用空格分隔的单词,并计算每个单词内的平均分数。
dai.beta.Classifications: 包含按序列顺序排列的选定类名和分数的原生分类消息。
ValueError: 如果类不是列表,分数具有不兼容的维度或无效的概率,或者忽略的索引不是有效的整数类索引列表。