【目标检测】评价指标:mAP概念及其代码实现(yolo源码/pycocotools)

这篇具有很好参考价值的文章主要介绍了【目标检测】评价指标:mAP概念及其代码实现(yolo源码/pycocotools)。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

本篇文章首先介绍目标检测任务中的关键评价指标mAP的概念;然后介绍其在yolo源码pycocotools工具中的实现方法;最后比较两种mAP的计算方法的不同之处。

目标检测中的评价指标:

mAP概念及其代码实现(yolo源码/pycocotools)
混淆矩阵概念及其代码实现(yolo源码)

1 概念

  在分类任务中,多以精确率/查准率(Precision, P)召回率/查全率(Recall, R)作为类别预测的评价指标,其计算方法如下:
P = T P T P + F P P = {{TP} \over {TP + FP}} P=TP+FPTP
R = T P T P + F N R = {{TP} \over {TP + FN}} R=TP+FNTP
其中 T P TP TP表示目标被预测为正样本且实际为正样本数量; F P FP FP表示预测为正样本但实际为负样本的数量; F N FN FN表示预测为负样本但实际为正样本数量, F N + T P FN+TP FN+TP为样本总数。
  在不同的置信度阈值下,模型对某一类别的预测有多组 P P P R R R平均精度(Average Precison, AP) P − R P-R PR曲线所围面积,均值平均精度(mean Average Precison, mAP)为所有类别 A P AP AP的均值。
  目标检测的任务为对目标进行分类定位,模型的预测结果p ( c l s , c o n f , p o s ) (cls, conf, pos) (cls,conf,pos),其中 c l s cls cls为目标的类别, c o n f conf conf为目标属于该类别的置信度, p o s pos pos为目标的预测边框。在预测结果评价中,使用pgt(真实结果)边框之间的交集和并集面积之比(Intersection over Union, IoU)衡量结果,其 P P P R R R的计算公式如下:
P = T P T P + F P = T P n u m p ( a l l ) P = {{TP} \over {TP + FP}} = {{TP} \over {nump(all)}} P=TP+FPTP=nump(all)TP
R = T P T P + F N = R n u m g t ( a l l ) R = {{TP} \over {TP + FN}} = {{R} \over {numgt(all)}} R=TP+FNTP=numgt(all)R

  • T P TP TPpgt匹配的数量
    • IoU > IoU_thres且类别一致
    • 同一个gt至多匹配一个p(若一个gt匹配到多个p,则选择IoU最高的p作为匹配结果)
    • 同一个gt至多匹配一个p(若一个p匹配到多个gt,则选择IoU最高的gt作为匹配结果)
  • F P FP FPp未能与gt匹配的数量
  • F N FN FNgt未能与p匹配的数量

  假设某目标检测任务中具有两个类别,一共有八张检测图片,其检测结果如图1所示,其中数字表示类别置信度。
【目标检测】评价指标:mAP概念及其代码实现(yolo源码/pycocotools),目标检测,目标检测,YOLO,mAP

图1 模型检测结果

  根据上图结果,设定 I o U _ t h r e s IoU\_thres IoU_thres为0.5,预测结果的 T P TP TP F P FP FP统计结果表1所示。

表1 预测结果TP/FP统计

【目标检测】评价指标:mAP概念及其代码实现(yolo源码/pycocotools),目标检测,目标检测,YOLO,mAP

  根据表1统计结果,计算表中底色为蓝色(class_1)的类别预测 A P AP AP,根据置信度从大到小对其类别预测结果进行排序,并在不同的类别置信度下计算其 P P P R R R,得到的结果如表2所示。

表2 类别1在不同置信度阈值下的P和R

【目标检测】评价指标:mAP概念及其代码实现(yolo源码/pycocotools),目标检测,目标检测,YOLO,mAP
  根据表2统计结果,绘制类别1在不同置信度阈值下的P-R曲线,如图2所示,其中每个点最终P值为该点本身及右边点的最大值,计算P-R曲线面积即可得到最终mAP,关于面积在pycocotoolsyolo源码中的具体求法见下文。
