Unverified 提交 567397d6 authored 作者: jbutle55's avatar jbutle55 提交者: GitHub

Fix confusion matrix update when no predictions are made (#8748)

* Fix confusion matrix update when no predictions are made * Update metrics.py * Simply confusion matrix changes * Simply confusion matrix fix Co-authored-by: 's avatarGlenn Jocher <glenn.jocher@ultralytics.com>
上级 587a3a37
......@@ -139,6 +139,12 @@ class ConfusionMatrix:
Returns:
None, updates confusion matrix accordingly
"""
if detections is None:
gt_classes = labels.int()
for i, gc in enumerate(gt_classes):
self.matrix[self.nc, gc] += 1 # background FN
return
detections = detections[detections[:, 4] > self.conf]
gt_classes = labels[:, 0].int()
detection_classes = detections[:, 5].int()
......
......@@ -228,6 +228,8 @@ def run(
if npr == 0:
if nl:
stats.append((correct, *torch.zeros((2, 0), device=device), labels[:, 0]))
if plots:
confusion_matrix.process_batch(detections=None, labels=labels[:, 0])
continue
# Predictions
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论