Taught you do object detection (five) with a deep learning: YOLOv1 Introduction

"之前写物体检测系列文章的时候说过,关于YOLO算法,会在后续的文章中介绍,然而,由于YOLO历经3个版本,其论文也有3篇,想全面的讲述清楚还是太难了,本周终于能够抽出时间写一些YOLO算法相关的东西。本篇文章,我会先带大家完整的过一遍YOLOv1的论文,理解了YOLOv1才能更好的理解它的后续版本,YOLOv2和v3会在下一篇文章中介绍。"

yolov1

论文:《 You Only Look Once: Unified, Real-Time Object Detection 》
Address: https://arxiv.org/pdf/1506.02640.pdf

Summary:

我们提出YOLO,一种新的目标检测方法。以前的目标检测是用分类的方式来检测,而我们将目标检测定义成回归问题,从空间上分隔出边界框和相关的类别概率。这是一个简洁的神经网络,看一次全图后,就能直接从全图预测目标的边界框和类别概率。因为整个检测线是一个单一的网络,在检测效果上,可以直接做端到端的优化。我们的统一架构非常快。我们的基础YOLO模型每秒可以处理45帧图片。该网络的一个更小的版本——Fast YOLO,每秒可以处理155帧图片,其mAP依然能达到其他实时检测模型的2倍。对比最先进的检测系统,YOLO有更多的定位误差,和更少的背景误检情况(把背景预测成目标)。最终,YOLO学到检测目标的非常通用的表示。在从自然图片到其他领域,比如艺术画方面,YOLO的泛化能力胜过其他检测方法,包括DPM和R-CNN。

1 Introduction

人类看一眼图片就能立即知道,图片里有哪些目标,目标的位置,以及目标之间的交互关系。人类视觉系统快且精确,这让我们不用做过多显性意识层面的思考,就能执行类似驾驶这样的复杂任务。快速、精确的目标检测算法,将让计算机无需特定的传感器就能驾驶汽车;将使辅助设备能实时传递场景信息给人类,将解锁通用目的的响应式机器人系统的潜力。当前的检测系统,使用分类器来执行检测。为了检测一个目标,这些系统利用这个目标的分类器在一个测试图片上的不同位置使用不同的尺度来评估是否是该目标。比如DPM(deformable parts models)系统,就是使用滑动窗口的方式以均匀的步长跑完整个图片上的位置。更近期一些的方法,比如R-CNN使用候选区域的方式,首先生成候选边界框,然后运行分类器,根据结果删除一批边界框,对剩余的边界框进行排重处理,并根据图片场景中的其他目标来重新对剩余的边界框进行打分。这些复杂的过程又慢又难以优化,因为每个独立的组件都必须分开来训练。我们重新把目标检测问题框定成一个回归问题,直接从图片像素到边界框和类别概率。使用我们的系统,你只需看一次(you only look once ,YOLO)图片,就可以预测有什么目标以及目标的位置。YOLO很简洁:看图1:

 

  
一个卷积网络同时预测多个边界框和类别概率。YOLO在完整的图片上训练,并直接优化检测效果。与传统的检测方法相比,这个统一模型有许多优点:
  • First, YOLO very fast. Because we frame the detection process is a regression problem, so we do not need complicated. When we test image detection, simply run at our neural network, do the forecast. Our basic network on TitanXGPU, without batch, you can reach the speed of 45 per second, FastYOLO faster, up to 150 frames / sec. This means we can use less than 25 milliseconds of latency, real-time processing of video streams. The average accuracy is twice YOLO other real-time systems. In our example network system operates in real time on the camera, please see our project page: http://pjreddie.com/yolo/.
  • Second, YOLO when the forecast is reasoning on the full range of the image. Sliding window and do not want regional technical candidate, YOLO in training and testing, see the complete picture, so YOLO implicitly encoded contextual information about the category and category appearance. Fast R-CNN, a top-level detection method, the error detection target as part of the background, because the algorithm can not see the bigger context information. Compared with Fast R-CNN, YOLO background error generated in less than half.
  • Third, YOLO general characterization of learning objectives. When the model is trained on the natural picture, tests on the art picture, YOLO performance far exceeds the DPM and R-CNN. Due to the high generalization of YOLO, applied to enter new areas or seen, compared with less may be faulty. YOLO accuracy in detection, still lags behind most advanced detection systems. Although the recognition target speed, it is difficult accurately locating certain goal, particularly small targets. We'll take a trade-off in the experiment. All our training and test code are open source. Pre-training of various models can also be downloaded to.

