YOLO 系列 object detection 算法

2019-10-01  本文已影响0人  OurNote

R-CNN 以及后续改进的 Fast R-CNN, Faster R-CNN 都是 region-based,也就是说在进行物体检测时,对某个局部区域的检测完全取决于该区域的图像特征,而不会受到整幅图片其他区域的影响。这种 Region-based 物体检测可以直观理解成先把图片分割成若干小区域,然后对每个孤立的区域分别进行 classification。

YOLO ( You Only Look Once ) 则是基于整幅图片的信息同时检测若干小区域。YOLO 也是一个持续改进的算法,以 v1, v2, v3 标记。

基于 COCO 数据集的测试效果看,YOLO v3 是目前 real-time object detection ( >=30 frames per second )算法中检测准确度最高的。

本文将尝试总结 YOLO 三个版本的基本思想。

参考文献:
YOLO v1 原文:https://arxiv.org/pdf/1506.02640.pdf
YOLO v2 原文:https://arxiv.org/pdf/1612.08242.pdf
YOLO v3 原文:https://pjreddie.com/media/files/papers/YOLOv3.pdf

在下边每个小节中,如果没有特殊说明,“YOLO” 指代本小节的 YOLO 版本。

YOLO v1

基本检测流程
From the original paper
  1. 首先将整幅图片划分成 S\times S 个小格子

  2. 每个小格子对应 B 个带有自信度 (confidence scores) 的 bounding box。自信度取决于两方面:一是这个 bounding box 包含物体的概率,用 Pr(object) 表示;二是这个 bounding box 是否准确的包含了该物体,用预测 bounding box 与实际 bounding box 的 intersection over union (IoU) 来表示。因此,自信度计算公式为
    Pr(object)×IoU^{truth}_{pred}

    最理想的情况是,每个 bbox 的自信度就等于它所包含物体的 IoU^{truth}_{pred}.

  3. 每个 bbox 对应 5 个预测值:

    • x, y : bbox 相对于小格子的偏移,取值在 [0,1] 内。
    • w, h : bbox 相对于整张图的宽和高,取值在 [0,1] 内。
    • 自信度 confidence score
  4. 每个小格子还要预测一组条件概率 Pr(Class_i|Object):如果这个小格子中包含了某个物体,则这个物体属于某个类别的概率是多少。不论小格子对应的 bbox 数目有多少,每个小格子只负责预测一组条件概率。
    结合前述自信度公式,我们用如下公式表示每个 bbox 包含某类物体的自信度:
    Pr(Class_i|Object) \times Pr(object) \times IoU^{truth}_{pred} = Pr(Class_i) \times IoU^{truth}_{pred}

网络结构

在基于 PASCAL VOC 数据集的测试中选择 S=7, B=2,C=20.
网络包括 24 个卷积层 + 2 个全连通层,具体结构如下:

From the original paper

其中最后一个维度为 (7, 7, 1024) 的 feature map 被重新排列成一维向量送入后边的全连通层,最后一个全连通层的输出被重新排列成 (7, 7, 30) ,对应了 7×7 个 cell,每个 cell 对应长为(B×5+C=30)的向量。得到所有的 bbox 和对应的 score 之后,通过 non-maximal suppression (NMS) 消除重复的检测,对于同一个物体只保留 score 最大的 bbox。

另外为了提高检测速度,还有一个 Fast YOLO 版本,只有 9 个卷积层。除了网络结构精简以外,Fast YOLO 与 YOLO 在训练、测试参数方面完全相同。

在 PASCAL VOC 数据集上测试时,每个格子只有 2 个 bbox,一幅图总共有 7×7×2=98 个 bbox。由于 bbox 数量较少,YOLO 在 localization 方面不如 Region based 算法,但是由于有整幅图的信息,在预测时将背景识别为物体的错误较低 (less false positives)。YOLO 还具有很强的泛化能力,基于实际场景训练的 YOLO 在艺术作品场景中也具有较好的检测效果,这一点比 R-CNN 系列算法好很多。