【目标检测】评价指标:mAP概念及其代码实现(yolo源码/pycocotools),目标检测,目标检测,YOLO,mAP

图2 类别1在不同置信度下P-R曲线

2 mAP计算(pycocotools)

2.1 coco评价指标

coco的评价指标如图3所示,各个评价指标的意义如下:

  • Average Precision (AP):即mAP
  • Average Recall (AR):IoU阈值@0.5:0.95下的所有Recall(不常用)
  • IoU (@0.5,@0.75,@0.5:0.95):不同的IoU阈值下的结果
  • area:预测目标的面积大小
  • maxDets:每张图片中的最多预测目标数量

【目标检测】评价指标:mAP概念及其代码实现(yolo源码/pycocotools),目标检测,目标检测,YOLO,mAP

图3 coco评价指标

2.2 coco指标计算

pycocotools函数:

  • pycocotools.coco.COCO:COCO数据形式(gt)
  • pycocotools.coco.COCOeval:指标计算

coco数据形式(json)(cocoGT):

  • image
    • id(图片id)
    • height(图片高度)
    • width(图片宽度)
  • categories
    • id(类别1)
    • id(类别2)
  • annotations:
    • image_index(当前标签属于的图片id)
    • bbox(xmin,ymin,w,h 绝对坐标)
    • categoried_id(当前标签属于的类别id)
    • area(当前预测边框面积)
    • iscrowd(目标检测任务中设为0)

yolo数据数据(txt)(yoloGt):(class, x, y, w, h)

2.2.1 数据形式转换(yolo to coco)

def convert_to_coco_api(ds):
    '''
    实现yolo数据形式(txt)到coco数据形式(json)的转换
    :param ds: 数据类(yolo源码中形式)
    :return: coco数据类
    '''
    coco_ds = COCO()  # pycocotools.coco.COCO
    # labels IDs need to start at 1, not 0
    ann_id = 1
    # images: {'id'(图片id): , 'height':, 'width': }
    # categories: {'id'(类别id): , 'id': , ...}
    # annotations: {'image_id'(属于图片id): , 'bbox': (xmin, ymin, w, h)绝对坐标, 'categoried_id', 'area(面积)', 'iscrowd': , 'id': 标签id}
    dataset = {'images': [], 'categories': [], 'annotations': []}
    categories = set()
    # 遍历dataset中的每张图像
    for img_idx in tqdm(range(len(ds)), desc="loading eval info for coco tools."):
        # targets: [num_obj, 6] , 6 -> (img_index, obj_index, x, y, h, w)
        targets, shapes = ds.coco_index(img_idx)
        # 图像字典添加
        img_dict = {}
        img_dict['id'] = img_idx
        img_dict['height'] = shapes[0]
        img_dict['width'] = shapes[1]
        dataset['images'].append(img_dict)
        # 标签字典添加
        for obj in targets:
            ann = {}
            # 当前标签属于的图片id
            ann["image_id"] = img_idx
            # 将相对坐标转为绝对坐标 (x, y, w, h) -> (xmin, ymin, w, h)
            # 位置信息
            boxes = obj[1:]
            boxes[:2] -= 0.5*boxes[2:]
            boxes[[0, 2]] *= img_dict["width"]
            boxes[[1, 3]] *= img_dict["height"]
            boxes = boxes.tolist()
            ann["bbox"] = boxes  # 当前标签的边框信息(xmin,ymin,w,h)
            ann["category_id"] = int(obj[0])  # 当前标签属于的类别id
            categories.add(int(obj[0]))
            ann["area"] = boxes[2] * boxes[3]  # 当前标签边框面积
            ann["iscrowd"] = 0
            ann["id"] = ann_id  # 当前标签id
            dataset["annotations"].append(ann)
            ann_id += 1

    dataset['categories'] = [{'id': i} for i in sorted(categories)]
    # 构造coco数据形式
    coco_ds.dataset = dataset
    # ds.anns(标签id:标签信息)
    # ds.imgToAnns(图片id:标签信息(属于当前图片))
    # ds.catToImgs(类别id: 标签信息(属于当前类别))
    # ds.imgs(图片id:图片信息)
    # ds.cats(类别id:类别)
    coco_ds.createIndex()
    return coco_ds