2. uniform testing

我们统一了独立的目标检测组件到一个单一的神经网络中。我们的网络使用完整的图片特征来预测每个边界框。 它还可以同时预测一个图像在所有类中的所有边界框。这意味着我们的网络推理的时候会考虑整个图片,包括图片中的所有对象。YOLO的设计,使其能做端到端的训练,并在保持一个高平均精度的同时实时的做预测。我们的系统将输入图片分成S\*S的网格。如果一个目标的中心落在一个格子里,这个格子就负责这个目标的检测。每个格子预测B各边界框以及每个边界框的置信度分数。这个置信度分数反应了模型有多确定该边界框里包含目标,以及该边界框就是最合适框住目标的边界框。我们正式定义置信度的公式:

 

  
第一项是格子包含目标的概率,第二项是预测的边界框和真实边界框的交并比(IOU)。如果格子里没有目标,那么置信度应该是0。每个边界框有5个预测:x,y,w,h,confidence。(x,y)坐标是边界框中心点相对于格子边界的表示。w和h是相对整个图像预测的。置信度是预测框和真实框IOU的表示。每个格子也预测了C 个条件类别概率:

 

  
这些概率的条件是格子中包含目标。我们每个格子只预测一组类别概率,不管边界框数量B是多少。在测试时,我们将条件类别概率乘以单个边界框的置信度:

 

  
这样就得到了能反映每个边界框中的类别概率的置信度分数。也就是说,这个置信度分数中既包含了边界框里是某个类别的概率,又包含了边界框本身对目标的适合程度。Figure2:

 

  
图2:我们的系统模型将检测作为回归问题。它将图片分割成S\*S的网格,每个格子预测B个边界框、这些边界框各自的置信度、C个类别概率,这个预测结果编码成一个S\*S\*(B\*5+C)的张量。(其中的5表示边界框的x,y,with,heigh,confidence这个5个参数,具体含义上面的段落已经解释过了。)
2.1 Network Design
我们以卷积神经网络的方式实现这个模型,并在PASCAL VOC检测数据集上进行评估。网络初始的卷积层从图片提取特征,全连接层输出概率和坐标。我们的网络架构受 GoogLeNet图片分类模型的影响。我们的网络有24个卷积层跟着2个全连接层。相比GoogleNet的inception模型,我们简单使用1\*1的reduction层,后面跟上3\*3的卷积层,类似Lin et al\[22\]。完整的网络可以看图3:

 

  
图中最终的输出结果是一个 7 × 7 × 30 的张量。
我们也训练了一个快速版本的YOLO,以推动快速目标检测领域的边界。Fast YOLO使用一个更少卷积层的神经网络(用9代替24),并且卷积层用了更少的filters。除了网络的大小,所有的训练和测试参数,YOLO和Fast YOLO是一样的。
2.2 Training
我们在ImageNet的1000分类竞赛的数据集上,预先训练了我们的卷积层。我们使用前面的20个卷积层,后面跟上一个average-pooling 层和一个全连接层。 我们对这个网络进行了大约一周的训练,并在ImageNet 2012验证集上获得了88%的top5准确率,与 Caffe’s Model Zoo 里的GoogLeNet模型相当。我们使用Darknet框架进行所有的训练和推理。然后我们改变模型来执行检测。Ren 等人提出同时添加卷积和连接层可以改善网络的预测效果。按照他们的例子,我们添加了四个卷积层和2个全连接层,用随机的方式初始化权重。检测经常需要细粒度的视觉信息,所以我们增加了输入图片的分辨率,将224\*224增加到了448\*448。我们的最后一层预测类别概率和边界框坐标。我们根据图片的高宽来归一化边界框宽度和高度,以便让边界框的高宽在0~1之间。我们参数化边界框的x和y坐标为特定格子位置的偏移,所以该坐标也落在0-1之间。我们在最后一层使用一个线性激活函数,其他层使用下面的带泄露的修正线性激活函数:

 

  
我们对模型输出的平方和误差做了优化。使用 sum-squared error是因为它易于优化,但是它不能完全实现我们最大化平均精度的目标。它将位置误差和分类误差同等权重看待,这可能不明智。并且,图片中大部分格子都是不包含任何目标的。这使得这些格子的置信度分数趋于0,经常会压倒( overpowering )包含目标的格子的梯度。这会导致模型的不稳定,在训练早期出现发散。
为了补救,我们增加来自边界框坐标预测的损失值,然后降低来自不包含目标的边界框的置信度预测的损失值。我们使用2个参数:

 

  
来实现这个目的。我们设置:

 

  
大边界框和小边界框中,平方和误差目前也是具有相同的权重。但是我们的误差度量应该能反映出小的偏离在大边界框中的影响没有在小边界框的影响大(比如100高宽的大框偏移5没什么,但是10高宽的小框偏移5就影响较大了)。我们采用预测边界框的宽和高的平方根代替直接将预测宽和高的方法,来部分解决这个问题。(平方根可以降低大框和小框的差距,但是差距仍然存在,所以是部分解决。)
YOLO的每个格子会预测多个边界框。在训练时我们只需要一个边界框预测器来负责每个目标。如果某个预测器在某个对象上预测的IOU最高,我们就分配该预测器负责预测这个目标的边界框。该方法使每个预测器在预测特定大小,纵横比,或目标类别上表现的更好,改善了整体的召回率。(这段中的边界框预测器貌似没有具体的介绍,所以没太弄的明白,但是好在yolo2开始引入了anchor box,并且说明了是通过kmeans的方式来的到,所以这里不深究了。)附上原文如下:
YOLO predicts multiple bounding boxes per grid cell. At training time we only want one bounding box predictor to be responsible for each object. We assign one predictor to be “responsible” for predicting an object based on which prediction has the highest current IOU with the ground truth. This leads to specialization between the bounding box predictors. Each predictor gets better at predicting certain sizes, aspect ratios, or classes of object, improving overall recall.
在训练期间,我们优化下面的损失函数:

 

  
  I represents the object appears in the grid;
  I represents the lattice in the j-th predictor bounding box "responsible" predict the bounding box of the grid.

 