From the original paper

YOLO 能够以 45 frames per second (FPS) 的速度处理图片,而基于更小网络的 Fast YOLO 达到了 155 FPS。如果输入的是画面连贯的视频 (> 30 FPS),YOLO 也有足够的时间处理其中的每一个 FPS,也就是具有了实时 object detection 的能力,这对于实时性要求比较高的应用场景(例如自动驾驶)是非常重要的。

YOLO v2

相比于 Region-based 物体检测算法,YOLO v1 的主要问题是 localization 误差比较大,而且 recall 相对较低。这里 recall 反映了能否找到图片中尽量多的物体。这两个问题似乎都是由于 YOLO v1 划分格子太粗糙造成的。

YOLO v2 改善了这两个方面的问题,同时依然具有较高的检测速度和准确度。改进方式主要是广泛借鉴了当时已有的深度学习网络构建和训练技巧。概括如下:

From the original paper

每一点改进都在检测精度 (precision)、recall 或者检测速度方面改善一些。

Detection 和 classification 是计算机视觉的两个主要任务。目前来看,用来训练 classification 任务的数据集(例如 ImageNet)规模远远超过训练 detection 任务的数据集 (例如 COCO)。

为了在 detection 的训练过程中充分利用 classification 数据集,YOLO v2 的作者采用新的训练方式,将 ImageNet 和 COCO 数据集合并在一起,大大扩展了 训练数据集。对于不同的数据集,训练的时候也是有区别的:对于 COCO 数据集,训练的时候要同时学习 bbox 位置预测和目标的分类,而对于 ImageNet 数据集,训练的时候只学习目标的分类。

通过这种训练方式得到的 YOLO v2 可以对超过 9000 种物体进行 detection,因此被称为 YOLO9000。

YOLO v3

YOLO v3 的文章写的比较随意,是以类似技术报告的形式记录了一些改进工作。文章开头就很清奇:

Sometimes you just kinda phone it in for a year, you know? I didn’t do a whole lot of research this year. Spent a lot of time on Twitter. Played around with GANs a little. I had a little momentum left over from last year; I managed to make some improvements to YOLO. But, honestly, nothing like super interesting, just a bunch of small changes that make it better. I also helped out with other people’s research a little.

结尾部分也挺有意思,很讽刺,似乎也很深刻:

But maybe a better question is: “What are we going to do with these detectors now that we have them?” A lot of the people doing this research are at Google and Facebook. I guess at least we know the technology is in good hands and definitely won’t be used to harvest your personal information and sell it to.... wait, you’re saying that’s exactly what it will be used for?? Oh.
...
Well the other people heavily funding vision research are the military and they’ve never done anything horrible like killing lots of people with new technology oh wait.....
...
I have a lot of hope that most of the people using computer vision are just doing happy, good stuff with it, like counting the number of zebras in a national park, or tracking their cat as it wanders around their house. But computer vision is already being put to questionable use and as researchers we have a responsibility to at least consider the harm our work might be doing and think of ways to mitigate it. We owe the world that much.
...
In closing, do not @ me. (Because I finally quit Twitter).

除了训练细节方面比较琐碎的改进,YOLO v3 最主要的改进是采用了新的基础网络作特征提取,将 ResNet 的思想引入了原本的 Darknet-19 中,得到 53 层卷积层的网络。

It has 53 convolutional layers so we call it ... wait for it ... Darknet-53.

作者似乎没少看 《How I Met Your Mother》,连写文章也要模仿一下。。。

最后 YOLO v3 在检测速度和准确度方面都比较出色。尽管 RetinaNet 在准确度方面比 YOLO v3 好,但是检测速度方面,YOLO v3 碾压所有对手。所以在之后的自动驾驶环境中,我们会优先考虑用 YOLO v3 做目标检测工作。

yolo3.PNG yolo3-2.PNG
上一篇 下一篇

猜你喜欢

热点阅读