2.2.2 coco计算类

调用pycocotools API实现coco指标计算类(CocoEvaluator)

  • 函数
    • update:在模型预测过程中添加模型的预测结果,并将其转换为coco数据形式
    • accumulate: 调用COCOeval.accumulate实现每一类别TP/FP计算
    • summarize: 调用COCOeval.summarize实现评价指标的计算
class CocoEvaluator(object):
    def __init__(self, coco_gt, iou_types):
        assert isinstance(iou_types, (list, tuple))
        coco_gt = copy.deepcopy(coco_gt)  # coco数据(gt)
        self.coco_gt = coco_gt

        self.iou_types = iou_types  # ['bbox']
        self.coco_eval = {}
        for iou_type in iou_types:
            self.coco_eval[iou_type] = COCOeval(coco_gt, iouType=iou_type)

        self.img_ids = []
        self.eval_imgs = {k: [] for k in iou_types}

    def update(self, predictions):
        img_ids = list(np.unique(list(predictions.keys())))
        self.img_ids.extend(img_ids)

        for iou_type in self.iou_types:
            results = self.prepare(predictions, iou_type)
            coco_dt = loadRes(self.coco_gt, results) if results else COCO()
            coco_eval = self.coco_eval[iou_type]

            coco_eval.cocoDt = coco_dt
            coco_eval.params.imgIds = list(img_ids)
            img_ids, eval_imgs = evaluate(coco_eval)

            self.eval_imgs[iou_type].append(eval_imgs)

    def synchronize_between_processes(self):
        for iou_type in self.iou_types:
            self.eval_imgs[iou_type] = np.concatenate(self.eval_imgs[iou_type], 2)
            create_common_coco_eval(self.coco_eval[iou_type], self.img_ids, self.eval_imgs[iou_type])

    def accumulate(self):
        for coco_eval in self.coco_eval.values():
            coco_eval.accumulate()

    def summarize(self):
        for iou_type, coco_eval in self.coco_eval.items():
            print("IoU metric: {}".format(iou_type))
            coco_eval.summarize()

    def prepare(self, predictions, iou_type):
        if iou_type == "bbox":
            return self.prepare_for_coco_detection(predictions)
        elif iou_type == "segm":
            return self.prepare_for_coco_segmentation(predictions)
        elif iou_type == "keypoints":
            return self.prepare_for_coco_keypoint(predictions)
        else:
            raise ValueError("Unknown iou type {}".format(iou_type))

    def prepare_for_coco_detection(self, predictions):
        coco_results = []
        for original_id, prediction in predictions.items():
            if len(prediction) == 0:
                continue

            boxes = prediction["boxes"]
            boxes = convert_to_xywh(boxes).tolist()
            scores = prediction["scores"].tolist()
            labels = prediction["labels"].tolist()

            coco_results.extend(
                [
                    {
                        "image_id": original_id,
                        "category_id": labels[k],
                        "bbox": box,
                        "score": scores[k],
                    }
                    for k, box in enumerate(boxes)
                ]
            )
        return coco_results

    def prepare_for_coco_segmentation(self, predictions):
        coco_results = []
        for original_id, prediction in predictions.items():
            if len(prediction) == 0:
                continue

            scores = prediction["scores"]
            labels = prediction["labels"]
            masks = prediction["masks"]

            masks = masks > 0.5

            scores = prediction["scores"].tolist()
            labels = prediction["labels"].tolist()

            rles = [
                mask_util.encode(np.array(mask[0, :, :, np.newaxis], dtype=np.uint8, order="F"))[0]
                for mask in masks
            ]
            for rle in rles:
                rle["counts"] = rle["counts"].decode("utf-8")

            coco_results.extend(
                [
                    {
                        "image_id": original_id,
                        "category_id": labels[k],
                        "segmentation": rle,
                        "score": scores[k],
                    }
                    for k, rle in enumerate(rles)
                ]
            )
        return coco_results

    def prepare_for_coco_keypoint(self, predictions):
        coco_results = []
        for original_id, prediction in predictions.items():
            if len(prediction) == 0:
                continue

            boxes = prediction["boxes"]
            boxes = convert_to_xywh(boxes).tolist()
            scores = prediction["scores"].tolist()
            labels = prediction["labels"].tolist()
            keypoints = prediction["keypoints"]
            keypoints = keypoints.flatten(start_dim=1).tolist()

            coco_results.extend(
                [
                    {
                        "image_id": original_id,
                        "category_id": labels[k],
                        'keypoints': keypoint,
                        "score": scores[k],
                    }
                    for k, keypoint in enumerate(keypoints)
                ]
            )
        return coco_results