注意损失函数只在格子里有目标的时候才会惩罚分类误差(因此之前先讨论了条件类别概率)。同样只有在第j个预测器是负责预测格子边界框的预测器的时候(也就是格子i里有最高的IOU的那个预测器),才会惩罚边界框坐标误差。我们在PASCAL VOC2007和2012的训练集和验证集上训练网络用了135个epochs。当测试2012的数据时,我们也包含了2007的测试集进行训练。训练过程中我们始终使用64batch size , a momentum of 0.9,和0.0005的衰减。我们的学习率调整计划如下:第一个epochs我们缓慢上升学习率,从0.01到0.1。如果我们以一个高的学习率开始,我们的模型经常会因为不稳定的梯度而发散。我们继续在0.1的学习率下训练75个epochs,然后0.01下训练30个epochs,最后0.001下训练30个epochs。为了避免过拟合,我们使用dropout(失活层)和大量的数据增强。在第一个连接层之后,一个rate=0.5的dropout层,阻止了层之间的co-adaptation(互相适应)。数据增强方面,我们引入随机缩放和高达原始图像20%的平移。我们也以高达HSV颜色空间1.5倍的因子来随机调整图片的曝光度和饱和度。
2.3 Reasoning (Inference)
就像训练那样,检测一张图片,也只需要一个网络。在PASCAL VOC 数据集上,网络每张图片预测98个边界框以及框里目标的类别。不像基于分类的方法,YOLO在预测的时候非常快,因为其只有一个单一的网络。网格设计在边界框的预测上强制使用了空间多样性。目标落在那个格子里经常是清晰的,网络为每个目标之预测一个边界框。然而,有一些大的目标,或者跨越了格子边界的目标,会被多个格子都定位到,这样就会出现重复的边界框。Non-maximal suppression (非极大值抑制)可以修复这些多重检测的问题。虽然非极大值抑制对于YOLO,不像对R-CNN或DPM那样关键,但是也增加了2-3%的mAP。
Limitations of 2.4 YOLO
YOLO施加了很强的空间约束,使得每个格子只能预测2个边界框,只能有一个类别。这个约束限制了同一个格子中邻近对象的检测。所以我们的模型很难预测像鸟群这样的邻近小目标。因为模型从数据中预测边界框,所以很难泛化到新的或不常见的纵横比或配置上。我们的模型架构对输入图像用了多个下采样层,所以模型使用了相对粗糙的特征来预测边界框。最后,当我们在一个趋近检测效果的损失函数上训练时,我们的损失函数对待小边界框和大边界框的误差是一样的。一个小误差在大边界框下通常不那么有影响,但是对小边界框来说,在IOU上的影响将更大。我们的误差主要来自定位错误。

