fomo_confusion_matrix
最后更新
luxonis_train.attached_modules.metrics.confusion_matrix.fomo_confusion_matrixFOMO 的混淆矩阵,它将每个预测点周围的小框与目标框进行匹配。类
FomoConfusionMatrix
输入::keypoints(list[Tensor]): 每张图像 [Ki, 1, 4],(x, y, prob, class),像素target_boundingbox(Tensor): [N, 6],[batch, class, x, y, w, h],xywh归一化
输出::mcc(Tensor): 整个矩阵的标量 MCC,请参阅 compute_mccconfusion_matrix(Tensor): [nclasses + 1, nclasses + 1] 计数,行是目标,最后一行和列是背景
公式:: update 会丢弃每个概率低于0.5的关键点。它将每个其他关键点转换为围绕该点的5x5像素框,并裁剪到图像。然后 DetectionConfusionMatrix 使用 IoU 阈值0计算这些框。因此,当关键点框和目标框共享的面积大于0时,目标框和关键点匹配。DetectionConfusionMatrix 的其他规则保持不变。
参考
- 来源:本项目。
- 许可证:Apache-2.0 (本项目)
注意
该指标始终使用 IoU 阈值
0。iou_threshold 不为 None 和 0 时会记录警告。示例
在
model.nodes 中附加到 FOMOHead:Yaml
1- name: FOMOHead
2 inputs: [EfficientRep]
3 metrics:
4 - name: FomoConfusionMatrix兼容::- 节点: FOMOHead
方法
init
Python
1def __init__(iou_threshold: float | None = None, **kwargs):0 初始化指标。参数iou_threshold(float | None): 忽略。非None和0.0的值会记录警告。**kwargs: 转发给 DetectionConfusionMatrix 的关键字参数,例如node。
update
Python
1def update(keypoints: list[Tensor], target_boundingbox: Tensor):0.5 的关键点。它将每个其他关键点转换为围绕该点的 5x5 像素框。它将框裁剪到 BaseAttachedModule.original_in_shape 的高度和宽度。然后 DetectionConfusionMatrix 计数这些框。示例
一个类别
0 的目标框覆盖从 0 到 5 的像素。第一个关键点位于其中。第二个关键点的概率低于 0.5,因此指标将其丢弃。SimpleNamespace 代表节点。Pycon
1>>> import torch
2>>> from types import SimpleNamespace
3>>> node = SimpleNamespace(
4... task=None,
5... n_classes=1,
6... original_in_shape=torch.Size([3, 10, 10]),
7... )
8>>> metric = FomoConfusionMatrix(node=node)
9>>> target = torch.tensor([[0, 0, 0.0, 0.0, 0.5, 0.5]])
10>>> points = [
11... torch.tensor([[[2.0, 2.0, 0.9, 0]], [[8.0, 8.0, 0.3, 0]]])
12... ]
13>>> metric.update(points, target)
14>>> metric.confusion_matrix.tolist()
15[[1, 0], [0, 0]]keypoints(list[Tensor]): 每张图像的关键点,形状为[K_i, 1, 4],表示为像素中的[x, y, probability, class]。列表的长度是批次大小。target_boundingbox(Tensor): 批次的boundingbox标签,形状为[N, 6],表示为[batch_index, class, x, y, w, h]。这些值是归一化的,x和y是左上角。该方法将xyxy像素写入其中。