3 mAP计算(yolo源码)

基于YOLO源码实现mAP @0.5:0.95计算(MeanAveragePrecsion)

  • 数据形式:
    • 预测结果:xmin,ymin,xmax,ymax,conf,class(绝对坐标)
    • 真实结果:class,xmin,ymin,xmax,ymax(绝对坐标)
  • 函数:
    • process_batch:实现预测结果和真实结果的匹配
    • calculate_ap_per_class: 计算每一类别的AP值
    • compute_pr_area:计算PR曲线的面积
class MeanAveragePrecison:
    def __init__(self, device="cpu"):
        '''
        计算mAP: mAP@0.5; mAP @0.5:0.95; mAP @0.75
        '''
        self.iouv = torch.linspace(0.5, 0.95, 10, device=device)  # 不同的IoU置信度 @0.5:0.95
        self.niou = self.iouv.numel()  # IoU置信度数量
        self.stats = []  # 存储预测结果
        self.device = device
    def process_batch(self, detections, labels):
        '''
        预测结果匹配(TP/FP统计)
        :param detections:(array[N,6]) x1,y1,x1,y1,conf,class (原图绝对坐标)
        :param labels:(array[M,5]) class,x1,y1,x2,y2 (原图绝对坐标)
        '''
        # 每一个预测结果在不同IoU下的预测结果匹配
        correct = np.zeros((detections.shape[0], self.niou)).astype(bool)
        if detections is None:
            self.stats.append((correct, *torch.zeros((2, 0), device=self.device), labels[:, 0]))
        else:
        # 计算标签与所有预测结果之间的IoU
            iou = box_iou(labels[:, 1:], detections[:, :4])
            # 计算每一个预测结果可能对应的实际标签
            correct_class = labels[:, 0:1] == detections[:, 5]
            for i in range(self.niou):  # 在不同IoU置信度下的预测结果匹配结果
                # 根据IoU置信度和类别对应得到预测结果与实际标签的对应关系
                x = torch.where((iou >= self.iouv[i]) & correct_class)
                # 若存在和实际标签相匹配的预测结果
                if x[0].shape[0]:  # x[0]:存在为True的索引(实际结果索引), x[1]当前所有True的索引(预测结果索引)
                    # [label, detect, iou]
                    matches = torch.cat((torch.stack(x, 1), iou[x[0], x[1]][:, None]), 1).cpu().numpy()
                    if x[0].shape[0] > 1:  # 存在多个与目标对应的预测结果
                        matches = matches[matches[:, 2].argsort()[::-1]]  # 根据IoU从高到低排序 [实际结果索引,预测结果索引,结果IoU]
                        matches = matches[np.unique(matches[:, 1], return_index=True)[1]]  # 每一个预测结果保留一个和实际结果的对应
                        matches = matches[np.unique(matches[:, 0], return_index=True)[1]]  # 每一个实际结果和一个预测结果对应
                    correct[matches[:, 1].astype(int), i] = True  # 表面当前预测结果在当前IoU下实现了目标的预测
            # 预测结果在不同IoU是否预测正确, 预测置信度, 预测类别, 实际类别
            self.stats.append((correct, detections[:, 4], detections[:, 5], labels[:, 0]))

    def calculate_ap_per_class(self, save_dir='.', names=(), eps=1e-16):
        stats = [torch.cat(x, 0).cpu().numpy() for x in zip(*self.stats)]  # to numpy
        # tp:所有预测结果在不同IoU下的预测结果 [n, 10]
        # conf: 所有预测结果的置信度
        # pred_cls: 所有预测结果得到的类别
        # target_cls: 所有图片上的实际类别
        tp, conf, pred_cls, target_cls = stats[0], stats[1], stats[2], stats[3]
        # 根据类别置信度从大到小排序
        i = np.argsort(-conf)  # 根据置信度从大到小排序
        tp, conf, pred_cls = tp[i], conf[i], pred_cls[i]

        # 得到所有类别及其对应数量(目标类别数)
        unique_classes, nt = np.unique(target_cls, return_counts=True)
        nc = unique_classes.shape[0]  # number of classes
 
        # ap: 每一个类别在不同IoU置信度下的AP, p:每一个类别的P曲线(不同类别置信度), r:每一个类别的R(不同类别置信度)
        ap, p, r = np.zeros((nc, tp.shape[1])), np.zeros((nc, 1000)), np.zeros((nc, 1000))
        for ci, c in enumerate(unique_classes):  # 对每一个类别进行P,R计算
            i = pred_cls == c
            n_l = nt[ci]  # number of labels 该类别的实际数量(正样本数量)
            n_p = i.sum()  # number of predictions 预测结果数量
            if n_p == 0 or n_l == 0:
                continue

            # cumsum:轴向的累加和, 计算当前类别在不同的类别置信度下的P,R
            fpc = (1 - tp[i]).cumsum(0)  # FP累加和(预测为负样本且实际为负样本)
            tpc = tp[i].cumsum(0)  # TP累加和(预测为正样本且实际为正样本)
            # 召回率计算(不同的类别置信度下)
            recall = tpc / (n_l + eps)
            # 精确率计算(不同的类别置信度下)
            precision = tpc / (tpc + fpc)


            # 计算不同类别置信度下的AP(根据P-R曲线计算)
            for j in range(tp.shape[1]):
                ap[ci, j], mpre, mrec = self.compute_ap(recall[:, j], precision[:, j])
        # 所有类别的ap值 @0.5:0.95
       	return ap


    def compute_ap(self, recall, precision):
        # 增加初始值(P=1.0 R=0.0) 和 末尾值(P=0.0, R=1.0)
        mrec = np.concatenate(([0.0], recall, [1.0]))
        mpre = np.concatenate(([1.0], precision, [0.0]))

        # Compute the precision envelope np.maximun.accumulate
        # (返回一个数组,该数组中每个元素都是该位置及之前的元素的最大值)
        mpre = np.flip(np.maximum.accumulate(np.flip(mpre)))

        # 计算P-R曲线面积
        method = 'interp'  # methods: 'continuous', 'interp'
        if method == 'interp':  # 插值积分求面积
            x = np.linspace(0, 1, 101)  # 101-point interp (COCO))
            # 积分(求曲线面积)
            ap = np.trapz(np.interp(x, mrec, mpre), x)
        elif method == 'continuous':  # 不插值直接求矩阵面积
            i = np.where(mrec[1:] != mrec[:-1])[0]  # points where x axis (recall) changes
            ap = np.sum((mrec[i + 1] - mrec[i]) * mpre[i + 1])  # area under curve

        return ap, mpre, mrec