3. Compared to other detection systems

目标检测是计算机视觉领域的核心问题。检测过程通常从提取输入图片的一组鲁棒性特征开始。然后,分类器或定位器被用来在特征空间中识别目标。这些分类器或定位器要么是基于滑动窗口的样式贯穿整个图片,要么基于图片区域的子集。我们将YOLO和几个顶级的检测系统对比,突出显示了关键的相似处和不同点。
  • Deformable parts models. DPM uses a sliding window to achieve target detection. DPM extracting static feature, area classification, as predicted on the area of ​​the bounding box score functions used are different pipeline (pipeline). Our system will replace the network with a convolution these different lines. The network while performing feature extraction, the boundary detection block, a non-maxima suppression, context reasoning. The network optimization feature extraction training rather than static characteristics. Our unified architecture, which makes YOLO become faster and more accurate than the DPM model.
  • R-CNN. R-CNN candidate regions and variants thereof used instead of a sliding window to find the target image. Based Selective Search [14] [28] bounding box generating potential, a convolutional network extracts a feature, a bounding box score to SVM, a linear model bounding box adjustment, a non-maxima suppression eliminate duplicate detection. Each of this complex stage of the pipeline must be precisely adjusted independently, which makes the system very slowly, to more than 40 seconds to detect a picture.
    YOLO R-CNN and has some similarities. Each grid bounding box may be made, such as scores convolution wherein a bounding box. However, the ability of our system to the proposed use of the space constraints of the grid to ease the multiple detection of the same target. Our system will give much less the bounding box, compared Selective Search of the bounding box of each picture 2000, our systems as long as 98. Finally, our system allows these separate components into a single joint, can work together to optimize the model.
  • Other fast detector. Fast and Faster R-CNN focused in lieu Selective Search by sharing and using a neural network calculation on the lifting speed candidate area. While this improves the R-CNN speed and accuracy, but has not yet reached the real-time performance. Many studies have committed to enhancing the DPM pipeline [31] speed [38] [5]. They accelerated the HOG calculated using cascading, calculated to push GPUs. But in fact only 30Hz of DPM [31] can run in real time. YOLO completely abandoned those large-scale testing of individual components in the pipeline, to accelerate the whole process from the design, rather than trying to optimize them. Such as a face or a person of a single class detector, it can be highly optimized, because they have to deal with fewer changes. YOLO is a general-purpose detector, simultaneous detection of a wide variety of learning goals.
  • Deep MultiBox. And R-CNN different, Szegedy, who trained a neural network to predict the area of ​​interest, rather than using Selective Search. MultiBox single target detection may be performed to replace the confidence prediction can be predicted to a single category. However, MultiBox can not detect common goals, but still only detect a large pipeline, the need for further image blocks are classified. YOLO and MultiBox use convolution neural network to predict the bounding box, but YOLO is a complete detection system.
  • OverFeat. Et al Sermanet a convolutional neural network trained to perform positioning, and align the locator detection is performed [32]. OverFeat efficient implementation sliding window detection, it still is a decentralized system. OverFeat do optimized for positioning, rather than detection performance. And DPM, as positioners at the time predicted only see pictures of local information. OverFeat not theorized global context, and therefore require significant post processing to generate a coherent detection (produce coherent detections).
  • Similar MultiGrasp. Our model is designed with Redmon et al [27] of the grasp of testing. Our grid method to predict the bounding box is MultiGrasp system based on the return of grasps. However, grasp detection is simpler than the target detection task. MultiGrasp only need to predict the image contains a target area of ​​a crawl, it does not estimate the size, location, boundaries, category, just need to find a suitable capture area. YOLO is predicted bounding box and categories probability of multiple targets of different types in one image.

