YOLOv5 compared to Faster RCNN. Who wins?

栏目: IT技术 · 发布时间: 4年前

内容简介:The deep learning community is abuzz with YOLO v5. ThisAll the controversy aside, YOLOv5 looked like a promising model. So I have compared it to one of the best two stage detectors — Faster RCNN. To do this comparison, I have taken 3 videos from with diffe

Doing cool things with data!

Introduction

The deep learning community is abuzz with YOLO v5. This blog recently introduced YOLOv5 as — State-of-the-Art Object Detection at 140 FPS. This immediately generated significant discussions across Hacker News, Reddit and even Github but not for its inference speed. Two prominent issues were — Should the model be called YOLO and are the speed benchmarking results accurate and reproducible. If you are interested in Roboflow’s response then you can find it here .

All the controversy aside, YOLOv5 looked like a promising model. So I have compared it to one of the best two stage detectors — Faster RCNN. To do this comparison, I have taken 3 videos from with different contexts and run the 2 models side by side. My assessment includes observations on the quality of results and inference speed. So lets get started!

YOLOv5 model

The YOLOv5 implementation has been done in Pytorch in contrast with the previous developments that used the DarkNet framework. This makes it easier to understand, train with it and deploy this model. There is no paper released with YOLO-v5. My understanding is that architecturally it is quite similar to YOLO-v4 . One different may be the use of Cross Stage Partial Network (CSP) to reduce computation cost. It is still not clear if YOLO-v5 runs faster than YOLO-v4 but I prefer Pytorch implementations and I am amazed with how easy it is to train with this model. My personal experience of running inference through it was also seamless.

The release of YOLOv5 includes five different models sizes: YOLOv5s (smallest), YOLOv5m, YOLOv5l, YOLOv5x (largest). The inference speed and mean average precision (mAP) for these models is shared below:

YOLOv5 compared to Faster RCNN. Who wins?

YOLO v5 stats from UltraLytics repo

Inference using YOLO-v5

The first step would be to clone the repo for YOLO-v5 . Install all the requirments. I use Pytorch 1.5 and the code works without any problems.

You can download all the weights for different pretrained COCO models using:

bash weights/download_weights.sh

To run inference on a video, you have to pass the path to the video and the weights of the model you want to use. If the weights argument is not set, then by default code runs on the YOLO small model. Sample arguments I used are shared below:

python detect.py --source video/MOT20-01-raw-cut1.mp4 --output video_out/ --weights weights/yolov5s.pt --conf-thres 0.4

The output video will be saved in the output folder

Training using YOLO-v5

I haven’t personally tried training using YOLO-v5 on a custom data set but a good step by step tutorial is shared by Roboflow on Youtube here .

Faster RCNN Model

For the Faster RCNN model, I used the pretrained model from Tensorflow Object Detection . Tensorflow Object Detection shares COCO pretrained Faster RCNN for various backbones. For this blog I have used the Fatser RCNN ResNet 50 backbone. This repo has shared a nice tutorial on how to do inference using their pretrained model here .

Comparison of YOLOv5 model with Faster RCNN

The first scene I chose was a street driving scene considering the importance to self driving car industry. The results from both these models is shared below:

YOLOv5 compared to Faster RCNN. Who wins?

YOLOv5 model evaluated on Driving Video

YOLOv5 compared to Faster RCNN. Who wins?

Faster RCNN evaluated on Driving Video

YOLO model seems much better at detecting smaller objects — traffic lights in this case and also is able to pick up the car when it is farther away i.e smaller.

Run Speed of YOLO v5 small(end to end including reading video, running model and saving results to file) — 52.8 FPS!

Run Speed of Faster RCNN ResNet 50(end to end including reading video, running model and saving results to file) —21.7 FPS

These results are evaluated on NVIDIA 1080 Ti.

So far YOLO v5 seems better than Faster RCNN

YOLOv5 compared to Faster RCNN. Who wins?
YOLO v5 and Faster RCNN comparison 1

The next video is a basketball match video from youtube. The results of both models are shared below:

YOLOv5 compared to Faster RCNN. Who wins?

YOLO v5 on Basketball Video

YOLOv5 compared to Faster RCNN. Who wins?

Faster RCNN ResNet 50 on Basketball Video

The Faster RCNN model is run at a threshold of 60% and one could argue it is picking up the crowd with a single person label but I prefer YOLO here for the cleanliness of results. Both models have false positive on the abc logo.

I was also disappointed on how both failed to detect the basketball ball even though sports ball is a category in COCO. Their tally is now:

YOLOv5 compared to Faster RCNN. Who wins?

YOLO v5 and Faster RCNN comparison 2

For the final video, I chose an indoor crowded scene from MOT data set . This is a challenging video with low lighting, distant and dense crowds. The results from both the models are shown below.

YOLOv5 compared to Faster RCNN. Who wins?

YOLO v5 model tested on indoor crowded scene from MOT data set

YOLOv5 compared to Faster RCNN. Who wins?

Faster RCNN model tested on indoor crowded scene from MOT data set

This is interesting. I would say both these models struggle to detect people in the distance as they walk into the corridor. This could be attributed to low light and smaller objects. When the crowd gets closer to the camera, both are able to pick up overlapping people.

YOLOv5 compared to Faster RCNN. Who wins?

YOLO v5 and Faster RCNN comparison 2

Conclusion

The final comparison b/w the two models shows that YOLO v5 has a clear advantage in terms of run speed. The small YOLO v5 model runs about 2.5 times faster while managing better performance in detecting smaller objects. The results are also cleaner with little to no overlapping boxes. Ultralytics have done a fabulous job on their YOLO v5 open sourcing a model that is easy to train and run inference on.

This blog also shows an emerging trend with computer vision object detection towards moving to models that are both faster and accurate .

If you have tried YOLOv5 please share your experience in the comments below.

At Deep Learning Analytics , we are extremely passionate about using Machine Learning to solve real-world problems. We have helped many businesses deploy innovative AI-based solutions. Contact us through our website here if you see an opportunity to collaborate.

References

  • YOLO v5
  • Faster RCNN
  • YOLO v4

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

JAVASCRIPT权威指南(第四版)

JAVASCRIPT权威指南(第四版)

David Flanagan / 张铭泽、等 / 机械工业出版社 / 2003-1-1 / 99.00

《JavaScript权威指南》全面介绍了JavaScript语言的核心,以及Web浏览器中实现的遗留和标准的DOM。它运用了一些复杂的例子,说明如何处理验证表单数据、使用cookie、创建可移植的DHTML动画等常见任务。本书还包括详细的参考手册,涵盖了JavaScript的核心API、遗留的客户端API和W3C标准DOM API,记述了这些API中的每一个JavaScript对象、方法、性质、......一起来看看 《JAVASCRIPT权威指南(第四版)》 这本书的介绍吧!

图片转BASE64编码
图片转BASE64编码

在线图片转Base64编码工具

URL 编码/解码
URL 编码/解码

URL 编码/解码

HEX CMYK 转换工具
HEX CMYK 转换工具

HEX CMYK 互转工具