4 计算方法对比(pycocotools和yolo源码)

  yolo源码计算得到的mAP会高于pycocotools计算得到的mAP,其主要表现在得到P-R曲线后的处理过程,如图4所示。
【目标检测】评价指标:mAP概念及其代码实现(yolo源码/pycocotools),目标检测,目标检测,YOLO,mAP

图4 coco和yolo中P-R曲线面积计算方法对比

4.1 插值方法

  在最终计算得到的mpre(P),mrec(R)中,通过插值的方法得到101个点,在两种计算方法中,所用的插值函数存在不同。

  • pycocotools:np.searchsorted
'''
np.searchsorted(a, v, side='left', sorter=None)-> inds
a:一维数组,当sorter为None时,其必须为升序数组
v:插值数组
side: 'left':a[i-1] < v <= a[i],第一个满足条件的; 'right':a[i-1] <= v < a[i],最后一个满足条件的
inds: 列表,对应v中元素插入a的位置
'''
recThrs = np.linspace(.0, 1.00, 101, endpoint=True)
inds = np.searchsorted(mrec, recThrs, side='left')   # 在横坐标(R)上插值得到新的横坐标
for ri, pi in enumerate(inds):
	q[ri] = mpre[pi]  # 新的纵坐标
mpre = np.array(q[ri])
  • yolo源码:np.interp