4. Experimental

首先,我们比较YOLO和其他实时检测系统在PASCAL VOC 2007上的表现。为了理解YOLO和R-CNN变体的差异,我们探索了YOLO和Fast R-CNN(R-CNN变体中性能最好的版本)在VOC2007数据集上的误差。基于不同的误差,我们展示出YOLO可以刷新Fast R-CNN检测的分数,降低背景误检率,开创一个新的记录。我们也呈现了VOC2012上的结果,对比了YOLO的mAP和最优秀的mAP记录。最终,我们呈现了YOLO在新领域(2个艺术品数据集)的泛化能力比其他检测器更好。
4.1 compared to other real-time systems
许多目标检测领域的研究,都在致力于让标准的检测管道更快。 \[5\] \[38\] \[31\] \[14\] \[17\] \[28\]然而,实际上只有 Sadeghi 等人创作了一个实时的检测系统,达到30帧/秒或更高。我们比较了YOLO和他们的DPM的GPU实现,要么跑在30Hz要么在100Hz上(这里貌似应该是指GPU时钟频率,但是难道不应该是MHz吗?)。虽然其他的研究努力没有达到实时的层次,我们也比较了他们的相对mAP和速度,以检查在目标检测系统中可用的精度和性能权衡。据我们所知,在PASCAL上,Fast YOLO是现有的最快的目标检测方法,其mAP达到52.7%,比以前实时检测工作的精度高了2倍多。而YOLO将mAP提高到了63.4%,并且仍然能达到实时的要求。我们也用VGG-16训练了YOLO。这个模型有更高的精度,但是也明显更慢。这么做的意义是和其他依赖VGG-16的检测系统进行对比,但既然用VGG-16的YOLO无法达到实时要求,所以后续的文章内容将还是专注于我们更快的YOLO模型。
Fastest DPM致力于不降低更多mAP的情况下提升速度,但是其实时性仍然差了2倍\[38\]。这也是受DPM对比神经网络的方法有着更低的精度的限制。R-CNN minus R\[20\]用静态边界框提议来代替了Selective Search方法。虽然比R-CNN更快,但仍然达不到实时性,而且如果提议的静态边界框不够好,会大大降低精度。
Fast R-CNN是对R-CNN的分类阶段进行了提速,但是仍然依赖selective search方法,该方法为一张图片生成候选边界框的时间是2秒。因此该模型虽有着高的mAP,但是也有着低到0.5的fps,这仍然远远达不到实时性。最近的Faster R-CNN使用神经网路代替了selective search方法来给出边界框候选,类似 Szegedy et al.\[8\] 我们测试过,他们的最好精度下能达到7fps,降低精度的话能达到18fps。Faster R-CNN的VGG-16版本的精度是YOLO的10倍,但是速度比YOLO慢6倍。 ZeilerFergus的Faster R-CNN只比YOLO慢2.5倍,但也精度也同样更低。
4.2 VOC2007 error analysis
为了进一步对比YOLO和目前最先进的检测器之间的差别,我们看看VOC2007上的详细结果分类。我们将YOLO和Fast R-CNN 对比,是因为在 PASCAL 上,后者是R-CNN中表现最好的变种,并且其检测是公开的。我们使用了 Hoiem et al. \[19\]的方法和工具。每个类别我们统计topN的预测结果。每个预测要么是正确的,要么是错误的,但是错误会根据具体的错误类型分类。

 

 
  
  
图4显示了所有20个类中每种错误类型的平均情况。YOLO很难准确定位目标。定位错误占YOLO所有错误的比例超过了其他所有错误的总和。Fast R-CNN的定位错误更低,但是背景错误更多。它把背景检测成目标的情况达到了13.6%,这个值几乎是YOLO的3倍。
4.3 Joint Fast R-CNN and YOLO

We use the bounding box YOLO given confidence level and degree of coincidence of the bounding box of bounding box and Fast R-CNN analysis enhance the accuracy of prediction. VOC 2007 on the test set, mAP raised to 71.8% from 75.0%. Other versions of the model and the combination of Fast R-CNN failed to achieve such improvement.

  
 

