计算机视觉中的目标检测:从YOLOv3到YOLOv7
1. 目标检测中的平均精度计算
在目标检测中,平均精度(mAP)是评估模型性能的重要指标。以下是计算平均精度的代码实现:
# a dictionary for true_bboxes number on each image
for key, val in amount_bboxes.items():
amount_bboxes[key] = torch.zeros(val) #===================line 15
detections.sort(key=lambda x: x[2], reverse=True) #==========line 16
TP = torch.zeros((len(detections)))
FP = torch.zeros((len(detections)))
total_true_bboxes = len(ground_truths) #total true_bboxes in class c
if total_true_bboxes == 0:
continue # If no true_bboxes for class c, skip the following codes
for detection_idx, detection in enumerate(detections):
#===line 22
trueBboxesOnllmg = [ #Pick out all true bboxes on an image
bbox for bbox in ground_
超级会员免费看
订阅专栏 解锁全文
2442

被折叠的 条评论
为什么被折叠?