'''
numpy.interp(x, xp, fp, left=None, right=None, period=None)->p
x:计算插值的x坐标
xp:原数据的纵坐标
fp:原数据的横坐标
p:通过估计xp和fp的线性关系,得到插值
'''
recThrs = np.linspace(.0, 1.00, 101)
mpre = np.interp(recThrs, mrec, mpre)

4.2 面积计算方法(mAP)

  • pycocotools:np.mean(mpre)计算插值点的均值得到结果

  • yolo源码:np.tapz(mpre,recThrs)计算插值后P-R曲线积分(面积)得到结果文章来源地址https://www.toymoban.com/news/detail-808164.html

到了这里,关于【目标检测】评价指标:mAP概念及其代码实现(yolo源码/pycocotools)的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包赞助服务器费用

相关文章

  • 【计算机视觉 | 目标检测】目标检测中的评价指标 mAP 理解及计算(含示例)

    【计算机视觉 | 目标检测】目标检测中的评价指标 mAP 理解及计算(含示例)

    在目标检测中,有几个常用的评价指标用于衡量算法的性能。以下是其中几个重要的评价指标: Precision(精确率):Precision 衡量了在所有被检测为正样本的样本中,有多少是真正的正样本。 Precision 的计算公式为:Precision = TP / (TP + FP),其中 TP 是真正的正样本数量,FP 是将负

    2024年01月19日
    浏览(9)
  • 【深度学习】目标检测的性能评价指标,mAP_0.5,mAP_0.5,0.95,0.05

    【深度学习】目标检测的性能评价指标,mAP_0.5,mAP_0.5,0.95,0.05

    指标有检测精度和检测速度之分: mAP是一个容易混淆的概念。计算mAP之前先考虑我们有的数值:图片原label的bbox、模型预测的bbox、模型预测的bbox的置信度、模型预测的bbox中目标类别的分类置信度。在YOLO中,最后两个数值会乘起来表示一个置信度数值。 此外,我们还需要确

    2023年04月21日
    浏览(10)
  • MS COCO数据集的评价标准以及不同指标的选择推荐(AP、mAP、MS COCO、AR、@、0.5、0.75、1、目标检测、评价指标)

    MS COCO数据集的评价标准以及不同指标的选择推荐(AP、mAP、MS COCO、AR、@、0.5、0.75、1、目标检测、评价指标)

    目标检测模型性能衡量指标、MS COCO 数据集的评价标准以及不同指标的选择推荐 目标检测模型通过 pycocotools 在验证集上会得到 COCO 的评价列表,具体参数的含义是什么呢? PASCAL VOC Microsoft COCO(MS COCO) 在 MS COCO 数据集出来之前,目标检测基本上用的是 PASCAL VOC 数据集,现在

    2024年02月08日
    浏览(16)
  • YOLO等目标检测模型的非极大值抑制NMS和评价指标(Acc, Precision, Recall, AP, mAP, RoI)、YOLOv5中mAP@0.5与mAP@0.5:0.95的含义

    YOLO等目标检测模型的非极大值抑制NMS和评价指标(Acc, Precision, Recall, AP, mAP, RoI)、YOLOv5中mAP@0.5与mAP@0.5:0.95的含义

    YOLOv5正负样本定义 yolov5输出有3个预测分支,每个分支的每个网格有3个anchor与之对应。 没有采用IOU最大的匹配方法,而是通过计算该bounding-box和当前层的anchor的宽高比,如果最大比例大于4(设定阈值),则比例过大,则说明匹配度不高,将该bbox过滤,在当前层认为是背景

    2024年02月03日
    浏览(10)
  • 【目标检测】目标检测的评价指标(七个)

    【目标检测】目标检测的评价指标(七个)

    样本在计算机视觉的评价中是非常重要的概念,正样本比较好理解,是要检测的物体,负样本是不要检测的目标。这里负样本会有一些问题,首先负样本定义比较主观,其次负样本和正样本的量纲不在一个级别,那么实际算法中会把检测出的待选区域中的一部分作为正样本,

    2024年02月04日
    浏览(8)
  • 目标检测评价指标

    目标检测评价指标

    IoU(交并比) 1、IOU的全称为交并比(Intersection over Union), 是目标检测中使用的一个概念,IoU计算的是“预测的边框”和“真实的边框”的交叠率,即它们的交集和并集的比值 。 2、IoU等于“预测的边框”和“真实的边框”之间交集和并集的比值。 IoU计算如下图,B1为真实

    2024年02月05日
    浏览(10)
  • 目标检测网络的常见评价指标

    目标检测网络的常见评价指标

    声明:原视频链接https://www.bilibili.com/video/BV13k4y1m7DY?spm_id_from=333.880.my_history.page.click 下面是我的笔记,截图均来自原视频。 举例说明:单类物体检测时,以人脸检测为例。如图 绿色 实线和虚线框:人脸的真实标注 红色 的实线框和虚线框:算法的检测结果 框左上角的 红色数

    2024年02月06日
    浏览(14)
  • 目标检测中常见指标 - mAP

    目标检测中常见指标 - mAP

    在目标检测领域,比较常用的两个公开数据集: pascal voc 和 coco 。 目标检测与图像分类明显差距是很大的,在图像分类中,我们通常是统计在验证集当中,分类正确的个数除以验证集的总样本数就能得到准确率。 那么对于目标检测,怎么样才能算检测正确呢? TP(True Posit

    2024年02月06日
    浏览(10)
  • 目标检测-计算IOU,mAP指标

    IoU,全称Intersection over Union,可翻译为交并比,是两个框交集与并集的比值。计算IoU的公式如下图,可以看到IoU是一个比值,即交并比。 在分子中,我们计算预测框和ground-truth之间的重叠区域;分母是并集区域,是预测框和ground-truth所包含的总区域。重叠区域和并集区域的比

    2024年02月12日
    浏览(5)
  • 目标检测评估指标 mAP, FPS

    目标检测评估指标 mAP, FPS

    参考1 mAP (mean Average Precision) might confuse you! 参考2 Breaking Down Mean Average Precision (mAP) 根据 IoU 的取值,可以将预测得到 bbox 判断为 TP, FP 或者 FN。 TN 不考虑。 考虑下面这幅图,只查看 person 的预测 bbox。 TP 为 IoU 0.5 的bbox. FP : 有两种情况会被考虑为 FP IoU 0.5 其他大于0.5 但是小于

    2024年02月07日
    浏览(10)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包