Although the joint YOLO and Fast R-CNN enhance the mAP, but no good speed. YOLO quickly approaching and even Fast R-CNN joint, there is not much time to calculate its increase.

 

4.4 VOC 2012 Results
在2012数据集中,YOLO的表现没能达到最高技术水平,因为其在小目标,比如瓶子、羊等,的检测上表现不好,但是在其他比如火车、猫等目标上,YOLO的表现依然很好。联合YOLO和Fast R-CNN后,其表现比Fast R-CNN增加了2.3%,排名上升了5。
4.5 generalization capabilities: detection of human art
目标检测的学术数据集的训练和测试数据都是来自同一个分布。在现实世界中,要预测的图像可能和之前学过的不同。我们在 Picasso Dataset \[12\]和 People-Art Dataset \[3\] 上比较YOLO和其他检测系统,使用这两个数据集都是为了检测艺术品中的人。图5显示了YOLO和其他检测方法的性能对比。为了参考,我们给出了VOC2007数据集中PERSON的检测AP列,该列所有的模型只在VOC2007数据上训练。在Picasso列,模型是在VOC2012上训练的,在People-Art列,模式是在VOC2010上训练的。R-CNN在VOC2007上的AP算高的。然而,R-CNN在艺术品图像上的表现就会急速下降。R-CNN使用基于自然图像调优的Selective Search 边界框提议法。而R-CNN的分类阶段只能看到很小的区域,并且需要良好的候选区域提议。DPM在艺术图像上的表现没有R-CNN那么差,但是AP也有所下降。
YOLO在艺术图像上的表现相比其他模型下降的更少。 与DPM一样,YOLO建模对象的大小和形状,以及对象之间的关系和对象通常出现的位置。艺术图像和自然图像在像素级别非常不同,但是在物体的大小和形状上却是相似的,因此YOLO可以预测出良好的边界框并进行类别检测。

 

  

5. Real-time detection of the external environment

YOLO是一个快速,准确的目标检测器,这使其成为计算机视觉应用的理想选择。 我们将YOLO连接到一个网络摄像头,并核实从摄像头获取图片到显示检测结果的实时性能。最终的系统是交互式的和吸引人的。虽然YOLO是独立处理图片,但是加上摄像头后,它的功能像一个跟踪系统,检测着目标的移动和外观变化。该系统的演示例子和源代码可以从我们的项目网站上找到: http://pjreddie.com/yolo

Summary 6

我们提出YOLO,一个统一的目标检测模型。我们的模型构造简单,可以直接在全图上训练。和基于分类器的方法不同,YOLO在一个直接对应检测效果的损失函数上训练,并且训练的是一个完整的检测模型(覆盖了检测的所有过程,比如边界框预测、类别预测、非极大值抑制等)。Fast YOLO是目前文献中最快的通用目标检测器,YOLO打破了这个记录。YOLO在新领域的泛化能力使其成为对速度、鲁棒性有要求的应用下的理想选择。

Acknowledgments:

This work is partially supported by ONR N00014-13-1-0720, NSF IIS-1338054, and The Allen Distinguished Investigator Award。

references:

请参考原论文。

in conclusion:

  • YOLOv1 end presents a model of object detection, image input, only a running web, can recognize the position of the target image and the type of target.
  • Unlike the sliding window and the regional technical candidate, YOLO in training and forecasting, see the complete picture, so YOLO implicitly encoded contextual information about the category and category appearance, which greatly reduces the background of false detection of cases.
  • YOLOv1 compared to other models, faster, and can already achieve real-time detection of water products; generalization stronger, even in training on natural picture, and then on the art picture test can have a good performance.
  • YOLOv1 drawback is also very clear: on the predicted target position is not accurate enough; difficult to detect small targets (such as birds); generalization difficult than the picture to a new or unusual aspect.

ok, yolov1 here to introduce you, the next article, "taught you how to learn to do with the depth of the object detection (VI): YOLOv2", we will introduce v2 v1 on the basis of what had been done to improve.

Guess you like

Origin www.cnblogs.com/anai/p/11465175.html